Slide 1

Slide 1 text

REMOTE CONTROL OF IoT LINUX DEVICES ARDUINO CONNECTOR | LINUXLAB 2018 04|12|2018

Slide 2

Slide 2 text

2 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT ABOUT ME LUCA CIPRIANI CIO, ARDUINO @MASTROLINUX

Slide 3

Slide 3 text

3 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT 3 INTRO | GOALS

Slide 4

Slide 4 text

4 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT ARDUINO - KNOWN FOR MICROCONTROLLERS MKR FOX 1200 MKR WAN 1300 MKR GSM 1400 MKR NB 1500 MKR WIFI 1010 MKR ETH SHIELD MKR1000

Slide 5

Slide 5 text

5 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT RUNS ON LINUX TOO

Slide 6

Slide 6 text

6 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT USE CASE Give users a quick and easy web interface to • Check the status of the system • Configure networking • Install packages • Deploy apps/containers, Arduino Sketches

Slide 7

Slide 7 text

7 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT CONTROL LINUX FROM THE WEB • Old problem, Old solutions • HTTPS is hard to achieve • Bi-directional communication • Work on most network topologies • Create a web server, contact it via http • Cannot have HTTPS unless domain name is registered and IP address is static/known • UDP port are often closed

Slide 8

Slide 8 text

8 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT KNOWN SOLUTIONS DID NOT FIT USE CASE Here is a random list • Ubuntu Landscape • Zentyal • Ajenti • Webmin • Others

Slide 9

Slide 9 text

9 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT LANDSCAPE - DO NOT BE OVERKILL We do not want to store users’ data unless needed or with big advantages for both users and us. We do not want to deal with state synchronization. Scaling is really expensive!

Slide 10

Slide 10 text

10 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT SECTION TITLE

Slide 11

Slide 11 text

11 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT ZENTIAL - OUR TARGET ARE NOT SMB You have to control a Raspberry, not a small office, do you really need a whole OS?

Slide 12

Slide 12 text

12 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT

Slide 13

Slide 13 text

13 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT AJENTI - GOOD PRODUCT BUT STILL WEB SERVER They have a nice, well designed product but has the same issues we mentioned already. HTTP server based system!

Slide 14

Slide 14 text

14 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT

Slide 15

Slide 15 text

15 Remote Control of IoT Linux Devices | LinuxLab 2018 - Firenze, IT ARDUINO CONNECTOR FEATURES One single binary ~20MB (no external deps) 01 Works on every Debian-like Linux distros 02 Works on slow connections 05 No need to know the IP in advance 06 Secure only connections 03 MQTT (Stable TCP socket with the remote server) 04

Slide 16

Slide 16 text

16 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT MQTT is: • Well known • Widely used • Feature complete • Simple enough • Bi-directional I like AMQP more ;)

Slide 17

Slide 17 text

17 Remote Control of IoT Linux Devices | LinuxLab 2018 - Firenze, IT SERVER SIDE WHAT YOU NEED MQTT Server 01 SSL Support 02 MQTT over Websocket (optional) 05 MQTT Client 03 Oauth2 server (optional) 04

Slide 18

Slide 18 text

18 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT SHOW ME THE CODE Go Language runs on: arm v5, v6, v7 arm64 v8 x86 x86_64 Public repo: https://github.com/arduino /arduino-connector

Slide 19

Slide 19 text

19 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT {} --> $aws/things/{{id}}/stats/post INFO: { "memory":{ "FreeMem":1317964, "TotalMem":15859984, "AvailableMem":8184204, "Buffers":757412, "Cached":6569888, "FreeSwapMem":0, "TotalSwapMem":0 }, <-- $aws/things/{{id}}/stats EXAMPLE API {} --> $aws/things/{{id}}/apt/list/post INFO: {"packages":[ {"Name":"firefox","Status":"upgradable"," Architecture":"amd64","Version":"57.0.3+b uild1-0ubuntu0.17.10.1"}, ...], "page":0,"pages":1} <-- $aws/things/{{id}}/apt/list

Slide 20

Slide 20 text

20 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT Use /proc Luke! And remember, everything is a file in Linux We released https://github.com/arduino/go-system-stats STATS API

Slide 21

Slide 21 text

21 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT APT integration is dummy, APT lib api are in C++ only and nearly impossible to integrate with Go, so we used the CLI as an API We released https://github.com/arduino/go-apt-client/ A combination of dpkg + apt commands wrapped in an API Supports managing repos APT INTEGRATION

Slide 22

Slide 22 text

22 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT DOCKER INTEGRATION

Slide 23

Slide 23 text

23 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT NetworkManager has stable API (0.98 is really stable) We released https://github.com/arduino/gonetworkmanager You can add ETH or WiFi networks NETWORK MANAGER INTEGRATION

Slide 24

Slide 24 text

24 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT DOCKER INTEGRATION

Slide 25

Slide 25 text

25 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT We install docker if not previously installed and if target supports it. Docker Go APIs are really easy to manage (imagine why) Works with private registry Runs on huge servers (we tried with Intel Data Center with 64 core CPU) And Small devices (like Beaglebone Black and Raspberry Pi) DOCKER INTEGRATION

Slide 26

Slide 26 text

26 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT DOCKER INTEGRATION

Slide 27

Slide 27 text

27 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT We can run Arduino compiled code directly as a Linux binary Integrations with all Hardware sensors and GPIO is provided by the MRAA library https://github.com/intel-iot-devkit/mraa ARDUINO INTEGRATION

Slide 28

Slide 28 text

28 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT Support for all Debian Based devices. Porting to other OS is simple.

Slide 29

Slide 29 text

29 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT Communicate with the hardware directly from Arduino to Linux API and vice-versa

Slide 30

Slide 30 text

30 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT Run Shell commands in Arduino and manage hardware directly https://create.arduino.cc/projecthub/Arduino_Genuino/arduino-linux-on- up2-board-with-intel-mraa-a30f87

Slide 31

Slide 31 text

31 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT ARDUINO INTEGRATION

Slide 32

Slide 32 text

32 Remote Control of IoT Linux Devices | LinuxLab2018 - Firenze, IT Let’s give it a try! https://create.arduino.cc

Slide 33

Slide 33 text

THANK YOU! ARDUINO.CC Luca Cipriani - CIO [email protected] - @mastrolinux