Friday, 22 July 2016

OpneHab, esp8266 And MQTT - Smart Lighting Project

Hello everyone,
Today I wanted to talk about a old project of mine. I am talking about it just now because like every hardware project of mine, it gets delayed because many design issues.. but the important thing is that I don't give up!
I mean smart lighting is not really new, and not really creative.. you can probably find this title in other blog, but it's really cool in my opinion.
Let's get started:
Why smart lighting? basically.. because I am lazy..
Why not using already retail product? because it's expensive and not challenging.

Actually the real reason for me was my eyes sensitivity to light. In the last years I started walking more and more with sunglasses. In time, my eyes became really sensitive to light (yeah I know, I sound like a basement nerd), which requires changing my light brightness in the room (it was too bright). I got a regular fluorescent lamp, which cannot be dimmed.

Regular incandescent bulb can be dimmed but are really inefficient and the light is yellowish and not nice and natural white. At this point I said let's build some LED based one. At this time the LED strips are really popular, I can use them to light my room.
I used 8 RGB strips of 2.5M


Two 12V 12A power supplies with modified cooling.
This design was tested and I was really disappointed. Those LED strips has afoul efficiency, at 250W they were still less bright than two 32W T8 fluorescent. Each LED got its own resistor, making the entire consumption go to heating the resistors. Even more, for some reason RGB led making white color is much less efficient than just white LED. Also, the cheap LED strips has horrible color uniformly. Each batch is different, and some strips has slightly different colors :(

Knowing the RGB and LED strips are really inefficient, I decided to separate the main white lighting and the RGB one, and of course not using LED strips.  I bought simple 10W RGB LED, and some 220v 15W LED plate.
I will control the brightness with esp2866 PWM connected to MOSFET regulating the 220V.
The first try didnt work because of the LED 220v driver is sensitive to the PWM for some reason.
Second try was a 24W LED plate X4 connected in series, meaning no driver is needed.

The result:


(You may or may not see the thermistor)
Electronics:


From the bottom to up:
PCA9685 - PWM Controller
ESP8266 - Wifi controller based on LUA/Arduino



The GPIO transformer created some problems, it got replaced by optocoupler (made much more sense).

Software
Arduino:

As you can see we are supporting OTA!
The openhab side is really easy except the gamma correction.  You can read about it here.
Simple gamma correction code:


This code create sample gamma table. I took the code and converted it to openhab rule


Testing






The white is really great at 100W max
Usually in the night I am at 25%-33% power, in the day about 50% power. Fully power the LEDs my room becomes white torture room, really bright.
For now the firmware is really basic. I don't mind because of the OTA feature, I don't have to disassemble the LEDs from the sealing.
Future plans may include
- Sending thermal only when active
- Thermal protection in the firmware
- What to do with the 220V GPIO
- Fast protocol for changing colors faster
- Connecting the LEDs to VLC and changing the colors according to the movie.
- (Not mine!!)

Thats it for now!

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete