Standard Disclaimer: You may learn something out of it, or you may not. I make no warranties.
First things first
In this post I want to create a minimal IOT device, it should be capable of sending some messages to a internet server to show connectivity.
I got a ESP-01 board, an ESP8266 with the smallest set of connectors. You can get it from eBay, Aliexpress, and many other places. I got mine from tindie, bundled with a Flasher which makes it easy to just plug your ESP-01 into the flasher and connect the flasher via USB with your computer to push the code down.
Beware: the ESP-8266 works with 3.3V power, if you connect it to 5V directly it will probaly be killed. (I did not try this yet). Using the flasher will take care of the power conversion during the programming, but if you run your ESP8266 later without the flasher you need to take care of the right power. We will get into the details later.
This is the bare minimum required to run your ESP-8266.
I use Ubuntu linux box for my developemnt, but it is very similar on MacOS or Windows.
First install the Arduino IDE (currently 1.6.10) as described on the Arduino Website and specifically for the IDE on different platforms:
Next you need to install the ESP8266 tools for Arduino IDE with
- Open Preferences in the Arduino IDE
in the field for Additional Boards Manager URLs
- Open Tools -> Boards -> Boards Manager and install esp8266
- Also in the Boards Menu, select the Generic ESP8266 Module as your board.
This didn’t work…
There seems to be an issue in the esp8266 flash tool used by this and I had to apply this recipe to fix it.
Push some code
My first program for the ESP8266 should just send some message to show it is alive. I have chosen thingspeak.com as receiver because it was easy to set up. The program below will send a message containing the hostname and the time since last boot (in milliseconds), you need to:
- register an account on www.thingspeak.com
- create a channel and configure the first input field with a name of “Uptime [ms]”or similar - it is just a name for display purposes.
- note your write API KEY and channel number and fill into the code below.
- note down your WIFI SSID and password to connect to your WiFi router. Also to be filled into the program below.
The code is available on github abarbanell/arduino-esp8266.
With this you can see the data sent to thingspeak.com here. On this site you can then analyze the data with Matlab code and visualizations.
So my “thing” is up and running and now we can look at more complex tasks in the next posts.
Let me know in the comment if you have any questions, suggestions or corrections.