In this last episode, let’s try to replace the control module with a new one, which supports an open firmware.
One of the most adpoted firmwares for domotic products is for sure tasmota. This firmware is developed for the ESP8266 chip by Espressif. The chip is indeed widely used in “smart” products (tasmota itself was born as an alternative firmware for iTead’s Sonoff products)
To begin my tests, I decided to use a development board, the Wemos D1.
I connected the board to my computer and programmed it with the latest version of Tasmota, using the handy Tasmotizer software:
I needed 4 pins to generate the 4 PWM signals to control the different colors (red/green/blue and white). The silkscreen of the development board doesn’t show the real names of the pins, I then gave a look to this great post by randomnerdtutorial for the correct pinout and to choose the most suitable pins.
In the Tasmota configuration, you assign pins to PWM1,2,3… functions. To understand which color is linked to which PWM channel, I used the table in the official wiki:
The mapping I therefore adopted was as follows:
- pin D5 (GPIO14) – PWM1 (RED)
- pin D6 (GPIO12) – PWM2 (GREEN)
- pin D7 (GPIO13) – PWM3 (BLUE)
- pin D8 (GPIO15) – PWM4 (WHITE)
I created a new template with the above mapping using Tasmota’s web interface (Configuration – Configure Template):
For the first tests, I preferred to have the independent control of the 4 PWM channels available. To do this I entered the command
SetOption68 1
through the web console:
In this way, 4 sliders and 4 buttons are available on the main screen to control the 4 colors:
And I was successful! Through the web interface I was able to control the light bulb:
Of course the Wemos D1 board cannot be inserted into the light bulb. I then switched to an ESP-12 module.
To program those modules fantastic boards are available… which unfortunately I don’t own 😉 So I adopted a quick’n’dirty solution, building on a breadboard the schematic explained in this Hackster blog post:
With this circuit I was able to program Tasmota on the module, always using Tasmotized. I also used the handly functions included in Tasmotizer to configure my WiFi settings and to get the module’s IP address when connected to my network:
To perform a normal boot from flash memory, the ESP8266 chip requires some of its pins at a specific logic level:
- GPIO0, pull up to VCC (if connected to GND the programming mode is triggered)
- REST, CH_PD, pull up to VCC
- GPIO15, pull down to GND (if connected to VCC, the chip boots from SD card)
I soldered three 10Kohm resistors on the back of the module for connecting the pins to VCC
GPIO15 instead is used, in my configuration, as a PWM pin to control the white LEDs. If you give a look at the schematic shown in the second part of this tutorial you will discover that it is already connected to GND through a 5.1Kohm resistor.
I soldered thin wires to the remaining pins and covered the module with a heat shrink tubing to avoid any accidental contact
Finally I made all the connections between the ESP-12 module and the control board and arranged everything so that I could close the bulb again:
Here is the final result, a smart light bulb with a new opensource brain!
1 Comment