Skip to content
Philippe Coval edited this page Feb 6, 2019 · 29 revisions

MICRO CONTROLLERS:

INTRODUCTION:

In IoT domain Micro controllers (MCU) are very popular, because of low cost and low consumption.

Arduino boards are very popular in academics or DiY communities, then API were ported to other micro controllers than Atmel, like espresif ESP8266, ESP32 etc.

Mozilla's is supporting Arduino API for through this SDK project:

The supported language to program MCU webthings is currently C/C++.

Note that IoT.js is also targeting constrained devices (like ARTIK05x on TizenRT or STM32 on NuttX).

mcu

So to recap, MCUs can serve WebThings API for Mozilla Gateway either in native language (C/C++) or using script runtime (IotJs, uPython, enventually Lua too?) but Gateway is too resource consuming for that.

DEMO:

"Smart Orchid Demo" showed a light controller and arduino moisture sensor:

web-of-things-agriculture-20180712rzr.webm

A moisture sensor is just plugged on analog pin (and +5v GND, the digital pin was not used here, but it can be used for other boards without analog like RaspberryPi and use potentiometer as "hardware threshold").

RGB LAMP: ON ESP8266

Developing webthing on Arduino APIs or compatible platforms such as Espressif ESP8266 or ESP32

Once your have setup build tool, Developing is pretty straight forward, and it has been covered elsewhere:

The RGB Lamp code is upstreamed at:

Watch video for more:

webthing-esp8266-webapp-20180602rzr

LEVELSENSOR: ON ARDUINO

Since I shared a slightly more advanced example that handle ADC port, it was used to monitor the moisture of the ground of a plant, or any analogic sensor:

To rebuild, just use GNU make:

git clone https://github.com/mozilla-iot/webthing-arduino ; cd webthing-arduino
make

for reference a docker file has been upstreamed:

sudo=$sudo # In not configured for $USER
sudo apt-get install docker.io # Or adapt
$sudo docker build https://github.com/mozilla-iot/webthing-arduino.git
# AVR Memory Usage
# ----------------
# Device: atmega2560
# Program:   40136 bytes (15.3% Full)
# (.text + .data + .bootloader)
# Data:       1451 bytes (17.7% Full)
# (.data + .bss + .noinit)

If you prefer you can setup IDE and do the manual configuration.

Note, hardware side, I used an Arduino mega with Ethernet Shield ( same one in this IoTivity 1.2 "arduino switch" demo )

MORE WITH TIZEN:RT

TizenRT OS is also targeting lower class devices, currently hardware support is limited to a few platforms like ARTIK05x and a few others plus QEmu.

The key feature for Javascript developers is IoT.js support, this mean code can be portable from on GNU/Linux OS to contrained devices without any rebuild effort, which is is not the case of Arduino compabible devices.

MORE WITH STM32 (IN PROGRESS)

IotJs is also supporting NuttX kernel on STM32F4

Track status at:

More hints shared at:

Hints and work in progress:

git clone -b sandbox/rzr/nuttx/devel https://github.com/rzr/rzr-wip/ ; cd rzr-wip
make nuttx/devel
make iotjs/devel # Enable IoT.js on 2d build

STM32F7 (IN PROGRESS)

Basic IoTjs is running on Nucleo-f767zi on NuttX OS:

Usage:

mount -t procfs /proc ; mkdir /tmp ; mount -t tmpfs /tmp ; df
ifconfig ; ifdown eth0 ; ifconfig eth0 hw 00:80:E1:34:ff:ff; 
ifconfig ifup eth0; renew eth0; ifconfig
ifconfig ping 8.8.8.8 ; ping ifconfig.me 
cd /tmp/ ; wget http://ifconfig.me/ip ; cat ip
cd /tmp ; echo "console.log(process)" > p.js; iotjs p.js

Status:

ARDUINO

Alternatively arduino framework can be used with a couple of fixes:

STATUS: UPSTREAMED

Related Upstreamed contributions:

For reference code was developed in this repo: (but most of it is upstreamed)

Possible open tasks:

  • TODO: refactor to handle Arduino's WiFi shield too
  • TODO: port iotjs to arduino/ESP and compare performance

RESOURCES

LICENSE: CC-BY-SA-4.0

INDEX

Clone this wiki locally