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.
The example is tested on an Adafruit HUZZAH ESP8266 Breakout board connected with a standard USB to TTL Serial Cable in the following way:
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
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
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.
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:
- Hold down the GPIO0 button, the red LED will light up
- While holding down GPIO0, click the RESET button
- Release RESET, then release GPIO0
- 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.