IOT with the Intel Edison using Node.js

| Posted on January 19th, 2016 by Sean Hopen

Since I last blogged about IOT I've had a chance to work with a new platform, the Intel Edison. Intel invited me to attend an Edison hackathon at Project: SPACES OWL , and on a whim I attended. I liked it so much I recommended it to a client and they decided to upgrade one of their products with it. There are a lot of things I like about the Edison, in particular, a delightful experience with Node.js, but there were still couple of small hurdles to get over.

The Intel Edison is this great little System-On-a-Chip (so called SOC) that runs Linux, has 4 GB of flash memory, a 500MHz dual-core Atom CPU, built-in Wi-Fi, Bluetooth, a real-time clock, and just for fun a Quark core that runs a real-time OS at 100 MHz. I haven't used the Quark yet, but it's intriguing for some potentially time -sensitive operations we might do. For example, to time-stamp readings from a sensor, compensating for microsecond delays in communication or processing.

For communicating with sensors, it’s got 2 UARTs (for USB, RS232, etc), it also supports SPI and I2C. The compute module though small, needs to be plugged into some kind of expansion board to be useful. Those can be quite small like the mini-breakout board we're using, or the Arduino compatible breakout board.

One of the problems we had to deal with is that the second UART. All the messages from the Linux as it starts up are dumped by default to the second UART. That may be okay for some GPS or other sensors, but our sensors accept commands as well as reporting readings.

All that diagnostic info needs to be turned off, which proved to be a bit tricky. I also discovered that dumping sensor information into the debug terminal while booting up can crash Linux. That wasn't too hard to work around, but it did take a while to figure out what was going on. (Ask me in the comments and I'll post the details of the solution here).

The other issue I had was accessing the Edison's memory from USB (via a PC). Our app writes logs to the "Mass Storage Device"(MSD) -- a partition in the 4GB of eMMC memory that is made accessible to one of the USB ports on the mini-breakout board. The problem is both Linux and the USB Host can't reliably access the MSD at the same time. We managed to detect the cable's connection, and mount or unmount the MSD accordingly.

Our project has a web service for control and monitoring of the device. The platform we started with didn’t easily support Node.js. It required cross-compiling the Node source, and rebuilding the Linux kernel and there was some question about what the configuration should be for that platform. So we originally implemented the server in C++. Fortunately the Edison comes with Node.js pre-installed, and its well supported. So when new features were required for our web service, it was easier to re-implement using Node and Express than to update the C++ server.

The best thing about all this was the excellent support from Intel's community leveraging all the work that's been done with Arduino, and all the compatible third party boards that are available (see Grove, Sparkfun, Arduino).

My next step is to move more of the implementation to Node.js to stream data from the sensors to any device with WiFi. Let me know if you’re interested in our progress, and stay tuned…