Tuesday, February 16, 2016

The ESP8266 NodeMCU using the Arduino IDE for development (with optional MQTT and Bluemix)

I bought a NodeMCU (ESP8266) board from Aliexpress for just a few dollars.
The NodeMCU ESP8266 is cheaper than the Arduino and has more memory, includes wifi, and runs faster.


After a lot of false starts, I arrived at this process to allow development using the Arduino IDE that I'm already familiar with.

I received help from my fellow IBMer, Neil Kolban, who wrote this free eBook about the ESP8266:
http://neilkolban.com/tech/esp8266/


Most of this information is also found in the article here:
http://www.instructables.com/id/Get-Started-with-ESP8266-Using-AT-Commands-NodeMCU/?ALLSTEPS

The ebook and that article have much more information about other ESP8266 boards, so I've "boiled it down" here to what is necessary.


1. Download the latest Arduino IDE (1.6.7 or above)
https://www.arduino.cc/en/Main/Software

2. add the ESP8266 board manager to the Ardujino IDE

Start up the Arduino IDE software
go to file, preferences, additional boards manager URLs and enter
http://arduino.esp8266.com/stable/package_esp8266com_index.json
click OK
Go to Tools, board, board manager. Scroll down to the ESP8266 and on the bottom right click "install" (if there are multiple options, choose the latest)


3. Install a USB Driver for the NodeMCU.
Driver is here:
https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx
I suggest you reboot after installing it.
4. Connect the NodeMCU board to PC via a cable that has USB on one end and the microUSB on the other.

5. Look in Windows Device manager to find the driver for the NodeMCU under comm ports (windows start, device manager)

6. in the Arduino IDE, select the NodeMCU board
go to tools, board, scroll down to generic 8266, and select NodeMCU 1.0 in the menu.

7. Run the Blink code
in the IDE, select  file, examples, basic, blink
change the  three places where there is a number 13 to 2
go to the menu at top and select: sketch, upload
(note: if it fails, just restart and try again or click sketch, upload again)

Further exploration:
8. Use with MQTT and IBM Bluemix IoT Foundation
download the pubsub library to talk over MQTT

https://github.com/knolleary/pubsubclient/tree/master/src
Install a program - you can google many. The examples for the pubsub library are a good start.

https://github.com/knolleary/pubsubclient/tree/master/examples/mqtt_esp8266

if you want to read this about MQTT on IBM Bluemix
https://docs.internetofthings.ibmcloud.com/devices/mqtt.html


Note: you may also find these helpful
http://www.seeedstudio.com/recipe/1107-getting-started-with-nodemcu-devkit-in-arduino-ide.html

http://www.whatimade.today/esp8266-easiest-way-to-program-so-far/

https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/using-arduino-ide

https://github.com/esp8266/Arduino#using-git-version-

No comments: