Zerynth IoT PlatformThe Zerynth IoT Platform is a full set of hardware-software tools designed by IoT experts to enable an easy transition from the prototyping phase to mass production in a flexible, scalable, and efficient way.

Zerynth Platform consists of:

Hardware

Zerynth hardware is powerful, power-efficient, and secure, with development boards and expansion boards that add unique functionalities to your application, and a powerful IoT module that can be integrated easily into your end-product.

Software

Zerynth OS is an operating system designed to simplify the development process. It features a Python/C Development environment and seamless integration with other hardware vendors.

The Zerynth Cloud makes it possible to manage IoT devices, store data, visualize data, and gain insights from a single interface.

The following article was released in July 2017. To provide better software-hardware integration, support more features, and simplify the development of IoT products, Zerynth released Zerynth SDK v3 that supports revamped SDK, new development boards, and a complete cloud service.

Zerynth continuously supports and adds new features and functionalities, at the moment, Zerynth V3.0.6 does not support the Servo module. All of the following information is based on Zerynth SDK V2.x.x which is discontinued and is maintained only for bug fixes.

We recommend migrating to Zerynth SDK V3. For more information please refer to our documentation.

In a recent article, we’ve seen how to control an Adafruit NeoPixel ring via mobile using Python and JQWidgets.

Let’s do something similar but using another very popular “actuator”: a Servo Motor, which is a rotary actuator used for precise control of angular position.

We’ll use Zerynth Studio to program the microcontroller-based board in Python and Zerynth App to run the JQWidget-based graphical user interface.

Required Material

Last but not least, you need:

  • Zerynth Studio, our powerful IDE for embedded programming in Python that enables the IoT. You can download it here.
  • Zerynth App. You can download it here.

Assembling

Just put the WiFi 4 Click on the slot “A” of the Flip&Click and connect the Servo as follows:

  • Brown wire of the Servo to the GND pin of the Flip&Click
  • Orange wire of the Servo to the 3.3V pin of the Flip&Click
  • Yellow wire of the Servo to a PWM  pin of the Flip&Click (for example D2)

Programming

Once you have installed Zerynth Studio and created a Zerynth user, you have to register and virtualize the board. Take a look at the Zerynth official documentation for the Particle Photon for a quick getting started.

Now you can start to program your board in Python!

Create a new project and edit the main.py file as follows:

Copy to Clipboard

Of course, you have to edit the SSID name and the PASSWORD of the wifi network you want to connect the board.

As you can see comparing the script of the project mentioned above, the logic is the same and the code is very similar. Just a few differences:

  • In this case, we’ve used a different wifi driver so you have to import the SPWF01SA module instead of the BCM43362 module for the WiFi connection.
  • Of course, you have to import and setup the Servo library instead of the Neopixel library.
  • Then, you have to define a function that sets the degree of the servo according to the data sent by the Zerynth App. So you have to define a function “set_degree” instead of the function “set_color” of the previous project.

The rest of the code remains pretty much the same. Easy, huh? Say thanks to our Zerynth Virtual Machine and its hardware abstraction layer features.

Just another step and you’re done!

In this project too, you have to create a “connected device” and link the “zerynthapp” instance to it. Then you have to create and link a template to the connected device. Take a look at the “Create and set up a connected device” and “Create, upload and set the Template” steps of this tutorial for more details.

The index.html file should look like this:

Copy to Clipboard

Set Degree

In this case, we’ve used the jqxKnob” element of the JQWidgets collection. The main part of this code is

Copy to Clipboard

The Z.call function is the channel from Javascript to Python. Every time you move the knob, the Z.call function sends the value to the device and it is used as an argument of the corresponding Python function.

At this point, you can uplink the project to your device.

Finally, as you can read in this very brief tutorial, you just have to open the Zerynth App, log-in and select the specific device to see your GUI.

Enabling Firmware Over-the-Air (FOTA) updates with Zerynth Studio PRO

Once you’ve built your smart project, you wouldn’t want to disassemble everything to upgrade the firmware.

To meet this specification, Zerynth has included the “Firmware Over-the-Air” feature within the Zerynth Studio PRO version, which also includes industrial-grade features like:

  • Selectable RTOS
  • Power Saving
  • Hardware-driven Secured Firmware burned on the device at industrial volumes
  • …and much more

Share This Story, Choose Your Platform!

About the Author: Luigi F. Cerfeda

Luigi is a biomedical engineer, and is currently Sales Director at Zerynth. Being one of the first members on the team, he has held various roles in the company as he has a deep knowledge of the IoT market and Industry 4.0.

Follow Zerynth on

Latest Posts