The Zerynth Framework - Programming IoT With Python - Open Electronics
The Zerynth Framework - Programming IoT With Python - Open Electronics
Home > Open Source Projects > The Zerynth Framework: programming IoT with Python
Search site
LOGIN
Username
Password
ByBorisLandonionMarch3,2016
Remember Me
LogIn
Register| Forgot Password?
POPULAR
LATEST
COMMENTS
ZERYNTH, formerly known as VIPER, is a software suite used for the programming of
interactive items, that are ready for the cloud and the Internet of Things. ZERYNTH
enables the development in Python, on the most widespread prototyping platforms,
and by using paradigms and features that are typical of a high level programming.
Posted4yearsago
172Comments
Nowadays,everyoneisconnectedtotheInternet.Itsnotjustpersons,everythingisconnectedor
maybeconnected:thatstheIoTrevolution.Televisions,lampsandsmartthermostatsarestarting
toappearperemptorilyinourhouses,anditisalreadypossibletodaytohavealarmclocksthatare
synchronizedtothecitytrafficservice,andwashingmachinesthatdecidethebestwashingfunction
inourplace,dependingontheatmosphericconditions.
Ifthereareonlyafewmillionitemsofthiskind,today,inafewyearstheywillbebillions.Allthe
majormanufacturersofconsumergoodsarethinkingathowtoacquireusefulinformationandat
howtoanalyzethegreatamountsofdatathattheseitemswillexchangeinordertooffernew
services.Thegreatestpartofthesedeviceshaveamicrocontrollerinside,whichenablesits
functioning,andalsoitsconnectiontotheInternet.However,inordertohavethisInternetof
Thingstobeabletoachieveitspotential,somepracticalprojectsareneeded,sotomakeeventhe
simplestitemsofeverydaylifesmart.
Forexample,isitpossibletoconnectthetoastertotheInternet?Andwhataboutthedogbowl?And
thebabycradle?
Fromatechnicalpointofview,allofthiscansurelybedone.
CATEGORIES
Surely,theprototypingplatforms(suchasArduino,STNucleo,CoreandParticlesPhoton)arenot
lacking.Moreover,inordertohaveeachitemofeverydaylifebecomingsmart,itisneededto
supplyitwithbothsensorsandactuators,thatarecapableofmakingitinteractive.
Categories SelectCategory
ThankstotheZERYNTHShield,eachitemofeverydayusagewillbeabletoexchangeinformation
withtheenvironmentand,obviously,withthepeople.WewillseetheZERYNTHShieldindetail,in
thefollowingparagraphs.
BLOG
ABOUT
3DRAG 3DPRINTER
PROJECTS
CONTACTS
SUBMIT!
Fromtheoppositeside,thecurrentsituationoftenturnsouttobeanotveryflexibleone,evenfor
themostexpertprogrammers,sinceitsufficesthattheneedtochangetheboardfortheirproject
arises,thattheyhavetorestartwritingcodefromthebeginning,andintheprogramminglanguage
requiredbythenewboard.
STORE
Todosothateachusermayprogramhisinteractiveitems,theapproachtotheirprogramming
needstobechanged.
Inthehopetosimplifythewaywithwhichthesethingsareprogrammedandconnectedtothe
Internet,ZERYNTHgathersaseriesofsoftwarecomponentstobetterautomatizethedevelopment
processofinteractiveitems.
ZERYNTH,availableforthedownloadasopensource:isamultiplatform(Linux,WindowsandMac)
worksuitethatenablestheprogrammingofthegreatestpartofthe32bitboardsactuallyavailable
onthemarket:fromtheprofessionalboardsusedintheindustrialfieldtothemostwellknown
prototypingboardsforhobbyists,suchasArduinoDUE,UDOO,ParticleandSTNucleo.
Moreover,ZERYNTHisprogrammedinPython,thatisoneoftheeasiestandmostintuitive
programminglanguagesamongtheexistingones.Pythonisinfactusedinbothschoolsand
universities,andintheprofessionalworld.
Thankstoitsslenderandpowerfulsyntaxandtothemultiplatformsupport,itisusedformanykinds
ofapplications:fromthenetworking,totheweb,tothegraphics.
Byusingourwebsiteyouareconsentingtoouruseofcookiesinaccordancewithour
ZERYNTHspeculiarityliesinthefactthatitmanagestocombinetheeaseofusewithprofessional
PolicyCookie X
performances.ThatspreciselywhatoccurredwithPhotoshop,themostwellknownphotoediting
software,nowindiscriminatelyusedbystudents,amateurandprofessionalphotographersalike.
ZERYNTHguaranteesarapiddevelopmentandaneffectiveintegrationwithsensors,actuatorsand
cloudservices,thusreducingtimesandenergiesusedforthedevelopment.
Thecodeusedintheprototypingphase,infact,maybeusedagainforboththeelectronicsselected
fortheproductioninseries,andforthefutureprojectupdates,orevenonanotherboardamong
thosethataresupported.
ZERYNTHsideaisbornoutoftheneedtooptimizesuchprocesses,bymeansofawebinterface
usedtomanageandprogramtheboards,ofavirtualmachineoperatinginrealtimeandofan
extendedlibraryofreadytousefunctions.
Moreover,thesuiteincludesamobileAppthatenablesthecontroloftheZERYNTHitemsby
meansofsmartphones,thuswithouthavingtodevelopspecificAppsforeachproject.Allofthisis
alreadynativelyconnectedtothecloud.Suchaconfigurationallowstoreducetimesandthe
energiesusedforthedevelopment.
Indetail,ZERYNTHiscomposedof:
ZERYNTHSTUDIO:amultiplatformandbrowserbaseddevelopmentenvironment,withcloud
synchronizationandstorageoftheprojects
ZERYNTHVM:aVirtualRealTimeMachinefor32bitmicrocontrollers,writteninPython3,with
multithreadingsupport.
Itiscompatiblewithalltheboardsuponthe32bitARMchip,suchasArduinoDue,UDOO,Particle,
STNucleo.
theZERYNTHLibrary:asetofmodulesincludingtheCC3000ofSparkCoresWiFiandAdafruits
WiFishield,theAdafruit/Sparkfunthermalprinter,theNeoPixelLEDring,theRTTLsmartmelody
player,asignalslibraryoftheStreamskind,aswellastheTCPandUDPprotocols.
theZERYNTHAPP:anapp,availableforbothiOSandAndroid,thatactsasaninterfacetodrive
theboardsthathavebeenprogrammedbymeansofZERYNTH,withouthavingtouseswitchesor
potentiometers.Thecommandinterfacecanbecustomizedforeachsingleproject,sincetechnically
theappisaHTMLclientthatdisplaysthetemplatesdefinedbythePythonscriptsinsidethe
ZERYNTHObjectsmemory.
Inrespecttoothersolutions,ZERYNTHisnativelycrossplatformandcompatiblewithallthe32bit
boardsthatarebasedonARM32,andhasagreatnumberofsensorsandkitsforarapid
prototyping.
Moreover,itintegratesarealtimeoperatingsystem,andenablesthedataanalyticsconcerningthe
boardandthecomponents.
DifferentlyfromthosewhocarryouttheproductprototypingbymeansofArduinoorRaspberryPi
developmentsuites,ZERYNTHmakesiteasiertousetheindustrialcomponents,inordertocreate
commercialproductsthatarereadyforthemarket.Withafewlinesofcode,theusersmaydevelop
awideselectionofIoTapplications,rangingfromhomeautomationtofitness,fromroboticsto
seamanship,fromtheindustrialapplicationstotheremotemaintenancecontrols,anduptosmart
agriculture.
Averysimpleexample,inwhichitispossibletoglimpseZERYNTHpotentialities,isgivenbythe
MultipleLEDBlink(Listing1).
Listing1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Initialize the digital pins where the LEDs are connected as outp?
ut
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
thread(blink,D3,200) # D3 is ON for 200 ms and OFF for 100 ms, the default
thread(blink,D4,500,200) # D4 is ON for 500 ms and OFF for 200 ms
Amongtheexperts,tomakeaLEDflashcorrespondstotheHelloworldoftheembedded
devicesButwithZERYNTHitispossibletomakeitinamuchmorecomplexandentertaining
way,andwithevenlesstoil.WeareinfactabletomakemanyLEDsflashatdifferentfrequencies,
byusingdifferentseparatedthreads,inafewlinesofcode.
Yes,youreaditright:wemayusethethreadsonboardsoftheArduinokind!Wewillnolonger
havetowriteallofourcodeinasinglelogicloop,asitistypicaloftheimperativeprogramming.
WithZERYNTH,itispossibletoproceedwitharealmultithreadimplementation!Thisexample
showshowtouseZERYNTHsthreadinordertoguidethreeLEDswithasymmetricflashing
frequencies,thatdifferfromoneanother.
Oncethescripthasbeenexecuted,threethreadsarecreated(inadditiontothemainthread,thatis
alwaysavailable),eachoneofthemexecutesaspecificinstanceoftheblinkfunction,with
differentparameters.
EachthreadinZERYNTHisasortofseparatedandparallelprocessthatoperatesautonomously
onyourboard.Athreadrequirestoexecuteafunctionasaninputforthedefinition.Thesame
functionmaybeinstancedbythevariousthreads,bygivingthepossibilitytowritesomeverybrief
andreadablecode.Withthethreadsitispossibletodesignyouralgorithmsarchitecture,bytaking
advantageoftheparallelismthatistypicalofhighlevelsystems.
Moreover,thankstothepassingparametersinPython,thedefaultvaluesmaybedefinedbythe
inputsforeachfunction.Inthiswayitispossibletostartthethreads,withouthavingtospecifyall
theinputsrequiredbythefunction.Intheabsenceoftheexplicitvalue,thedefaultvalueswillserve
tofillthespaces.Inthiscase,alltheblinkfunctionsparameterswillbepassedasargumentsto
thefunctions.
ZERYNTH Shield
TheZERYNTHShieldisashieldthatiscompatiblewithArduinoandParticlespinoutsandnatively
supportedbyZERYNTHsdevelopmentenvironment.
Itshowsasetofcommonlyusedsensorsandactuators,amongthemtherearetouchdetection
sensors,infraredLEDs,amicrophone,aluminositysensorandatemperaturesensor.
Moreover,therearetheAuxports,thatenabletheusageofothersensors,suchasthoseof
Grove,ThinkerKit,Phidgets,andAdafruitsNeopixelLEDstrips.
Thefactofhavingaseriesofsensorsaboard,andallthemostusedcommunicationportsreadyto
beconnected,allowsmakers,artisansanddesignerstoeasilydeveloptheirsmartobjects,thus
withouthavingtodealwiththeelectriccircuit,andwiththeweldingortheloosecablesinthe
breadboard.ItisenoughtoconnectanArduinoDueoraPhotonoraSTNucleototheshield,and
tostarttoworkwithoneoftheZERYNTHexamplesfoundinitslibrary.Theroutingguaranteesthe
compatibilityoftheZERYNTHShieldwiththegreatestpartofArduinoshields,suchastheEthernet,
WiFiandBLEshields.ThismeansthattheZERYNTHshieldcanbeeasilydockedonthetopof
yourshieldsheap,withouthavinganypincompatibilityproblem.Theboardhastemperature,
sound,lightsensorsavailable,andalsoacapacitivetouchsensorandanIRreceiver.Aboarditalso
hasapiezoelectricbuzzerandanIRLEDemitter(actuator).Thecommunicationportsaboardare
SPIandICBustheboardiscompletedbyanAnalogandaDigitalAuxline,inadditiontoaPWM
outputandaportforAdafruitsNeopixelLEDstrips.
IRReceiver
TheIRreceiverisbasedontheTSOP34838component,thatmaybeusedinordertoreadsignals
fromthecommon38kHzIRdevices,suchasairconditioningandhometheatreones,and
televisions.TheIRreceiverrequiresadigitalinputpinandisconnectedtotheD2pinonArduino
andtotheA4pinonParticleslayout.
Temperature
ThetemperaturesensorbelongstotheMCP9700/9701seriesandconvertsthetemperatureinto
analogvoltage.Akeyadvantageofthisthermistorsseriesistheresistancetoparasitic
capacitance,andtheabilitytoactivategreatcapacitiveloads.Theintegratedcircuitsoutputpinis
connectedtoArduinosA4pinandtotheA1pinonParticleformats.
LightSensor
TheZERYNTHShieldintegratesaphotoresistor,alsoknownaslightdependantresistor(LDR).
LDRsarevariablelowcostresistancesinwhichtheresistancechanges,dependingonthequantity
oflighthittingitssurface.Indarkenvironmentstheresistanceishighinlightedenvironmentsthe
resistanceislow.
Theymaybeusedinordertoanswertoeventssuchasthetransitionfromdaytonight(andvice
versa),forhomeautomationapplicationsandgardening,andareoftenusedinordertocontrolthe
streetlighting.
Thecircuitisasimplevoltagedivider,thatallowsaquiteaccuratereadingofthephotoresistors
resistance.TheresistancethatisanoppositetotheLDRhasbeensetto20k,sincethechosen
LDRhasaresistancevaryingfrom12kto36kohm.ThesensorisconnectedtoArduinosA5pin
andtotheA0pinonParticleformats.
AcousticTransducer
Asmallamplifiedelectretmicrophonewithagainofabout200timesisusedinordertoenablethe
detectionofvoices,environmentalsoundsandsimilarnoises.Theimplementedcircuitisbasedon
asimpleamplificationstage,followedbyabuffer.Themicrophonesamplifieroutputisconnectedto
ArduinosA3pinandtoParticlesA2pin.
CapacitiveTouchsensor
TheZERYNTHShieldintegratesacapacitivetouchsensor,basedontheAT42QT1010chip,an
integratedcomponentthatisusedinordertoconvertanycapacitivesurfaceinabutton.Thechip
managesthemonitoringofaconductivezoneandisactivatedwhenthezoneistouched.Aslongas
atouchisdetected(forexample,afinger)theAT42QT1010keepstheoutputsignalatahighlevel.
Whenthetouchisinterrupted,thesignalisbroughtothelowlevel.
TheAT42QT1010sensorsoutputisconnectedtotheD7pinonbothArduinoandParticle.The
touchspincanbeconnectedtoametalsurface,tobesuppliedwithsensorsbymeansofthe
expansionconnector(P1).
PiezoelectricBuzzer
Thistransducer,builtupontheZERYNTHshield,isneededinordertogenerateacousticsignals,
tonesandalarms.Thebuzzerispoweredbymeansofthe5Vline,inordertoavoidinterferences
withthesensors.ThebuzzerisguidedviathepinsconnectedtoArduinosD8pinandtoParticles
A6pin.
IRLEDemitter
AnIRLED,guidedbyaBJT,isconnectedtotheD6pinonArduino,andtotheA5pinonParticle.A
PWMwaveisusedinordertocreateinfraredpulses,thatmaybereceivedanddecodedby
commonIRreceivers.
AdafruitNeopixelLED
IntheZERYNTHShield,adedicatedportfortheconnectionofAdafruitsNeopixelLEDstripshas
beenincluded.ThepowersupplypinisconnectedtoParticlesVinandtoArduinos5Vpin.The
pinstobeusedaretheGND,theVin,andtheLEDcontrolpin.ThecommandpinfortheLEDs
digitalcontrolisconnectedtotheD9pinonArduino,andtotheD6pinonParticle.Ifthe
configurationincludesmorethan24LEDs,inordertoavoidpossibledamagestoyourboard,itis
neededtouseanexternal5Vpowersupply,inordertopowertheLEDs.
ExpansionConnector
Itisa8X2maleconnectoronwhichalltheAuxpinsareavailableintable,inaconfigurationthatisa
compatibleonewithSeedstudioGrovemodulesanaloganddigitaloutputs.Theexpansion
connectoralsoallowsaneasyusageofthePhidgetsandThinkerkitmodules,andalsomakesthe
3.3V,5VandGNDpowersupplylinesavailable.Theexpansionconnectoralsoallowstoexposethe
SPIpins,butunfortunatelythisfunction,availablewithArduinoandNucleo,isnotavailableon
ParticlesPhoton,duetohardwarelimitations.
TheZERYNTHshieldalsoincludesaportonwhichtousetheIC.Theporthasapinorderthatis
compatiblewiththeICGrovesensorsandactuators(3,3,SCL,SDA,GND),andthatenablesthe
plugandplayusageofthesemodules.OthermanufacturersICdevicesmaybeused,butplease
payattentiontoexecuteappropriateconnections.
Thereisalsoaseriesofsmartfunctions,suchasthesmartmotiondetectionthatallowstheusage
oftheluminositysensorasapresencesensor,orthedoubleclick,thatallowsthedetectionoftwo
closetouchesonabutton,bymeansofthecapacitivesensor.Letsseeasimpleusageexampleof
ZERYNTHShieldslibraryonZERYNTHSTUDIO,asshowninListing2.
Listing2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
##################################################################?
##########################################
# 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
# lets 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 isnt it? <img src="
Finally,letsanalyzesomepossibleusagescenarios:theunionbetweenZERYNTHsoftwaretools
andtheZERYNTHShieldmayhelppeopletomonitortheirhome,bymeansofthewireless
communicationandwithouthavingtocreatetracksinthewalls.Thusitwillallowthemtoknow,as
anexample,ifthechildrenhavereturnedfromschool,ortoturnofftheheatingifithasbeen
accidentallylefton,ortocheckfromtheirworkplaceifthegashasbeenturnedoff.Allofthiscanbe
carriedoutbymeansoftheirPCorsmartphone.
Soonwewillproposesomesimple,practicalprojects,thathavebeendevelopedbymeansof
firmwarethathasbeenwritteninZERYNTH.
From Openstore
NucleoDevelopmentBoard,NUCLEOF401RE
ShieldmultiplatformZERYNTH
Arduino
toishield
homefeatured
viper
newsline
zerynth
Nucleo
particle
stm32
stm32 nucleo
zerynth app
RELATED POSTS
0Comments
Recommend
OpenElectronics
Share
Login
SortbyBest
Startthediscussion
Bethefirsttocomment.
WHAT'STHIS?
ALSOONOPENELECTRONICS
RaspberryPi3ComingWithBuiltin
WiFi,Bluetoothand64bit
ArduinocloneNerOdeliverspower
punchviaKickstarter
4comments5daysago
1comment2monthsago
DEmbryo.comOkGreat!I'mwaiting
MerlinTailShametheydidn'ttakethe
formoreinformation:)))Greetings
opportunitytoremovethebarreljack
connector
1Wamp:OpenHardware1WattGuitar
Amplifier.
TheFocalCameraopensourceDiY
modularcamera
1comment2monthsago
3comments6monthsago
FernandoFranaReallylovedthis
Silverdog
project.Thanksforsharing!
http://petapixel.com/2015/08/1...
Subscribe
AddDisqustoyoursiteAddDisqusAdd
Privacy
SPONSORS
About us
License
Explore tags
3D 3dprinting 3d printing
3drag Android
Arduino Arduino
remote control
homefeatured indiegogo
innovation iot italy kickstarter linux
Maker maker faire maker faire rome makers
microsoft
newsline open
hardware open
source
opensource open
source hardware
opensource hardware open
source software OSHW oshwa raspberry
Raspberry pi raspberrypi Raspberry pi 2
Remote control Robot robotics Tip & tricks Tutorials
wearable
Blog
About
3Drag 3DPrinter
Projects
Contacts
Submit!
Store