/rad-esp8266

An IoT framework library for ESP8266 modules.

Primary LanguageC++MIT LicenseMIT

rad-esp8266

Latest Travis CI build status Documentation Status

Documentation

The full documentation is at http://rad-ESP8266.rtfd.org.

Overview

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.

Requirements

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

Quickstart With Arduino IDE & SmartThings

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!

Arduino IDE

  1. Install the latest version of the Arduino IDE.
  2. 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 the Additional 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 the Tools > Board menu after installation).
  1. 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
  1. Download the RadEsp8266 library and extract it to your libraries directory for the Arduino IDE.

  2. From the application menu File > Examples > RadEsp8266, locate the and open the SimpleBinarySwitch sketch and add your local WiFi credentials:

    const char* ssid = "YOUR_SSID";
    const char* pass = "YOUR_PASSWORD";
    
  3. Be sure to set the proper upload settings in the Tools menu and then upload the sketch to the module.

  4. Once sucessfully uploaded, connect a momentary push button to GPIO 0 and a LED to GPIO 2. See the following connection diagram for a reference.

    qs_bb_img

    qs_schem_img

  5. 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
    
  6. 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}}'
    

SmartThings

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.