The full documentation is at http://rad-ESP8266.rtfd.org.
RAD-ESP8266 is an IoT framework for communicating with and controlling ESP8266 modules using a Pub-Sub HTTP API. It is designed to work in conjunction with the rad-home package to enable communication across various IoT ecosystems.
This library builds on top of existing libraries such as ArduinoJson, LinkedList and ESP8266-Core libraries such as ESP8266SSDP and ESP8266WebServer to provide a framework for building, configuring, discovering and communicating with a variety of devices such as sensors and switches.
Several "barebones" examples are provided that can simply be flashed to a chip and configured. For simple switch and sensor applications, these may provide all the functionality that is needed, however, the API can also be used to customize the devices for more complex or custom applications.
Supported ESP8266 chip versions:
- ESP-01
- ESP-12E
Supported Arduino IDE versions:
- Arduino IDE >= 1.6.4
Supported Arduino ESP8266 versions:
- ESP8266 Core 2.X.X
Supported AduinoJson versions:
- ArduinoJson 5.10.0
Supported LinkedList versions:
- LinkedList 1.2.3
The following steps should help you get an ESP8266 module setup and connected to SmartThings as a Switch. You will be able to turn it on/off from the SmartThings mobile App as well as recieve triggers when the switch is triggered manually by the momentary push button. Let's get started!
- Install the latest version of the Arduino IDE.
- Install the ESP8266 Core package using the Boards Manager. You can follow the instructions from the ESP8266 Arduino GitHub or the steps below should work as well.
- Start the Arduino IDE and select
File > Preferences
from the application menu.- Enter the URL
http://arduino.esp8266.com/stable/package_esp8266com_index.json
into theAdditional Board Manager URLs
field. You can add multiple URLs, separating them with commas.- Open the Boards Manager from
Tools > Board
menu and install esp8266 platform (and don't forget to select your ESP8266 board from theTools > Board
menu after installation).
- Select
Sketch > Include Library > Manage Libraries
from the application menu to open the Library Manager. Search for and install the latest supported versions of the following libraries:
ArduinoJson
LinkedList
Download the
RadEsp8266
library and extract it to yourlibraries
directory for the Arduino IDE.From the application menu
File > Examples > RadEsp8266
, locate the and open theSimpleBinarySwitch
sketch and add your local WiFi credentials:const char* ssid = "YOUR_SSID"; const char* pass = "YOUR_PASSWORD";
Be sure to set the proper upload settings in the
Tools
menu and then upload the sketch to the module.Once sucessfully uploaded, connect a momentary push button to
GPIO 0
and a LED toGPIO 2
. See the following connection diagram for a reference.If you see the following output from the Serial port, your module is sucessfully connected to your WiFi and ready to receive commands and send events:
Starting... Connecting to YOUR_SSID... WiFi connected IP address: 192.168.1.113
You should be able to push the momentary button to toggle the LED. Using a computer or device located on the same network as the ESP8266, you can submit an HTTP request like the following to turn the LED on or off:
# cURL request to turn the LED on curl -v -X POST 'http://<IP_ADDRESS>/commands' --data \ '{"feature_name": "switch_1", "command_type": "Set", "data": {"value": true}}' # cURL request to turn the LED off curl -v -X POST 'http://<IP_ADDRESS>/commands' --data \ '{"feature_name": "switch_1", "command_type": "Set", "data": {"value": false}}'
After your ESP8266 module is sucessfully connected to your WiFi network, you can then begin the intergration into your IoT ecosystem. Currently, only the SmartThings ecosystem is supported, but there are plans to integrate with othes such as OpenHAB, Blynk, IFTTT, AWS IoT etc.