Now that the JeeNode talks to the Raspberry Pi, it’d be interesting to be able to reset the JeeNode as well, because then we could upload new sketches to it.
It’s not hard. As it so happens, the next pin on the RPi connector we’re using is pin 12, called “GPIO 18”. Let’s use that as a reset pin – and because this setup is going to become a bit more permanent here, I’ve made a little converter board:
This way, a standard JeeLabs Extension Cable can be used. All we need is a board with two 6-pin female headers, connected almost 1-to-1, except for GND and +5V, which need to be crossed over (the other wire runs on the back of the PCB to avoid shorts).
This takes care of the hardware side of resets. Now the software. This is an example of just how much things are exposed in Linux (once you know where to find all the info).
There’s a direct interface into the kernel drivers called /sys, and this is also where all the GPIO pins can be exposed for direct access via shell commands or programs you write. Let’s have a look at what’s available by default:
$ sudo ls /sys/class/gpio/ export gpiochip0 unexport $
The “export” entry lets us expose individual GPIO pins, so the first thing is to make pin 18 available in the /sys area:
sudo echo 18 >/sys/class/gpio/export
That will create a virtual directory called /sys/class/gpio/gpio18/, which has these entries:
$ sudo ls /sys/class/gpio/gpio18/ active_low direction edge power subsystem uevent value $
All we’ll need is the direction and value of that pin. Let’s first make in an output pin:
sudo echo out >/sys/class/gpio/gpio18/direction
Now, we’re ready to reset the JeeNode. I found out that the pin needs a negative transition (from 1 to 0) to do this, so the following three commands will do the trick:
sudo echo 1 >/sys/class/gpio/gpio18/value sudo echo 0 >/sys/class/gpio/gpio18/value sudo echo 1 >/sys/class/gpio/gpio18/value
And sure enough, the JeeNode resets, and the terminal I have running in another window shows the RF12demo startup message again:
We’re in control – shell over sketch!