Posts Tagged Improvements

Raspberry Pi vs. Avahi

It turns out that the various Avahi daemons performing the magick between whatever.local names and dotted-quad addresses for Raspberry Pi descend into gibbering madness when confronted with:

  • One name corresponding to multiple IP addresses
  • One IP address used for multiple MAC addresses
  • Multiple names for one IP address
  • Multiple names for one MAC address
  • Multiple IP addresses for one MAC address
  • Multiple MAC addresses for one IP address
  • Any and all combinations of the above at various times

The least of the confusion involved an incorrect IP address linked to a familiar name pulled from deep history by a baffled daemon doing the best it can with what it thinks it know. Despite what I concluded, rather early in the process, there’s no real error, other than what amounted to a self-inflicted fast-flux nameserver attack.

Anyhow, I devoted the better part of an afternoon to sorting out the mess, which involved labeling all the streaming radio players with their MAC addresses and rebooting them one-by-one to allow all the daemons time to recognize the current situation:

Raspberry Pi 3 - WiFi MAC address

Raspberry Pi 3 – WiFi MAC address

That label corresponds to the Pi 3’s on-board WiFi adapter.

For Pi 2 boxen, the MAC address travels with the WiFi adapter jammed into a USB port:

SunFounder WiFi Adapter - MAC address

SunFounder WiFi Adapter – MAC address

I didn’t label the (unused) Ethernet jacks, figuring I’d solve that problem after it trips me up.



Raspberry Pi Streaming Radio Player: Room Customization

Sometimes you (well, I) want a bit of late-night music, which is now one button press away. However, I initially set things up so the Raspberry Pi’s startup code executed a Python script on a network share from the file server in the basement, which shuts down around midnight after the daily backup.

Keeping a local copy meant having to update that copy whenever I tweak the code, a nuisance not to be tolerated. This Bash (or whatever) code in /etc/rc.local figures out if the server is up and, if so, updates the local copy from the server. If the server isn’t up, then it just runs with what it has:

# was !/bin/sh -e

... snippage ...


ping -c 1 $server
if [ $? -eq 0 ]
  mount -o ro ${server}:/mnt/bulkdata/Project\ Files/Streaming\ Media\ Player/Firmware/ /mnt/part
  rsync -auv /mnt/part/ /home/pi
  umount /mnt/part

sudo -u pi sh -c 'python /home/pi/ any' &

N.B.: you must remove the -e from the shebang, because otherwise the script jams to a stop when the ping fails. Took me a while to figure that out, yup.

Use raspi-config to force the startup sequence to wait until the network is available. Turns out that the DHCP process can stall for half a minute, so fixed timeouts don’t work.

Hardcoding the server IP address eliminates a whole bunch of mysterious failures apparently due to whatever handles the translation from mollusk.local to the dotted quad. Maybe that’s not really a problem, but I’ll run with it.

Now the streamers fetch the Latest and Greatest version whenever they’re on during the day and run their local copy, with the room parameter telling it where it lives.

Life is good!



Raspberry Pi Streaming Radio Player: Command Line Parsing

Some experience suggested different default stations & volume settings for the streamers in various rooms, so the Python code now parses its command line to determine how to configure itself:

import argparse as args

cmdline = args.ArgumentParser(description='Streaming Radio Player',epilog='KE4ZNU -')
cmdline.add_argument('Loc',help='Location: BR1 BR2 ...',default='any',nargs='?')
args = cmdline.parse_args()

I should definitely pick a different variable name to avoid the obvious clash.

With that in hand, the customization takes very effort:

CurrentKC = 'KEY_KP7'
MuteDelay = 8.5         # delay before non-music track; varies with buffering
UnMuteDelay = 7.5       # delay after non-music track
MixerVol = '15'         # mixer gain

Location = vars(args)['Loc'].upper()
print 'Player location: ',Location'Player setup for: ' + Location)

if Location == 'BR1':
  CurrentKC = 'KEY_KPDOT'
  MixerVol = '10'
elif Location == 'BR2':
  MuteDelay = 6.0
  UnMuteDelay = 8.0
MixerVol = '5'

The Location = vars() idiom returns a dictionary of all the variables and their values, of which there’s only one at the moment. The rest of the line extracts the value and normalizes it to uppercase.

Now we can poke the button and get appropriate music without having to think very hard.

Life is good!

The Python source code, which remains in dire need of refactoring, as a GitHub Gist:


1 Comment

Electronics vs. Dark Rooms

Despite its diminutive size, the white LED on the end of the Dell AC511 USB SoundBar lights up a dark bedroom surprisingly well:

Dell AC511 USB SoundBar - white power LED

Dell AC511 USB SoundBar – white power LED

That’s pretty much the only power-on indicator for the streaming players, so I didn’t want to just slap a strip of black tape over it. Instead, because white LEDs don’t emit much energy toward the red end of the spectrum, I made a cute little filter from a snippet of Primary Red gel filter material, surrounded by a black Gorilla Tape donut:

Red filter for Dell AC511 USB power LED

Red filter for Dell AC511 USB power LED

Two layers of Primary Red cut the light intensity to a dim glow that’s barely visible in daylight and completely inoffensive at night:

Red filter for Dell AC511 - installed

Red filter for Dell AC511 – installed

The blue activity LED on the SunFounder got the black electrical tape treatment, however, with just a sliver showing through to give a hint that it’s still active:

SunFounder RT5370 USB WiFi Adapter - masked LED

SunFounder RT5370 USB WiFi Adapter – masked LED

One of the other WiFi adapters has a pinhole over a red LED that’s barely visible. Another, seemingly identical one, lacks the red LED under the pinhole; when I asked the vendor about that, I was told it was removed “to save power.” Yeah, right. That was part of the motivation to try a different adapter next time around, with good results.

Of course, you must wrap an opaque black case around the Raspberry Pi to tamp down the red and green LEDs on the PCB. It’s possible to control them in software, with varying degrees of difficulty depending on which Pi you have, but …


1 Comment

Raspberry Pi WiFi Adapters

One might be forgiven for thinking these two USB Wifi adapters are essentially identical:

USB Wifi adapters

USB Wifi adapters

Turns out the SunFounder RT5370 (on the top, with the stylin’ curved case) has better performance than the Wifi With Antenna (on the bottom, with full-frontal chunk goin’ on), by a not inconsiderable 5 to 10 dB. Boosting the received power level in the fringe areas of our house from -70 dBm to -63 dBm makes all the difference between not working and steady streaming.

The built-in WiFi antenna on a Raspberry Pi 3 ticks along 10 dB lower, with -80 dBm (10 pW!) at the receiver making for poor communication: a Pi 3 works perfectly within reasonable line-of-sight of the router (even through our wood floor) and wakes up blind in fringe areas. Hacking an external antenna probably helps, but definitely isn’t a net win compared to ten bucks worth of USB adapter.

The wavemon utility (it’s in the Raspbian repo) comes in handy for figuring that sort of thing.

There is, of course, no way to determine anything important about the adapters from their product descriptions, which are essentially identical, right down to the price. Neither have any product identification on their cases. The back of the package for the SunFounder gadget gives some specs, none of which may mean anything (clicky for more dots):

SunFounder RT5370 USB WiFi Adapter Specs

SunFounder RT5370 USB WiFi Adapter Specs

I ordered another SunFounder adapter, Just In Case it comes in handy, with the hope that both behave the same way.



Raspberry Pi 3 Reset Switch

The (relatively) new Raspberry Pi 3 PCB layout puts the Run header in a different location than in the Pi 2, but a minute of filing gnaws a suitable opening:

Raspberry Pi 3 - Reset Switch

Raspberry Pi 3 – Reset Switch

As before, a hot-melt glue blob holds the switch in place. I’d prefer a black case, if only to hide the blob, but clear-ish is what’s available right now.

Remember those orderly shutdowns, even at the cost of a keypad button!


Leave a comment

Cast Iron Pan Seasoning: Round 3

After seasoning the pan after every meal for a few weeks, then not doing that for a few more weeks, its thick glaze began looking somewhat scuffed:

Cast Iron Pan - scuffed

Cast Iron Pan – scuffed

You may recognize some of those scars from the previous picture:

Wagner skillet - two weeks of use

Wagner skillet – two weeks of use

Perhaps the multi-layer seasoning was entirely too thick and prone to chipping; this time, I’ll try a thinner coating. Because it’s cast iron, the pan under the coating remains undamaged.

A few hours in a bucket of sodium carbonate solution with a battery charger driving a few amps through it removed most of the glaze and a few minutes with a sponge sanding block cleaned off the rest. Applying flaxseed oil and heating it to 400 °F on a regular burner (under close supervision!) produced a nice coating:

Cast Iron Pan - seasoned

Cast Iron Pan – seasoned

The single layer was way slick for veggies in the evening and handled the morning omelet with aplomb, so we’ll run with it until something interesting happens.

Leave a comment