Category: raspi

Puking up a Code Sample in Python

I hate python, it’s not friendly to my eyes.  That being said the compiler is super helpful.  And yes, I’m still alive despite the best efforts of …. myself.

I’m throwing together a raspberry pi zero powered uptime checker and an i2c backpack lcd display. I didn’t want to write my own library, and I wanted this to get thrown together as fast and easily as possible. Thus, I followed this guide using python. Python, ick.

But I’m not posting this to hate on anything. If I post more info on this, then I’ll share my logic for things. Anyway, one of the reasons for this display is an easy was to check the status of my DMR repeater. Here is the basic code I banged together to use the Project Halligan API that Brandmeister provides to check the status of my repeater.

Of note: Brandmeister does not provide an API call that tells you if the repeater is up or down. The website checks the last seen time and if it’s been more then 15 minutes it assumes that repeater is down. Checking against “status” or “status_text” will not tell you if the repeater is up or down merely what timeslots are linked – whether the repeater is connected or not.


import urllib.request, json
from datetime import datetime, timezone, timedelta
from email.utils import formatdate

try:
	url = urllib.request.urlopen("https://api.brandmeister.network/v2/device/313051")
except urllib.error.URLError as e:
	ResponseData = e.reason
	print (ResponseData)
else:
	lastSeen= (json.load(url)['last_seen'])
	print (lastSeen)
	timeOutTime = datetime.now(timezone.utc) - timedelta(minutes=15)
	timeOutString = timeOutTime.strftime("%Y-%m-%d %H:%M:%S")
	print (timeOutString)

	if timeOutString < lastSeen:
		print ("Repeater up")
	else:
		print ("Repeater Down")

This code isn't pretty but it does work, on my machine at least. The post however, is most certainly honest.


Dutch Apple, Please

Let’s start by recapping my experience with the models and operating systems to frame the discussion.  I’ve actually dealt the majority of the models, and my opinion is much the same on all of them.

Version Comments Operating Systems
2B+ I experienced stability issues and burned up two usb wireless cards.  I worked with the Pidora OS primarily, but eventually gave up and switched to Raspbian.  This did not make it any better as I can remember. Pidora & Raspbian
3A/B The only one I actually “like.”  Excellent for RetroPie and Octopi.  I haven’t used the Raspbian base OS. Retropie, Octoprint
4B I really hate the Pi 4.  Its not much of an specifications improvement over the 3B as far as I can tell.  I haven’t worked with mine enough to know though.  However,  I’ve already corrupted (and destroyed) one SD are a result of the power supply issues present in every single iteration of Raspberry Pi.  That leads to my main complaint about the Pi 4.  Why implement USB-C but not have it negotiate to any of the higher voltage options? Retropie
Zero W Its okay.  The SD cards seems to get corrupted often but they aren’t often destroyed.  Overclocking seems to work different on every single board I’ve bought.  Also, my first ZeroW would segfault when I tried to use the wireless connection. Retropie, Pi-KVM, PiStar
Zero W<2/td>

A very welcome update to my Retroflag GPi. Sadly, since its a new system I set up and clean install and by then I was done playing with. I will say though, I wish I had bought 2 of them. It seems stable enough, and I need to take the time to play with it more.

 

My main beef with the Pi family is that needing a 5.1 volt USB power supply defeats the purpose of using USB to power them.  Add in the awful time I had with the 2B (and the Alfa Alfa AWUS036H that it ate) I’m not really thrilled with them  I’m sure someone will say that by using a properly rated power supply all my problems could be solved.  However, I would argue that if you need a “special” voltage spec, then use a 9VDC or 7.5VDC barrel jack and step down the voltage on the board.

What prompted my post about this an article posted on Hackaday about modify the pi to try to help with the voltage warnings.  My opinion is this: Pi’s are not USB devices.  A wide variety are arguments were made in the article’s comments.  They’re enlightening, but ultimately I think you know the ones that I agree with this.  The Pi5 should feature a barrel jack instead of a USB.  There are a bunch of ways to try to help with the problem but at the end of the day if you put a USB connector in people will use whatever USB they have handy.  The legrand USB outlet I installed at my desk provides 4.87 volts which is with the USB power specification.  It can power a pi zero, and usually a 3B.  However it will completely kill an SD card on the Pi 4.  Even the USB-C charger (that will auto negotiate to 9VDC or 12VDC) cannot power my Pi4.

I loved my 3B retropie setup and in general I’ve been satisfied with the Pi3 devices I’ve deployed.  Using octoprint has been fantastic – I can now monitor my 3d printers remotely from work.  But I’m not sold on the other models.  Here are a few other tips for a less frustrating Raspberry Pi experience.

  • Don’t back up your home directory or configuration files.  Create a complete image the card using dd or follow HowToGeek’s instructions (I don’t run windows in that capacity).  If the SD card dies you flash a new one and go.
  • Don’t use a Pi’s when what you mean to use is a microcontroller.  Arduino, teensy, atiny85 are all more stable (and less money).
  • Don’t use pi’s when you could run a virtual machine instead.  You may even find it useful to spin up a copy of Fedora or Ubuntu server on an old machine.
  • Don’t use them for “mission critical” tasks.  Setup a “hot swap spare”.  $35 for the pi & imaging an SD card over is nothing.

Long and short, if I need to deploy a pie make mine a dutch apple.  By that I mean be cognizant of the limitations and strange requirements of the system and don’t try to get outside of them.  If I use a pi I know exactly what I want and why.

Update 20220417: Comment on the ZeroW2


Setting up a raspi

I finally got my christmas rasberry pi up and running. I had to redo the power grid to my room to properly support all the things I have plugged in upstairs. I live in a 100 year old farm house so now my room has as many outlets as the entire upstairs. Plus I had a few other issues that slowed me down in getting it done until now.

Here’s a couple of notes I took while working on this project.

Have to have an HDMI monitor with noobs. Also keyboard and mouse.

If you’re using NOOBS Lite, you’ll need to have a wired connection. For reasons (100 year old farm house), I needed to share the wireless across the wired connection of my laptop. I run KDE fedora linux and this guide talks setting up sharing wireless to a wired connection via KNetwork: https://bbs.archlinux.org/viewtopic.php?id=126285.

Use gparted to format SDCard. FAT32 is alright. Unzip with unzip -d destination ~/Downloads/NOOBS_lite_v1_3_4.zip

I chose arch linux because its small (so less download time on my very slow internet connection and i presume updated more then pidora (which is based on fedoraredhat and a distro I am more familiar with.)

after it says 100% you need to let it sit awhile or you will bork the install

Reboot into your fresh pi install. Run wifi-menu to setup wireless connection.

At this point you can either do the following configuration while connected on the tv or over ssh.

You can check your router for the IP address, or you can nmap scan. Either way, ssh to it and use root/root for login and password.

Enabling onboot wireless:
systemctl enable netctl-auto@wlan0
probably want to setup a static ip address
nano /etc/netctl/wlan0

Something like this is what you need after editing /etc/netctl/wlan0.

Description='Automatically generated profile by wifi-menu'
Interface=wlan0
Connection=wireless
Security=wpa
ESSID=ssid
Key=wpa password
IP=static
Address='10.13.37.7/24'
Gateway='10.13.37.1'
DNS=('10.13.37.1')

pacman -Syu to update the distor.

change the hostname by editing /etc/hostname

Change the root password. You’re internet facing now.

Time to reboot and enjoy your pi.