Arduino IDE Setup
On the Arduino IDE do the following steps: (Version of IDE used is 1.8.4)
- Get the latest Library release for the Blynk Board in Release v1.2.0 · blynkkk/blynk-library · GitHub. Open Arduino IDE and go to sketchboard in File->Prefs->sketchboard and in this Director, copy the downloaded Blynk Library (manually) into Library and Tools directory respectively.
- Go to File Prefs and set the Board Mgr URL to http://arduino.esp8266.com/stable/package_esp8266com_index.json
- Choose your board. Go to Boards Mgr - install ESP8266. Select “Generic Boards ESP8266”. (Starting with Arduino v1.6.4, Arduino allows installation of third-party platform packages using Boards Manager.)
- Kühnel, Claus. Building an IoT Node for less than 15 $: NodeMCU & ESP8266 (Kindle Location 519). Skript Verlag Kühnel. Kindle Edition.
- Change Tools->Reset Menu to NodeMCU
- Now select the example code we need to run from File > Examples > Blynk > BoardsAndShields → ESP8266 Standalone. Use 814533a2a55e41cd9fde51fa70fedbd7 as the auth key.
- You can also pick up examples from https://examples.blynk.cc
- Open the serial monitor, setting the baud rate to 9600. Wait for the “Ready (ping: xms).” message.
On the Mobile App for Android, Click on New Project and put a Button on the project. Under the Output tab- Click pin and select the pin to which led is connected to NodeMCU, here it is digital pin 2, hence select digital and under pin D2. And Click continue. Then click the “Run” button in the top right corner of the Blynk app. Press the button and watch the LED!
Additional code can be downloaded from Blynk for NodeMCU - Introduction - Robo India || Tutorials || Learn Arduino || Robotics
MQTT Client Library with NodeMCU
The PubSubClient for the Arduino open-source electronics platform has been available since 2009. The web site is http://www.hivemq.com/blog/mqtt-client-library-encyclopedia-arduino-pubsubclient/. It has been used in a number of production systems and has recently been updated to support MQTT 3.1.1.
Open the Library Manager by selecting Sketch → Include Library → Manage Libraries…Search for “PubSubClient”. Click the “Install” button. You do not need to install the library manually, but for reference you can find it here on github Release v2.8 · knolleary/pubsubclient · GitHub.