At developerWorks Recipes from IBM, novices and experienced developers can access and contribute powerful IoT recipes. This step-by-step tutorial offers a head start on IoT or other applications that connect hardware, run analytics, use machine learning and more.
This recipe provides an example on how to connect ESP8266 wifi module to IoT Foundation with NodeMCU Lua interpreter.
To program ESP8266, the authos used lua based NodeMCU firmware that has built-in MQTT functions required to communicate with IoT Foundation service. The recipe is basically few lines of lua script that periodically publish emulated data to the IoT Foundation.
In real application, the data will be obtained from external sensor such as temperature, humidity, etc through ESP8266 GPIOs.
The program plant.lua is ready now and can be downloaded from Sourceforge.
The Grove moisture sensor measures soil moisture and displays the measuring value on a LED bar. Furthermore the value is sent to dweet.io.
dweet.io is simple publishing and subscribing method for machines, sensors, devices, robots, and gadgets (name it things). Published messages are ‘dweets’. It’s helpful to think of dweet.io as a Twitter for things.
To visualize these data I use freeboard.io. You can understand freeboard.io as a ridiculously simple dashboard for IoT devices.
The image above shows such a dashboard for example. Each 30 seconds a new moisture value is sent to dweet.io and is visualized on the dashboard.
Clearly you can see the reduction of moisture over the time.
Similar program samples you will find in my book “Building an IoT Node for less than 15 $” expected at the end of November.
Yesterday I got some LoLin devices ordered from banggood.com and had to recognize that the form factor of this boards is similar to the original NodeMCU-devkit v0.9 (v1).
The following images compare the LoLin NodeMCU (v3) with an Amica NodeMCU (v2).
NodeMCU is open source hardware and software. Therefore this is no problem in general. But, if you want to include a NodeMCU-devkit into an existing baseboard you can run into problems if you do not consider such possible differences.
The Grove Base Board for NodeMCU is equipped with (female) headers that allow plugging both NodeMCU variants. Not all baseboards offer this degree of freedom.
The soil moisture content is an important parameter for the life quality of plants and their growth. NodeMCU can help to control the watering of your plants with simple means.
I combined a few Grove components and a NodeMCU to build an experimental base. In the image the used components can be recognized.
Here ist a list of the used components (incl. their Seeedstudio ordering number):
NodeMCU-devkit (v0.9 or v1.0 are suitable)
Grove Base Shield for NodeMCU (SKU: 105020008)
Grove LED Bar v2.0 (SKU: 104020006)
Grove – Moisture Sensor (SKU: 101020008)
The Grove Base Shield has a socket for NodeMCU suitable to plug the older and the actual versions. In the image above I used an NodeMCU-devkit v0.9.
The resistive sensor can have problems by contamination over longtime.
As alternative sensors I found the capacitive moisture sensors Chirp! and VH400.
The Chirp! sensor has an I2C interface and is easy to connect. The VH400 probe has an voltage output (0 – 3 V) and can be connected similar to the Grove-Moisture senors.
I will complete the code to measure moisture, display the moisture value with an LED bar, publish a MQTT message by dweet.io and visualize the data via freeboard.io.
The last mechanism is described in my book “Building an IoT Node for less than 15 $” too.