connect an esp8266 to the internet

13
Connect an ESP8266 to the Internet with thethings.iO

Upload: thethingsio

Post on 14-Jan-2017

564 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Connect an ESP8266 to the Internet

Connect an ESP8266 to the Internet with

thethings.iO

Page 2: Connect an ESP8266 to the Internet

thethings.iO is the Internet of Things platform that enables fast and scalable connection of things to the Internet, allowing you to monitor and manage your

devices in real time and get flexible analytic reports.

What’s thethings.iO?

Page 3: Connect an ESP8266 to the Internet

We are going to test the esp8266 with a simple example in which we can toggle a LED on and off.

We will use the firmware NodeMCU to ease the process of programming and prototyping the board.

Page 4: Connect an ESP8266 to the Internet

STEP 1: Get NodeMCU

1. Send it to your email

web: http://frightanic.com/nodemcu-custom-build/

Page 5: Connect an ESP8266 to the Internet

* Make sure it has the following modules included: node, file, GPIO, WiFi, net,

timer and MQTT.

Page 6: Connect an ESP8266 to the Internet

STEP 2: Setup the board to flash the firmware

1- Wire GPIO0 and ground to LOW on the FTDI. 2- Wire chip enable and VCC to VCC on the

FTDI.

3- Wire the TX and RX on the board to the FTDI. Connect the USB to your PC.

Page 7: Connect an ESP8266 to the Internet

STEP 3: Flash the firmware

1- Check the port of the FTDI in /dev/tty(USB|ACM|S)* 2- Use the esptool utility to flash it (https://

github.com/themadinventor/esptool)

$ esptool.py --port /dev/ttyUSB0 write_flash 0x00000 nodemcu.bin

Page 8: Connect an ESP8266 to the Internet

STEP 4: Setup the board to upload the Lua script

1- Wire the GPIO0. 2- Wire a LED and resistor to GPIO2

and ground.

Page 9: Connect an ESP8266 to the Internet

STEP 5: Upload the script

Page 10: Connect an ESP8266 to the Internet

1- Clone the esp8266 repository from https://github.com/theThings/esp8266.

2- Edit the led lua file and change the ssid, password and token variables to suit

your needs.

3- Load the script using luatool: $ luatool.py -sdr -f mqtt/lua/led.lua -t init.lua -p /

dev/ttyUSB0

4- Restart the board.

Page 11: Connect an ESP8266 to the Internet

STEP 6: Testing

Use curl to send the value you want the LED to be: $ curl -H "Content-Type: application/json" -X POST "https://api.thethings.io/v2/

things/TOKEN" -d “{\"values\":[{\"key\":\"LED\",\"value\":\"ON\"}]}"

$ curl -H "Content-Type: application/json" -X POST "https://api.thethings.io/v2/things/TOKEN" -d "{\"values\":[{\"key\":\"LED\",\"value\":

\"OFF\"}]}"

Page 12: Connect an ESP8266 to the Internet

That’s it! Easy, right?

Start connecting things now: thethings.io