Set the pin attached to the LED

Zerynth - Confidential | © 2018 www.zerynth.com 50 Blink two LEDs

Zerynth - Confidential | © 2018 www.zerynth.com 51 Example ‘Multi-Blink’

Zerynth - Confidential | © 2018 www.zerynth.com Search and clone the ‘Multi Blink’ Example

Zerynth - Confidential | © 2018 www.zerynth.com 53 Let’s take a look at the code

Zerynth - Confidential | © 2018 www.zerynth.com 54 Check the board pinout

Zerynth - Confidential | © 2018 www.zerynth.com 55 Set the pin attached to the LEDs

Zerynth - Confidential | © 2018 www.zerynth.com 56 Python vs /C++

Zerynth - Confidential | © 2018 www.zerynth.com 57 Reading a Digital Sensor

Zerynth - Confidential | © 2018 www.zerynth.com Reading a digital sensor Weather click https://www.mikroe.com/weather-click

Weather click carries BME280 integrated environmental unit from Bosch. It’s a sensor that detects humidity, pressure, and temperature, specifically designed for low current consumption and long-term stability. The click is designed to work on a 3.3V power supply. It communicates with the target over SPI or I2C interface.

Zerynth - Confidential | © 2018 www.zerynth.com 59 Search for BME280

Zerynth - Confidential | © 2018 www.zerynth.com 60 Open the doc of BME280

Zerynth - Confidential | © 2018 www.zerynth.com Open the doc of BME280

Zerynth - Confidential | © 2018 www.zerynth.com Copy/Paste and edit the code

Zerynth - Confidential | © 2018 www.zerynth.com Getting Started with Xinabox and Zerynth

Zerynth - Confidential | © 2018 www.zerynth.com Getting Started https://www.zerynth.com/blog/getting-started-with-xinabox-and-zerynth-fast-tracked-iot-development/

Zerynth - Confidential | © 2018 www.zerynth.com 65 Blink https://www.zerynth.com/blog/getting-started-with-zerynth-on-xinabox-blinking-an-led-using-python/

Zerynth - Confidential | © 2018 www.zerynth.com 66 Weather https://docs.zerynth.com/latest/official/lib.xinabox.sw01/docs/index.html

Zerynth - Confidential | © 2018 www.zerynth.com 67 Getting Started with LoRaWAN and Zerynth

Zerynth - Confidential | © 2018 www.zerynth.com LoRaWAN architecture

More info: https://www.zerynth.com/blog/getting-started-with-lorawan-and-python-using-zerynth-and-the-things- network/

Zerynth - Confidential | © 2018 www.zerynth.com 69 LoRa node

Zerynth - Confidential | © 2018 www.zerynth.com 70 Search for ‘RN2483’ or ‘get eui’

Zerynth - Confidential | © 2018 www.zerynth.com Clone the example and edit the script

Zerynth - Confidential | © 2018 www.zerynth.com Open the serial monitor to get the EUI

Zerynth - Confidential | © 2018 www.zerynth.com Search for ‘ping’

Zerynth - Confidential | © 2018 www.zerynth.com Let’s take a look at the code

Zerynth - Confidential | © 2018 www.zerynth.com Open the serial monitor and the TTN console

Zerynth - Confidential | © 2018 www.zerynth.com Edit the script to send data from the sensor

Zerynth - Confidential | © 2018 www.zerynth.com Getting Started with 4ZeroPlatform and Zerynth

Zerynth - Confidential | © 2018 www.zerynth.com 4ZeroPlatform, the Industrial Toolkit for IoT Solution Providers

http://www.thingsoninternet.it/ http://www.thingsoninternet.it/4zeroplatform

Zerynth - Confidential | © 2018 www.zerynth.com 79 Getting Started https://docs.4zeroplatform.com/guide/getting-started/

Hello 4ZeroBox https://docs.4zeroplatform.com/guide/4zerobox/

Hello 4ZeroManager https://docs.4zeroplatform.com/guide/4zeromanager/

Zerynth - Confidential | © 2018 www.zerynth.com 80 IoT solutions powered by Zerynth

For more info, contact us at www.zerynth.com/contact-us/

Zerynth - Confidential | © 2018 www.zerynth.com 81 Smart Retail Synchronized and remote-controllable rotating platforms for retail display

A set of synchronized and interactive retail window displays, installed in top level jewelry stores in Paris, with the following main features: - working 24/7; - remotely controllable with a dedicated mobile app; - interactive: customers can rotate the displayed object and control the illumination - able to gather data from customer interaction, presence, etc - Retailers can monitor the customers behaviour through a simple real-time dashboard

More info: https://www.zerynth.com/blog/portfolio/smart-iot-retail-displays/

Zerynth - Confidential | © 2018 www.zerynth.com 82 Wi-Ref: Industrial Refrigeration IoT solution for monitoring and control industrial refrigeration systems

Monitor old and modern industrial refrigeration systems for efficiency and regulatory purposes ● Temp, humidity, doors and power consumption data acquisition and recording ● Wi-fi connectivity ● Not-invasive interventions and apparatus replacements.

OUTCOMES ● Efficiency: reduction of Maintenance costs and energy ● Quality: cold chain monitoring meeting HACCP regulation Walk-in Refrigerators Refrigeration Engines

Zerynth - Confidential | © 2018 www.zerynth.com 83 Waste Management System IoT system for monitoring of the biogas from a waste management plant

Biogas production monitoring for efficiency improvement (Tuscany) • Data acquisition, analysis and visualization • CH4, O2, pressure, temperature and humidity • LoRa connection

Benefits: • Efficiency: less time and more precision for wells regulation; • Visibility: awareness of unknown biogas cyclic dynamics More info: www.iotitaly.net/wp-content/uploads/2018/02/iot_genova_mazzei_biogas.pdf

Zerynth - Confidential | © 2018 www.zerynth.com 84 Nautical Sector 4ZeroBox, powered by Zerynth, applied to boats performance monitoring

4ZeroBox used as data acquisition unit of boats participating at the Italian Platu25 Championship in Livorno.

Zerynth allowed to develop an IoT System able to analyse navigation data and elaborate operational information for boats manufacturers and end users.

in collaboration with

Zerynth - Confidential | © 2018 www.zerynth.com 85 Lincoln Project European Project for the Marine Space

The Lincoln project is an EU Horizon 2020 research project focused on creating three types of new marine vessels.

Zerynth allowed to develop a cloud connected Marine Gateway based on 32-bit microcontroller and embedded sensors able to acquire navigation data (position, acceleration, velocity, etc.) and elaborate operational information for boats manufacturers and end users. More info: www.lincolnproject.eu

Zerynth - Confidential | © 2018 www.zerynth.com 86 Automotive Python programmable OBD Boxes

A worldwide automotive company required Zerynth to support OBD-connected IoT black boxes;

The main added values are the easy connectivity (via GSM) to major cloud vendors and the possibility for non-skilled personnel to create their own IoT solutions.

The project will be made live in Q4 2018.

Zerynth - Confidential | © 2018 www.zerynth.com 87 Blockchain & Cryptocurrency Zerynth enables Blockchain applications for embedded devices!

Zerynth enables Blockchain applications for embedded devices!

This demo shows two devices playing an Ethereum Smart Contract based game where each device sends a random number and the Contract determines the winner (the player with the highest number).

Zerynth powered devices are capable of calling Smart Contract’s functions through signed transactions and getting Smart Contract’s states through eth calls so being aware of the progress of the game.

All of this in an easy to read and maintainable Python script.

Zerynth - Confidential | © 2018 www.zerynth.com 88 Domotics & Smart Lighting IoT Smart Lamp

A wi-fi smart lamp built with low power wireless standards combined with low cost, ultra- miniature LEDs, sensors and communications devices.

Remotely controllable with the Zerynth APP

Zerynth - Confidential | © 2018 www.zerynth.com 89 Community Projects See more on Hackster: www.hackster.io/zerynth

Zerynth - Confidential | © 2018 www.zerynth.com 90 Technical Details

Learn more at docs.zerynth.com

Zerynth - Confidential | © 2018 www.zerynth.com 91 Zerynth is “Agnostic”

Zerynth is hardware agnostic Zerynth does not and will not require a specific board. The porting of boards, sensors, shields is a daily activity.

Zerynth is OS agnostic Any RTOS with Mutexes and Threads can be easily ported.

Zerynth is Cloud agnostic Data can be gathered by Zerynth powered devices through the Zerynth ADM and channeled to any Cloud infrastructure.

Zerynth will be language agnostic Javascript, Go, Rust , Swift etc.. will be considered as other high level programming languages to be interfaced with Zerynth.

Zerynth - Confidential | © 2018 www.zerynth.com 92 Unique Technical Differentiations

Zerynth Virtual Machine: • The first virtual machine specifically tailored for embedded and IoT that supports hybrid C/Python programming • A tiny footprint: 60k-80k of flash, 3-5k ram. To keep VM code at minimum the Zerynth uplinker has been developed • RTOS for multithreading: in Zerynth each Python thread is a RTOS thread managed by a priority aware real-time scheduler

Zerynth Uplinker (Patented) : The first hybrid C/Python-bytecode linker with integrated multi-board uploader

Zerynth App: The first generic mobile app for embedded devices that renders HTML 5, CSS and JS templates

Zerynth Advanced Device Manager: A cloud based device manager bridging device data to top Cloud infrastructure, relaying device commands and handling FOTA

Zerynth - Confidential | © 2018 www.zerynth.com 93 Zerynth Virtual Machine - Features

• Zerynth VM achieves cross architecture compatibility by encapsulating any RTOS into an OS abstraction layer (ZOSAL) providing multithreading primitives

• Zerynth VM achieves cross mcu-family compatibility by encapsulating standard onboard peripherals (Serial ports, USB, I2C, SPI,..) into an hardware abstraction layer (ZHAL)

• Zerynth VM manages memory through a mark-sweep-compact tunable garbage collector

• Zerynth VM has realtime multithreading: every Python thread is a RTOS thread. Non-Python threads can be created.

• Zerynth VM supports OTA updates of both VM and/or application

• Zerynth VM has a large set of drivers for connectivity: WiFi, BLE, LORA, NFC,…

• The Zerynth VM is customizable for specific hardware solutions based on already supported

Zerynth - Confidential | © 2018 www.zerynth.com 94 Zerynth Virtual Machine - Technical Details

Footprint: • 50k-80k of FLASH depending on VM peripheral support (USART as bare minimum) • 3k-5k of RAM depending on underlying RTOS

Runtime structures: • Signed integers up to 31 are just 4 bytes. • Functions/objects are 16 bytes at minimum (plus storage) • Extra space for memory management is kept low at 8 bytes • GIL for atomic opcodes • Main Interrupt Thread

Performance overhead: • Pure Python code is 3 to 4 times slower than equivalent C code • C code can be mixed with Python, exploiting the best of both worlds • Smart Idle times for Power Saving

Zerynth - Confidential | © 2018 www.zerynth.com 95 Hybrid C/Python Programming

Zerynth bytecode can live together with C object code:

• Existing C code, even as object code without source, can be compiled and linked together with Python bytecode.

• Performance critical routines can be written in C, all the rest in Python getting the best of both worlds.

• Key C libraries are already included, e.g. lwip and fatfs

• C functions can be called from Python

• C functions can manage Python objects through safe macros

Zerynth - Confidential | © 2018 www.zerynth.com 96 The Zerynth Compiler and Uplinker

Zerynth COMPILER

The Zerynth toolchain integrates a compiler, written in Python, that reads the source code and produces an optimized bytecode for the Zerynth Virtual Machine. • Everything that can be statically computed at compile time is then saved on the flash to minimize RAM usage (i.e. code objects are entirely stored on flash, no RAM is used). • the Zerynth compiler analyses the code in terms of ”static reachability”. Dead code is removed, duplicated constants are merged, classes are lazily evaluated.

Zerynth UPLINKER (Patent pending)

An uploader that is also a linker, hence uplinker.

• The VM symbol table is used to link C object code to the running VM • Bytecode is uploaded to the flash together with packed resources (e.g. html templates, RSA keys,...) • The whole process works also via sockets for remote reprogramming

Zerynth - Confidential | © 2018 www.zerynth.com 97 Zerynth vs Python

Zerynth supports a subset of Python 3.4 since some Python features are not so useful in embedded programming.

Python 3.4 features not ported in Zerynth: • No getattr and setattr with string arguments (but this allows static analysis!) • No more than 65535 names (they are plenty, actually) • No more than 256 arguments to functions and no **kwargs support • sequences and maps are limited to 65535 elements • the huge Python standard library is not implemented, just the built-ins and some other modules • No closures, generators, decorators (yet) • No eval() and no compile()

The features that have been added to Python 3.4: • built-in real time threads • built-in support for native C calls • exceptions are not classes, just names with optional error codes • additional built-ins to drive GPIO, ADC, ICU, exti, PWM, DAC

For a full list of new features please refer to the Zerynth guide at http://docs.zerytnth.com

Zerynth - Confidential | © 2018 www.zerynth.com 98 Zerynth vs MicroPython

Zerynth has a smaller footprint 60k-80k of flash, 3-5k ram versus 80k-280k of flash and 8k of ram for MicroPython (see here). Such footprint is achieved by writing the VM from scratch and choosing to remove the compiler and the repl from the microcontroller; the Zerynth Uplinker allows to flash a minimal VM on the microcontroller once and subsequently add to it only the necessary drivers embedded in bytecode. Zerynth is Python even more tuned to micros than MicroPython is. Let’s say that Zerynth is a Micro MicroPython.

Zerynth features (multiple) RTOS for multithreading In Zerynth each Python thread is a RTOS thread managed by a priority aware realtime scheduler; in MicroPython, in our best knowledge, there is a custom round robin scheduler. In Zerynth the RTOS threads written in C can live along the VM allowing for a mixed C/Python realtime environment.

Zerynth supports C-Python programming Existing C code (or C object code) can be easily mixed with Python scripts without VM recompilation. For example, the Broadcom SDK for the Particle Photon is embedded in bytecode and uplinked to a running VM. Existing C code can be included in MicroPython too, but a VM recompilation is needed.

Zerynth supports a subset of Python 3.4 and adds new embedded-friendly features To make Zerynth suitable for microcontrollers constrained resources, support for generators, context managers and full-fledged closures has been made optional (will be compiled into the VM if needed). Moreover Zerynth has a new type, the shortarray, to handle 16-bit integer arrays. Also, Zerynth exceptions are lean and memory efficient, but still retaining the powerful debugging capabilities of tracebacks.

Zerynth has a cross-platform IDE built on a command line toolchain Zerynth Studio takes away the burden of compiling the VM, of setting up various toolchains and tools (arm gcc, xtensa gcc, etc…) and gives an easy to use interface to code and debug embedded Python. For MicroPython no official IDE does exist. In addition, Zerynth is based on a command line toolchain to ease and automate the integration of the Zerynth workflow for programmers who prefer other development environments.

Zerynth - Confidential | © 2018 www.zerynth.com 99 Thank you!

Luigi F. Cerfeda [email protected]

Zerynth - Confidential | © 2018 www.zerynth.com