Here's some quick notes on what I discovered today on
The Zerynth Framework: programming IoT with Python
Good starting point well written on open-electronics.org
Here we learn of a new firmware that can be loaded on those microcontroller:
Here's some links for those microcontrollers, mostly based on ARM 32 bit.
- STM32 Nucleo family
- Some kits and pricing at AliExpress from 18$
- Arduino DUE
- Kits on AliExpress from 13$
- Particle.IO microcontrollers
- Store from 19$
- UDOO single board computer
- 68$ at Digi-Key
Here's an example code for blinking 3 leds independently showing the power of Zerynth multi-treading
# Initialize the digital pins where the LEDs are connected as output
pinMode(D2,OUTPUT)
pinMode(D3,OUTPUT)
pinMode(D4,OUTPUT)
# Define the ‘blink’ function to be used by the threads
# delayON and delayOFF are optional parameters, used as default if not specified when you call the function
def blink(pin,timeON=100,timeOFF=100):
while
True:
digitalWrite(pin,HIGH) # turn the LED ON by making the voltage HIGH
sleep(timeON) # wait
for
timeON
digitalWrite(pin,LOW) # turn the LED OFF by making the voltage LOW
sleep(timeOFF) # wait
for
timeOFF
# Create three threads that execute instances of the ‘blink’ function.
thread
(blink,D2) # D2 is ON
for
100 ms and OFF
for
100 ms, the
default
values of delayON an delayOFF
thread
(blink,D3,200) # D3 is ON
for
200 ms and OFF
for
100 ms, the
default
value of delayOFF
thread
(blink,D4,500,200) # D4 is ON
for
500 ms and OFF
for
200 ms
To get you started with testing and development, they created the Zerynth shield
Which consist of many sensors and actuators
This can be found here for around 56$
Here's an example of using this shield:
############################################################################################################
# TOI Shield basics
#
# Created by VIPER Team 2015 CC
# Authors: L. Rizzello, G. Baldi, D. Mazzei
############################################################################################################
import streams
import adc
from drivers.toishield import toishield
streams.serial()
# toishield defines pin names in a board indipendent manner
# let’s use them to read raw sensors values
while
True:
print(“ Microphone:”,adc.read(toishield.microphone_pin))
print(“ Light:”,adc.read(toishield.light_pin))
print(“Temperature:”,adc.read(toishield.temperature_pin))
print(“ Touch:”,digitalRead(toishield.touch_pin))
# aux pins are also accessible!
print(“ AUX1:”,adc.read(toishield.aux1.ADC))
print(“-”*40)
sleep(500)
# this scripts runs on every supported board, without a single change...cool isn’t it? <img src="http://www.open-electronics.org/wp-includes/images/smilies/simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;">
Looks interesting, right!... now if you want to learn Python... there's a lot of resources:
- Youtube videos, like this 56 part Python 3.4 tutorial !
- Coursera online courses
- There's also online course like this neat Code Academy one!