by

ESP8266 WiFi lights

Keywords: C, Javascript, Node.js, FreeRTOS, ESP8266, Raspberry Pi, WiFi, MQTT

During the late autumn of 2016 I finally got the opportunity to fiddle around with the ESP8266. There are several ways to write code for the chip, but I decided to go for the open-rtos-sdk since it got the perks of being open source and based on FreeRTOS which I’m already familiar with. I bought some cheap RGB light bulbs based on the ESP8266 chip online, together with an USB to TTL cable to be able to flash my custom firmware to it.

lyt8266

The project, which I decided to call Alfred Home Assistant, consists several light bulbs with ESP8266 acting as MQTT clients, and a Raspberry Pi Zero acting as a MQTT broker (using Mosquitto). The RPi also runs a server to host the web application that is displayed on the smartphone. The ESP8266 outputs four PWM signals, one 8-bit signal for each RGB color and one for white. The app displays three different bars:
1. The color spectra in range 0-255 for all the three colors.
2. Saturation, which is the intensity from 0-100 of the color. 0 gives only white, 50 gives 100% white and 100% color, and 100 gives just 100% RGB color but no white.
3. Brightness 0-100.

alfred

The source code for the ESP8266 can be found here. Some parts are not beautiful, especially the fact that the ESP8266 seem to have only two timers (really?) caused problems in order to have four individual PWM signals.

The code for the web app can be found here. It was made in Javascript using the Onsen framework for AngularJS. It can be run on any device in basically any browser and is screen responsive. However, I’m a shitty web developer so most of it is hardcoded and there’s plenty of room for improvement.

Demo on YouTube:

Write a Comment

Comment