This is an update to my post [“Hypriot, wiringPI and a Blinking Light”]({% post_url 2015-12-06-hypriot-wiringpi-and-a-blinking-light %}).
There are two major changes to the whole thing.
-
The GPIO service is now a webservice implemented with Node.js and Express. For interfacing with the GPIO pins of the Raspberry Pi I’m using a library called “onoff”.
-
The shell script that is responsible for all the blinking has been replaced with a piece of JavaScript using “unirest” to call the GPIO service via HTTP.
Both the GPIO service and the JavaScript that sends the HTTP requests to it run in their own Docker containers and are set up with docker-compose as usual.
Setting it all up was not that difficult, but not being very familiar with JavaScript, the biggest issue I had was making the LED blink at a steady interval. Not being used to JavaScript’s asynchronous nature, it took me a while and a very helpful StackOverflow answer to make it work: “How to create a sleep/delay in nodejs that is Blocking?“.
Get it all from GitHub with
git clone https://github.com/twissmueller/docker-pi.git
cd docker-pi
git checkout tags/2016-01-13
Start the whole thing with
docker-compose --x-networking up -d
Done for today!