NOTE: The Zerynth Ecosystem has been updated to Zerynth 2.1.0. The update removes the distinction between “Zerynth Studio” and “Zerynth Studio PRO”. You can read more about it here.

Announced in June 2016, the new Bluetooth 5 specification promises significantly increased speed, and broadcast messaging capacity over current Bluetooth 4.2.

However most existing BLE development boards are not upgradable to support these.

RedBear has launched a Kickstarter campaign to enable the new generation of Bluetooth Low Energy products for makers and professional developers. The campaign includes three boards based on the Nordic nRF52832 BLE chipset, including a BLE module suitable for mass production and secure Over-the-Air Updates.

Why programming RedBear boards with Zerynth

As discussed in this post, there are more and more reasons to use Python for microcontrollers and embedded development.

But why use Zerynth?

Zerynth provides a platform for developing embedded devices in Python using paradigms and features typical of personal computer (PC) and mobile programming. It lets you make your object ‘connected’ and ‘smart’ with just a few lines of Python code and almost no wiring.

The advantages of programming RedBear Nano2/Blend2 with Zerynth include:

  • Coding in Python or Hybrid C/Python with a multithreaded real-time OS that requires a footprint of just a 60k-80k of flash and 3-5k RAM;
  • Development of flexible, scalable and customizable IoT solutions with reduced development time and guaranteed high performances and reliability;
  • Native mobile app and cloud connector for mobile control and cloud connection with the architectures that best fit with your needs.

 

All this is possible thanks to the Zerynth modular set of software tools that form the Zerynth Stack.

 

Zerynth Stack for RedBearLab

The main components of Zerynth are:

  • ZERYNTH VIRTUAL MACHINE: A multithreaded real-time OS that provides real hardware independence allowing code reuse on a wide set of 32bit chips. The VM supports most high-level features of Python like modules, classes, multi-threading, callback, timers and exceptions. In addition to these, it allows to use custom hardware-related features like interrupts, PWM and digital I/O. RTOS threads written in C can live along the VM allowing for a mixed C/Python realtime environment.
  • ZERYNTH STUDIO: an open-source browser based IDE that provides a platform for developing your Python or hybrid C/Python code and managing your boards. It includes a compiler, debugger and an editor, alongside tutorials and example projects for an easy learning experience.
  • ZERYNTH ADVANCED DEVICE MANAGER: A device manager compatible with many cloud providers (like Azure, Kinetis, Bluemix, Amazon), exposing a simple API based interface for data gathering, actuation and mobile integration.
  • ZERYNTH APP: a general purpose interface for all network- or Bluetooth-powered Zerynth objects, that turns any mobile into the controller and display for smart objects and IoT systems. You do not need to write any separate code for Android or iOS.

 

In order to guarantee a reliable, maintainable and scalable architecture of the Zerynth stack, the Zerynth Virtual Machine license is based on a closed source policy with distribution of binaries packags only and custom VM compilation as an online service. On the other hand, the Zerynth Studio IDE and most of Zerynth libraries and drivers are opensource. With the free version of Zerynth Studio, you will be able to program for free up to 5 Blend2 and up to 5 Nano2. Discounted/free extension packages for education are available on request.

We provide below some examples to explain 2 features of Zerynth through the LED blinking example: multithreading and code reuse.

Blinking one LED

Following the code related to the blink of one LED using Zerynth.

Blinking More LEDs

Blinking one LED is known as the “Hello World of embedded devices”… but with Zerynth it can be funnier. You can blink many LEDs at different frequencies using many separated threads in just a few lines of code.

It’s the magic of multithreading!

No more creepy single loop logic code, typical of imperative programming. Zerynth allows pure thread driven implementation!

This can save your mind. Take a look here to spot the differences with Multiblink in C/C++.

This example shows how to use Zerynth threads for driving three LEDs with asymmetric and different blinking rates.

Once the script is run, three threads are created (plus the main thread, that is always available), each running a specific instance of the blink function, with different parameters.

Each thread in Zerynth is a sort of separated and parallel process that runs autonomously on your board. A thread requires a function to be executed as input for the definition. The same function can be instanced by various thread giving you the possibility to write very concise and readable code. With threads, you can design your algorithm architecture assuming parallelism that is typical of high level. More info about Zerynth Virtual Machine here.

Moreover, thanks to Python argument passing, default values can be defined for function inputs. In this way you can launch threads without specifying all the inputs required by the function, default values will fill the holes. In this case, all the parameters following ‘blink’ are passed to the functions as arguments.

Write Once, Run Everywhere

You can easily switch the boards (for example from BLEND 2 to Nano 2) maintaining the same configuration.

Thanks to the Zerynth Hardware Abstraction Layer, the code remains the same!

 

[button title=”Support RedBear boards on Kickstarter!” link=”https://www.kickstarter.com/projects/1991736672/bluetooth-5-ready-ble-module-nano-2-and-blend-2″ new_tab=”no” size=”large” animation=”bottom-to-top”]