2015-08-12

Hello everyone!
I'm happy to present DeviceHive firmware for ESP8266!
DeviceHive is an Open Sources platform for IoT solutions.

Overview
DeviceHive firmware for ESP8266 is suppose to connect simple electronic devices with common interfaces to DeviceHive cloud service. Having this firmware on ESP8266 there is no need to write programs for hardware. Chip connects to specified remote DeviceHive server(which can be deployed in local network or in some cloud service) and waits for commands. Each command suppose to use some electronic interface to control some hardware connected to chip. It can be simple interaction with GPIO pins for turning on/off simple LED, relay or waiting some changes on pin from sensor. Also it is possible to connected more complicated sensors and actuators using UART or I2C bus. In other words, this firmware move the most commonly used interfaces right into cloud service where you can control your devices or even network of devices from any distance, from any point.

Example of connecting SSD1306 base OLED display:
https://www.youtube.com/watch?v=gKgU6RzaxFU

Source code of program that sends data to display:
https://github.com/devicehive/esp8266-f ... ample.html

DeviceHive server have two endpoints to send command commands or receive notifications: HTTP and Websocket. Developers can use any programming languages, any developer tools, any SDK that they prefer to interact with server and as a result with hardware. It is possible because all commands represent simple JSON string which sends via HTTP or Websocket. For example sending command with JavaScript looks like:

Code:

var xmlhttp = new XMLHttpRequest();
xmlhttp.open('POST','http://exmaple.com/api/device/deviceId/command', true);
xmlhttp.setRequestHeader('Authorization', 'Basic ' + btoa('user:password'));
xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8');
var myjson = {};
myjson['command"] = 'uart/write';
myjson['parameters'] = {'data':'SGVsbG8sIHdvcmxkIQ=='};
xmlhttp.send(JSON.stringify(myjson));

After receiving this command chip prints 'Hello, world!' in UART bus. The same idea with other interfaces.

Getting started:
First at all firmware have to be flashed into chip memory and chip have to be configured for using specified Wi-Fi network and DeviceHive server. Developers can build firmware and all tools for flashing and configuring by himself from sources. Or it can be downloaded from git repository: go to
https://github.com/devicehive/esp8266-f ... er/release
and download archive with the latest version.
For flashing chip needs to be connected to computer via USB-UART converter, CH_PD pin have to be connected to Vcc, GPIO15 and GPIO0 have to be connected to ground and 3.3 power supply should be used.
After assembling, connect it to computer. Install driver for your USB->UART converter. Make sure that virtual serial port is available in your system( virtual COM is present on Windows OS, '/dev/ttyUSB*' on Linux, '/dev/tty.*' on OS X). Unpack archive with firmware and flash it running 'esp-flasher-<your-os>' in terminal. Flasher automatically detects serial port and use '0x00000.bin' and '0x40000.bin' files for flashing. You can also you esp-tool for flashing -
https://github.com/themadinventor/esptool

Now remove wire from GPIO0(live it float or connect to high), reboot device and connect to firmware with with 'esp-terminal-<your-os>' util. You can also use any other util that can connect to terminal via UART and support escape sequences, PuTTY or GNU 'screen' for example. Port parameters are: 115200 8N1.
Firmware terminal is a unix like terminal with few commands. It exists for chip configuring and debugging. To see debug output type 'dmesg'. To configure run 'configure' command. Follow instructions in terminal. You need to know DeviceHive server credentials for configuring. If you don't have DeviceHive server instance you could use free playgroun on DeviceHive site. Follow to
http://devicehive.com/playground
and register there and you will have your own DeviceHive server instance. DeviceHive server can be deployed in local network or on some cloud hosting services. Follow for DeviceHive server deployment instructions on
http://devicehive.com

After rebooting you can send commands to DeviceHive server and ESP8266 perform them. List of accepted command is in this document -
https://github.com/devicehive/esp8266-f ... SP8266.pdf
You can use DeviceHive web admin control panel to send command for test purpose or learning. Go in web admin, 'Devices' tab, 'commands' subtab, 'enter new command'. Type command and parameters and press 'push'. After ESP8266 perform your command you can press 'refresh' button to see result.

You can find more detail instructions with images in 'DeviceHiveESP8266.pdf' file in archive with firmware. Or
https://github.com/devicehive/esp8266-f ... SP8266.pdf
(but be careful with only version, it can be newer than your firmware version)

Download
Current version v0.2 -
https://github.com/devicehive/esp8266-f ... re-v0.2.7z

v0.1 -
https://github.com/devicehive/esp8266-f ... re-v0.1.7z

Hope this firmware will be useful for your IoT or DIY projects! Any questions are welcome. Thank you!

Statistics: Posted by Nikolay — Thu Aug 13, 2015 1:13 am

Show more