Tuesday, April 3, 2018

IoT - NodeMCU

Introduction

Nobody now a days need introduction to IoT. To me its more buzzword where all the devices or things gets connected to internet. Regardless 'IoT' term is there or not, devices will get connected to internet if they can talk over wifi, phone networks or any other connection mechanism

Server side

IoT and Cloud seems getting coupled together with specialized IoT offerings from cloud providers. As far as we can host an http end point in internet with capability to handle load, device has connectivity to there, we are good to deal with most of use cases. Really don't need to follow the buzzwords of cloud providers. But there are so many marketing sessions happened and happening on IoT by just demoing the server side. Nothing at all about device side.

Device / Thing

Device is any Turing machine with internet connectivity and required sensors and actuators. The decision making is done by the Turing machine which is nothing but a computer CPU. Generally people use small boards which have these capabilities. Arduino, Raspberry Pi are famous in this area. If we use an old PC, laptop or mobile connected to required sensors and actuators, its same as the Thing. It doesn't necessarily be the small device always.

But the small device has advantage over PCs laptops and mobiles where the display, keyboard are optional things for the so called Thing. Basically the boards are modular. If we need a moisture sensor we can plug that in else just don't use that. That reduce the cost drastically when we use the boards. The board ensures that there is computing power from processor and I/O ports to communicate with the world.

NodeMCU

This is one of the board similar to Arduino and Raspberry Pi. More powerful than Arduino but below 
Raspberry Pi. The boards are available from 2.5 USD and up. NodeMCU currently is in Version 3 which indicate there were 2 version earlier and people might have used those and reported issues and perhaps fixed. So it is better to buy and try one now.

Why NodeMCU

The simple answer is its real out of the box WiFi enabled Thing. Other boards may need additional purchases to connect to internet. Second is that it has more specs that Arduino in the same price range.

This post is mainly about experience with one variant of NodeMCU V3 board named LoLin. Below is AliExpress link
https://www.aliexpress.com/item/new-Wireless-module-CH340-NodeMcu-V3-Lua-WIFI-Internet-of-Things-development-board-based-ESP8266/32556303666.html

Driver

We have to install the proper USB driver in order to connect from computer to the board to push the code. Have to google CH340G driver. Fortunately for Win10 it didn't had that issue. I am not sure whether I might have installed as part of any other experiment earlier.

Pin layout

If we just google for NodeMCU quick start tutorials we can get steps which will take us towards blinking the LED in the board. When I got the board, I tried the same but the code in those tutorials never worked to blink the LED. 

First I was in impression that they shipped a faulty one. But the rating of the listing made me rethink. how come that listing can get 108 five star ratings if they ship faulty products. Started deep googling. Deep googling seems a new term when the normal google doesn't help. That require one seperate post. 

It landed me into another world of incompatibilities among the NodeMCU boards. Below is one post discussing about the LED built into the board and the pin number to activate LED. The interesting thing is that we need to output 0 to turn the LED and vice versa.

https://arduino.stackexchange.com/questions/38477/does-the-node-mcu-v3-lolin-not-have-a-builtin-led

Connecting to WiFi

Another tutorial on connecting to the WiFi. This is yet to be tested using my board
http://henrysbench.capnfatz.com/henrys-bench/arduino-projects-tips-and-more/arduino-esp8266-lolin-nodemcu-getting-started/

I am planning to use the board to automatically water our curry leaves plant from Aquarium by sensing moisture in the soil. Hopefully more updates will be coming soon.

References

https://frightanic.com/iot/comparison-of-esp8266-nodemcu-development-boards/

No comments: