Featured

Ambient light with APA102 and MQTT

Ambient light with sensors and MQTT

Please read Liability Disclaimer and License Agreement CAREFULLY

Transform your living space with this ambient light device, powered by STM32 microcontroller, APA102 LED strip, connected with Wi-Fi and MQTT, and controlled in OpenHAB.

Create the perfect atmosphere with intuitive lighting control and effortless integration with your smart home system.

This DIY solution is easy to set up and customizable to your preferences. Elevate your home experience with this DIY technology.

 

This Ambient light device is build as alternative to Philips Hue Play HDMI Sync Box with extra features.

In order to get the colors displayed by a TV we are using TCS34717FN/TCS34727FN color light-to-digital converter sensors.

They are place in front of TV screen on each side in such way that each sensor sees 1/4 of the screen

Ambient Lights Sensor Position

The Sensor Controller Board

Each TCS34717FN/TCS34727FN sensor is connected to the sensor controller via I2C

Ambient Lights Sensor

Ambient Lights Sensor Controller

Two sensor and one sensor controller are assembled in a small 3D printed enclosure - stp model available for download here.

The placement of the sensor is shown in the image below (top side of the enclosure is hidden).

Ambient Lights Sensor Assembly

The 3D model in STP format for this enclosure can be downloaded here.

The sensor controller brain is an STM32F301K6Ux that is connecting two TCS34717FN/TCS34727FN to I2C1 and I2C2

as well the interrupt pins PB5 and PA8 that are triggering the color data read from sensors.

STM32F301K6Ux 

When the CRGB data from both sensors is available, we normalize it considering the Clear channel and we get the RGB values for each sensor.

We RMS the values for RGB from each sensor to get intermediary values that will ensure a smooth transition of color variation from top to bottom of the TV screen.

Using USART2 we are sending an array of 9 bytes to the Ambient Light Controller.

The first 3 bytes are the RGB values from sensor 1, next 3 byte are the RMS values for RGB and last3 bytes the RGB values from second sensor.

Ambient Light Controller

Ambient Lights Controller

1. Power supply input

2. INA280 high-precision current sense amplifier - is used to monitor the power consumption. It is connected to the MCU using I2C1 pins PB6 and PB7 plus a interrupt connected to PB8 as EXTI8

3. Programming header is exposing the following pins: NRST, SWCLK, SWDIO, SWO

4. Header to connect 1000uF capacitors on the APA102 power line

5. APA102 RGB LED headers connector

We are using SPI1 and SPI2 SCK and MOSI lines to transmit color data to LED strips.

6. Headers to connect the Sensor Controller Boards with the Ambient Light Controller on USART1 (PA9 and PA10)and USART2 (PA2 and PA3)

7. Connection toward ESP-01 or ESP8266 using USART3 PB10 as Rx and PB11 as Tx. To reset the ESP module pin PB2 configured as GPIO output is used.

8. TXS0104E 4-Bit Bidirectional Voltage-Level Translator we move from 3.3V logic level to 5V logic level of APA102

9. STM32F103CBTx

STM32F103CBTx

KiCAD and CubeMX configuration files can be downloaded here.

ESP-01 or ESP8266 is running a small Arduino IDE program that is adding Ambient light device in my WiFi network, connect it to my MQTT server and allows me to control this in manual mode using my home automation software OpenHAB.

The software running on ESP-01 or ESP8266 is found on MQTT software for Ambient light

The software for Ambient Light Sensor Controller Software as well as the one for Ambient Light Controller Software are done in Keil MDK can be used for free is the software size is maximum 32kb.

Comments powered by CComment