1. 程式人生 > >Zerynth r2.1.2 Patch p02 is available!

Zerynth r2.1.2 Patch p02 is available!

We are happy to announce a new update – the r2.1.2 Patch p02 is available!

One of the most exciting features of the update is a tweak on the library AWS IoT, which allows you to connect your sensor device to the AWS in only 15 lines of code in Python.

The update also introduces 12 new libraries, support for Gennann

, a powerful Artificial Neural Networks library, and support for AWS Hexagon v1 development board among other things.

To see the full list of updates and improvements our team has made, read this community post.

From Sensor to Cloud in 15 lines of Python

With this newest example, it is possible to send data to the cloud in just 15 lines of simple Python

. The example shows how to connect your device to AWS IoT and start sending data gathered from a plugged sensor.

Take a look at the code:

Python
123456789101112131415 fromwireless importwififromespressif.esp32net importesp32wifi aswifi_driverfrombosch.bme280 importbme280fromaws.iot importiot,default_credentialswifi_driver.auto_init()wifi.link("SSID",wifi.WIFI_WPA2,"PSW")endpoint,mqttid,clicert,pkey=default_credentials.load()thing=iot.Thing(endpoint,mqttid,clicert,pkey)thing.mqtt.connect()thing.mqtt.loop()sensor=bme280.BME280(I2C0)whileTrue:thing.mqtt.publish("sensors",{'temp':sensor.get_temp()})sleep(1000)

We will go further into detail of this example in one of our future posts, so stay tuned.

Support for AWS Hexagon v1 development board

The AWS Hexagon v1 development board by Tekt Industries has also been added to the list of Zerynth supported boards with this update. This development board mounts on-board the official ESP32 WROOM32 module by Espressif Systems.

AWS Hexagon v1 contains a dual-core ESP32 chip, 4 MB of SPI Flash, tuned antenna, and The ESP32 microcontroller has both WiFi and Bluetooth Classic/LE support. You can learn more about it in the official Zerynth Docs.

You can see the full list of supported boards here.

Gennann, a powerful Artificial Neural Networks library

Genann is a minimal, well-tested library for training and using feedforward artificial neural networks (ANN) in C. With this update we have added support for it and now you can use it with simple Python.

Here you can see the code example our team has made, called “Hello XOR”:

Python
12345678910111213141516171819202122232425262728293031 importstreamsfromgenann importgenannstreams.serial()try:# create an ANN objectann=genann.ANN()# set the layers: 2 inputs, 1 output, 1 hidden layer of 2 neuronsann.create(2,1,1,2)# set the weights of a pretrained XOR model (https://github.com/codeplea/genann/blob/master/example/xor.ann)ann.set_weights([-1.777,-5.734,-6.029,-4.460,-3.261,-3.172,2.444,-6.581,5.826])# define the inputsinput_set=[[0.0,0.0],# 0 xor 0 = 1[0.0,1.0],# 0 xor 1 = 0 [1.0,0.0],# 1 xor 0 = 0 [1.0,1.0]# 1 xor 1 = 1]# run the network for each input setforiininput_set:print("Running XOR on",i)out=ann.run(i)print("Result",out)# Enjoy AI on a microcontroller! :)exceptExceptionase:print(e)

Download Zerynth Studio

To access all these amazing features (and more) download Zerynth Studio. Start your own adventure with Python programming. Zerynth Studio is free and available for Windows, Linux, and Mac OS.