Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

nabto/unabto-esp8266-sdk

Repository files navigation

Nabto-ESP8266 Arduino Library

This is an example AppMyProduct device application on the ESP8266 Arduino platform simulating a heatpump. Currently supports the Heat Control Ionic starter app.

Please also refer to this article on the Nabto blog for more information.

What is needed to run the example

The example is tested on an Adafruit HUZZAH ESP8266 Breakout board connected with a standard USB to TTL Serial Cable in the following way:

USB to TTL Serial Cable wiring

To compile the example you need to install the Arduino IDE and the ESP8266 Board Package. Adafruit provides a nice tutorial on how to setup your Arduino IDE accordingly.

We also need a device name and key, both of which can be created at portal.appmyproduct.com

Step 1: Download the ESP8266 Board Package

Follow the steps laid out here to install the ESP8266 Board Package into the Arduino IDE OR read it right here:

Open up the Arduino IDE. Click File -> Preferences and then copy this

http://arduino.esp8266.com/stable/package_esp8266com_index.json

into the Additional Boards Manager URLs input field. Click OK

Now click Tools --> Board: -> Boards Manager

Here we search for ESP8266 and click Install

The ESP8266 Board Package is now installed

Step 2: Install the uNabto SDK library

There are two ways of getting the uNabto SDK library:

Using git

git clone --recursive https://github.com/nabto/unabto-esp8266-sdk

then change directory to the unabto-esp8266-sdk folder and run

copy-unabto.cmd # Windows
copy-unabto.sh  # Linux

to copy the files from the unabto submodule into the appropriate folders. Afterwards you can create a zip library with

make-lib.cmd # Windows
make-lib.sh  # Linux

OR

Download the latest unabto-esp8266-sdk-X.X.X.zip zip library from the releases (not the Source code (zip)).

No matter which way, we can now add the library to the Arduino IDE via Sketch -> Include Library -> Add .ZIP Library... and then browse to and add the unabto-esp8266-sdk-X.X.X.zip that was just created/downloaded.

Run the example

We can now open the HeatPump.ino example by going to File -> Examples -> Nabto-ESP8266 -> HeatPump

Here we need to enter the SSID and password of the wireless network we want to attach to. Furthermore we need to input the device name and key we created at portal.appmyproduct.com.

When the example is compiled you set the device into flash mode by pressing the following button combination on the Adafruit HUZZAH ESP8266 Breakout board:

  1. Hold down the GPIO0 button, the red LED will light up
  2. While holding down GPIO0, click the RESET button
  3. Release RESET, then release GPIO0
  4. When you release the RESET button, the red LED should light up dimly

Now the sketch can be uploaded to the device. When finished it automatically connects to the specified wifi network and runs uNabto.

In your serial monitor you should see the following printout:

Connecting to WiFi........done
Init Nabto...
Device id: 'n7j4qebq.hyr7o.appmyproduct.com'
Program Release 123.456
Application event framework using SYNC model
SECURE ATTACH: 1, DATA: 1
NONCE_SIZE: 32, CLEAR_TEXT: 0
Nabto was successfully initialized
Nabto v123.456 running
SECURE ATTACH: 1, DATA: 1
NONCE_SIZE: 32, CLEAR_TEXT: 0
State change from IDLE to WAIT_DNS
Resolving dns: esp8266test1.demo.nab.to
State change from WAIT_DNS to WAIT_BS
State change from WAIT_BS to WAIT_GSP
########    U_INVITE with LARGE nonce sent, version: - URL: -
State change from WAIT_GSP to ATTACHED

Now, connect to your device using the Heat Control Ionic starter app and see the LED change its brightness according to the target heat.