Instruments4Chem

High Performance, Low Cost…

IoT - The Internet of Things


The “internet of things” is a phrase describing a constantly growing global web of smart devices that can be controlled via the internet from anywhere in the world. I’ve seen predictions that by the year 2020 there could be as many as 50 billion such devices in use worldwide. Recently, I’ve been investigating several low cost IoT platforms as neither the Propeller or XMOS processors I’ve been using have any built-in wireless connectivity.

This page describes some initial evaluations/experiments using two different IoT platforms - the Particle Photon P0 and Espressif Systems ESP8266. These platforms are small PCB’s with inexpensive yet powerful 32 bit processors combined with wireless capabilities that make them ideally suited to IoT projects.

IoT - Particle Photon P0 + Sensor Breakout


The Particle Photo P0 is a platform targeting internet-of-things (IoT) applications. The P0 contains a BroadCom wi-fi chip and a powerful STM32 ARM Cortex M3 micro controller. An internet-enabled P0 can be programmed remotely from anywhere in the world.

The breakout board shown opposite has a P0 (at top) and a sensor board with an ST Microelectronics' LSM9DS1 9-axis motion sensor, and a Measurement Specialties high-accuracy MS5611 altimeter (bottom).

Code running on the P0 periodically polls all of the on-board sensor readings to the cloud, while a LabVIEWTM vi running on a PC with wi-fi access can see the results in real-time from a distant location.

The LabVIEWTM front panel to perform logging from this instrumentation is shown in the image below.
In the experiment shown opposite, the Particle Photon + Sensor module described above is placed on the passenger’s seat in a car that is making an ~20 km journey around suburban Melbourne, Australia.

Every ~2 seconds the Photon (which has a wireless internet connection) sends a result string to the cloud with the 3-axis accelerometer, gyroscope and magnetometer data, together with temperature and pressure readings.

The LabVIEWTM vi shown opposite (running on a PC in my home office) receives the result string, parses it and then displays the various readings in a collection of chart windows.

This proof-of-principle experiment illustrates that relatively low bandwidth cloud-based data transactions are easy to implement using the Particle Photon P0 device.
Stacks Image 6293

ESP-12 module


The photo opposite shows an ESP8266 WiFi module mounted onto a breadboard-compatible breakout package known as the ESP-12 or NodeMCU. This module can be found on EBay and is very inexpensive.

A particularly attractive feature of the ESP8266 is that it can be programmed using the Arduino IDE. Some excellent instructions for configuring the IDE for doing so can be found here.

Some Possible Ways to Use an ESP8266 in Wireless Applications

There are numerous possibilities for using the ESP8266 chip in wireless/IoT applications. Here’s a few possibilities that I’ve found to work nicely.

Wireless Access Point (WAP)


The ESP8266 can be configured to serve as a wireless access point. In that case the ESP8266 is accessed via its IP address from an iPhone or PC. This allows simple commands to be issued to (for example) control the I/O pins on the chip, or to measure and read back the voltage at an analog input pin. That scheme works fine for short range control applications.

Cloud-Based Data Sevices


Alternatively, the ESP8266 can connect as a web server to a Cloud-based data service. As the IoT rapidly grows in popularity many such services are springing up. One example is using the ESP8266 to POST messages to https://dweet.io, which requires no prior user setup. The message, which might contain data acquired by the ESP8266 from a sensor network can then be retrieved using the HTTP GET command and after parsing, the results can then be displayed in a graphical window.

Although there are a number of websites that offer utilities for creating simple GUI’s to interact with the Cloud, my preference is to implement the GUI in LabVIEWTM, making use of the LabVIEWTM’s in-built suite of HTTP vi’s. In this way one then has access to extremely flexible tools for analyzing and processing the data as has been discussed elsewhere.

Blynk


Blynk is a very attractive option for communicating with the ESP-8266. One first installs the Blynk application onto an iPhone or Android device and configures the Arduino IDE with the Blynk library. Using the Blynk app one then creates a graphical user interface on the iPhone with various controls and indicators. On the ESP8266 end functions are coded to receive and respond to data from the iPhone app. Apart from that all one needs is a simple call to the Blynk_Run() function in the Blynk library. A convenient (and highly visual way) to test the communication link is to connect a NeoPixel ring to the ESP8266 development board and use the Blynk app on the smart phone to initiate various programmed sequences of colours on the NeopIxels.

MQTT


Another excellent way to communicate with the ESP8266 is using the MQTT protocol. The MQTT acronym stands for Message Queuing Telemetry Transport and involves messages that are either published or subscribed to. The protocol is well suited to IoT projects (the messages are very succinct) and it allows multiple nodes or clients to communicate via a single broker. A public broker that is easy to use can be accessed at hivemq.com.

In transactions between brokers and clients the MQTT protocol supports various QOS (quality of service) options – in QOS0 the broker/client delivers the message once with no confirmation, in QOS1 the message is delivered at least once, but this time with confirmation required and in QOS2 the message is delivered exactly once with a four-step handshake. The higher QOS levels have higher latency but offer more reliable transactions.

In order to ensure that publishers and subscribers send and receive the correct messages, MQTT makes use of “topics”. For example, an ESP-12 development board to which a temperature sensor is connected could publish the sensor’s data using the topic name ESP12/temperature. A client subscriber to broker.hivemq.com would then gain access to those sensor readings by making reference to this same topic name. Experiments are currently being conducted using a LabVIEWTM vi to access the hivemq broker using an MQTT library found here.

An important consideration when using the no-cost, public Cloud-based data services referred to above is that the information posted is publicly accessible, which may not be desirable. While ideal for initial experimentation, a charge can be expected if these services are then to provide more secure options for data transmission /retrieval.

Apart from the simple wireless AP approach, all of the methods described above afford the user an easy means to remotely control their IoT project from anywhere in the world providing internet is available at each end of the connection.

It is already clear from my very brief exploration of these IoT platforms that there are endless possibilities for using them. I’ve now started thinking about a project using such devices to monitor the output from a wind/solar power generation system at a remote off-grid farm site (but with good internet access) located about 3 hours from my home in Melbourne, Australia.