Welcome to weblogs.com.pk Sign in | Join | Help


In Firmata post we established that we can have Python or Node.js application running on a computer; that can be a Single Board Computer like Raspberry Pi running Rasbian or Windows 10 IoT and can control and get sensor data from the Microcontrollers like Arduino or ESP8266


There exists many IoT frameworks for Javascript / Node.js that allows us to write our programs and Johnny-Five is one such popular framework. Using such framework we not only have access to many Javascript / Node.js libraries but also get a platform on which we can write our program quickly in more friendlier environment. Johnny-Five supports Arduino as well as many other boards through the IO Plugin; that is Firmata compatible interface; to communicate with non Arduino hardware. Johnny Five can be used on richer boards like Raspberry Pi and Galileo as well as with Microcontrollers through IO Plugins. It also includes DSL libraries for working with many different actuators and sensors that enable writing IoT code more fun.

Johnny Five needs Node.js v4.2.1 (at the time of this writing); and on Raspberry Pi you can get more recent version using NodeSource

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt install nodejs

And then use npm install johnny-five to get the bits. For ESP8266; we will create firmata object similar to the Firmata post and then on its ready event; hand it over as io to johnny five. We can then continue from there and subscribe to its ready event and write the program. The Blink code will be something like this:

There are also DSL libraries for other sensors and actuators; for instance we can use Thermometer library for temperature sensor; https://github.com/rwaldron/johnny-five/wiki/Thermometer has more details

  • Note that we are using ESP8266 that is 3.3V powered and we are not using the built in controller and instead giving our own temperature calculation lambda


  • 3.3V of ESP8266 is noisy; we can get better result by using some digital sensor
  • ESP01; the widely used ESP8266 board sadly doesnt expose its Analog pin; and we have to use digital sensor

We can use Johnny Five on Windows 10 IoT as well, in fact Node.js Tools for Visual Studio UWP Extension support Johny-Five and Cylon by providing Project Templates. For details on Node.js Tools for Visual Studio UWP Extension; check out Blink with Windows 10 IoT post


For development in Visual Studio and deployment on Windows IoT; we need to watch out for certain gotchas. After NPM package restore; we need to update them; this will apply Windows IoT specific patches to the node modules. Another important thing to watch out is MAX_PATH issue; when building the nodule modules are zipped up and make part of the package; and in doing this; it can face this issue; use npm dedupe to flatten the node modules; and we might have to go deep and dedupe inner modules as well; depending on the errors it generate. For instance I faced issues in node modules under firmata; I simply navigated there and dedupe it and then dedupe in root again. We have to restart the Visual Studio so it picks up the changed things. At the Windows 10 IoT side; we also need to enable Long Paths by issue-ing reg add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /t REG_DWORD /d 1 /v LongPathsEnabled /f at Device Portal and then restart the device to pick the things.


You can optionally specify –use-logger debug option and it will store the console output in the log file that you can then review


Published Friday, February 03, 2017 9:42 PM by khurram


No Comments

New Comments to this post are disabled