Skip to content

Arduino

Philippe Coval edited this page Jan 15, 2020 · 2 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.

MORE WITH IOTJS

Alternatively check other non-arduino frameworks for MCU supporting IotJs.

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").

ESP8266: RGB LAMP

Note: IotJs is not used here, only Arduino API.

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

ARDUINO: LEVELSENSOR

Note: IotJs is not used here, only Arduino API.

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 --depth 1 --recursive https://github.com/mozilla-iot/webthing-arduino ; cd webthing-arduino
make
make -C examples/LevelSensor upload monitor

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.

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

STM32 contributions:

RESOURCES

LICENSE: CC-BY-SA-4.0

INDEX

Clone this wiki locally