Software apps and online services

Story

Low power wireless standards combined with low cost, ultra-miniature LEDs, sensors and communications devices has made smart lighting a catalyst for the Internet of Things and home automation.

In this tutorial we'll see how to control a NeoPixel LED strip via mobile using the Zerytnh App, that shows a color picker and a menu for the selection of various pre-configured animations.

Step 1: Required Material

;

;

1 / 5

The project requires few elements:

Zerynth Studio: a multi-platform and browser-based Python development environment with cloud sync and board management features. No matter which OS you use, Zerynth runs! Just download Zerynth and install it (http://www.zerynth.com/zerynth-studio/).

Zerynth App: the Zerynth mobile interface for smart objects and IoT systems. Any mobile will become the objects display and remote controller. Download: http://www.zerynth.com/zerynth-app/

Arduino DUE or ST Nucleo F401RE or ParticlePhoton. or UDOO or Flip&Clip by Mikroelektronika. No matter which board you use, Zerynth is multi-board compatible! You can find all the supported boards details here: http://www.zerynth.com/zerynth-studio/

If you not use Particle Photon (which has a wifi module onboard), you need an element that connects the board to the web, such as the wi-fi shield of Adafruit. However you can use any other adapter that mounts the wifi chip CC3000 Texas Instruments (http://www.ti.com/product/cc3000).

After turning on the lamp, this will automatically connect to the preset network.

Then just open the Zerynth App, which will go in search of Zerynth objects connected to the network, select the object of interest, in this case the "Zerytnh Lamp", and you can interact with it! In this case the Zerynth App shows a color picker and a menu for the selection of various pre-configured animations.

The code is very simple and has a lot of comments. For any questions or suggestions please feel free to post on the Zerynth community forums: http://community.zerynth.com/

Step 4: Make IoT brighter!

Did you like it? Let’s get hardcore!

The Zerynth Shield presents a set of sensors and actuators, including sensors for touch detection, infrared LED, microphone, light sensor and temperature sensor. You can start from this very simple example code to develop the behavior you prefer. Use the Zerynth Shield to extend the functionalities of the Lamp!

Schematics

Zerynth Lamp: Electronics

Code

main.py

Python

################################################################################# Zerynth Lamp## Created by Zerynth Team 2015 CC# Authors: G. Baldi, D. Mazzei################################################################################# import needed modulesimportstreamsfrombcm43362importbcm43362aswifi_driverfromwirelessimportwifiimportanimationfromtoishieldimporttoishield# and import the zerynthapp modulefromzerynthappimportzerynthappstreams.serial()# connect to a wifi networktry:wifi_driver.auto_init()print("Establishing Link...")wifi.link("SSID",wifi.WIFI_WPA2,"password")print("Ok!")exceptExceptionase:print(e)# save the template.html in the board flash with new_resourcenew_resource("template.html")#### ZerynthApp Setup# :: Javascript to Python ::# the following functions will be called when buttons are presseddefchange_color(r,g,b):animation.setup_color(r,g,b)defchange_animation(n):animation.setup_anim(n)defchange_speed(n):animation.setup_anim_speed(n)# configure the Zerynth app with a name, a descripton and the template urlvp=zerynthapp.ZerynthApp("Zerynth Lamp","Try me!","resource://template.html")# everytime Javascript generates events the corresponding functions are calledvp.on("change_color",change_color)vp.on("change_animation",change_animation)vp.on("change_speed",change_speed)# run the ZerynthApp!vp.run()# since vp.run starts a new thread, you can do whatever else you want down here!# let's control ledsanimation.start(D6,24)