From Dusk till Dawn
Iot Sunlight workshop for the Makerfaire 2016, Hannover. The framework of this workshop is the Espressif ESP8266. With this IC we want to create an “Internet of Things”-project.
The goal of this workshop is to build an small lamp which will change its light insensitivity and lightcolor depends on the time as well as the current geo position. With this technics the lamp should simulate the sun. The needed data will be collected via API requests from the internet. The content of this workshop is to build and solder the components, the coding of the necessary modules, the api requests and come basics about color theory. At the end of this workshop every participant will build his own lamp, which he can carry home.
Exhibitions & talks
First of all we showed some basics about the electronic components which we used in this project. Mainly these following:
NodeMCU ( ESP8266)
The ESP8266 is an quite cheap IoT micro controller. You can get them fror around 3 $ at aliexpress or other supplier from china. This micro controller has to be coded in LUA scripting language. But it is possible to install an Arduino boot loader so you are able to write C / C++ code with the arduino IDE. Just install the USB driver and add the library as well as the addition board manager to the Arduino IDE. You can finde an nice tutorial from sparkfun >>here <<. The nodeMCU is an breakout board for the ESP8266 which includes the arduino boot loader so you don’t have to refresh it. The major goal of the ESP8266 is that if got an integrated WIFI model. So you are able to create http-requests for example for web api requests or transimmitng sensor data to other devices or to a server. As well as it the chip is able create an adHoc network. So on the one hand it creates an hotspot so you are able to configure the chip via an self created web interface ( which can be hosted on the chip! ) and on the other hand to create an connection to an existing wifi network to check if the device is able to connect to the internet.
WS2812B addressable LED Strip
The WS2812B is an chip inside an led. This led includes an red, green and blue led with the dimensions of the SMD 5050 reference model. The chips runs with 5v and got only 3 pins in and 3 pins out. One 5v voltage pin, one ground pin ( GND) and an Data in pin. The out pins got the 5v and ground pins as well so all but got an data out pin which can be connected to the next led. You should definitely buy these SMD leds as an LED Strip or pre soldered because it takes to much time to solder them on your own. Even if they are pre soldered to an heatsink. I tried it once and it took weeks to finish the soldering part. The major point of a WS2812B based strip is that every LED is addressable with only one data in. So you just have to connect 3 cables to your micro controller ( or 2 (GND and Data) if the power is supplied from an external power source). The data port has to be hardware PWM able. Faked software PWM signals with microseconds delays doesn’t work quite well. With the WS2812B chip inside the LED very led is able to know its position in the LED line so you can give every led an own RGB color. This technic behind the controls of this chip is ables on bit banning.
After this electric part we showed the designer point of view on the project. So we presented some basics about color recognition.
// Farbwahrnehmung einfügen
The device itself: The device itself should be easy to rebuild and fit onto an A5 letter of lasercutted wooden MDF. Another major point is that it should be easy to usable or disable without permanent connections like hot or wooden glue. So we designed our reverence design with the node MCU on the back of the device. The main MDF plate got thee holes to connect the LED strip. in the inner part of the device. To defuse the Led light we used polysterol which works as the front panel. Polysterol is much stronger than MDF so it gave more stability to the structure of the device. The code: The hole code was written in C++ with some additions from arduino. We separated the code in tree different topics: The api request We used the sunrise-sunrise.org api which is really nice. You can request an JSON via http url parameters. Just enter your coordinates and you received a JSON with many informations. We just needed two informations the sunrise and the sunset. With this informations we are able to calculate the rest on the micro controller itself. We decided not to use an JSON parsing library because we haven’t connected an clock module to the micro controller to know what the current time is. To solve this problem we needed the server time of the JSON request. which is contained in the ppt header. So we parsed this thee informations hard coded. the color output (RGB Fade) //insered the initiation //insered After all everyone got his own little IoT light and the participants started to manipulate our reference code to add some of there functions. In the end we fixed some bugs in our code with the help of the community.