Huffduffer Radiodan part 3 – using the switch with Radiodan code

Update: a step by step how-to is now available.

Yesterday I got a microswitch working – today I want to make it turn on the radio. Given that I can only start my podcasts in client-side mode at the moment, I’ll have to bodge it a bit so I can actually see it working (Andrew is going to help me understand the server side API better tomorrow).

So my plan is to

1. Switch back to the radiodan “magic button” radio
2. Make my switch replace the default on button
3. Make my switch turn the radio on when it’s open

and if I have time

4. attach a simple rotary encoder for volume
5. attach an RGB LED for the status lights

For the magic button radio, we have had some simple PCBs made to make the soldering easier for two RGB LED-rotary encoder-buttons, but it doesn’t fit in my new box, and anyway, I want to see how difficult it is without the PCB.

It’s 3pm now and I have about an hour free.

Switch back to the radiodan “magic button” radio

This is easy. I’ve sshed in and do this:

pi@radiodan-libby ~ $ sudo radiodan-device-type

Current device type: radiodan-type-huffduffer
Device type required. Valid types radiodan-type-example, radiodan-type-huffduffer, radiodan-type-magic

so I do

pi@radiodan-libby ~ $ sudo radiodan-device-type radiodan-type-magic

and reboot

Once we’re back up, if I go to http://radiodan-libby.local I should see the full-fledged radio interface, but I don’t, I just see my Huffduffer one.


I guess I messed up Monit or rc.d. Looking at ps ax | grep node, both versions are running.

looking at ls /etc/rc*.d

radiodan-huffduffer is in there but not magic, so I remove it from rc.d

update-rc.d -f radiodan-huffduffer remove


and that fixed it.


I’m testing it by doing

sudo radiodan-device-type radiodan-type-huffduffer


sudo radiodan-device-type radiodan-type-magic


to check I’ve got it switching properly, and it is.

ps ax | grep node

gives us among other things

node /opt/radiodan/apps/buttons/current/bin/server /opt/radiodan/apps/magic/current/config/physical-ui-config.json

/opt/radiodan/apps/magic/current/config/physical-ui-config.json is the config file for the physical buttons, dials etc.

catting that file gives us (among other things)

"id": "power",
"pins": [
"pin": 3,
"pull": "down",
"pressedIsHigh": true

so I want to

  • move my button to pin 3 from 17
  • change pressedIsHigh to false (because I want it to trigger when not pressed)
  • is that it?

For now I’m just trying to see if the pin 3 works. If I touch the croc clips together and look in

tail -f radiodan-buttons.log

I can see this:


so it seems to be working, but I can see in the web interface that it’s not turning on.

[debugging session with Andrew]

I had the pin wrong – we use the wiringpi ones, so 3 is the 8th on the left working downwards:

I was using one of the rotary encoder pins.

Also I need a pullup resistor because it’s attached to ground, not 5v (the rotary encoder-buttons work a bit oddly, a better example is “next” in the config file.)


"id": "power",
"pins": [
"pin": 3,
"pull": "up",
"pressedIsHigh": false

(then sudo monit restart radiodan-buttons )

This is the correct config, as the rotary encoder that usually does the ‘on’ button is usually connected to power. So now it goes and on and off when I touch the croc clips together. Fixing them to the switch as before, it goes on when I press it down. I need it to go on when my button is not pressed. I’m not sure how to do that, and I’m 30 mins over time so I’ll leave it till tomorrow.

Andrew also says: “you may want to copy that config file somewhere since any new software updates will overwrite it — a current limitation of our update software”

To see the things controlled by monit:

sudo monit summary

This stops it monitoring a script that turns the radio off when the power button is held down for 3 seconds:

sudo monit stop radiodan-cease

and this:

sudo monit stop updater_status

stops the updater (both between reboots)

One thought on “Huffduffer Radiodan part 3 – using the switch with Radiodan code

Comments are closed.