//YOUTUBE VIDEO HERE//
You can see this article as a continuation of the previous BH1750FVI - I2C Light Sensor Driver one.
The main goal of the project is to create a AC Mains Light dimmer that can automatically control the level of light and keep in in the desired set interval without any external intervention.
Why would you be intrested in such a setup? Well, if you have any interest in hydroponics, photography, or anywhere where you need some sort of constant flood light lamps with precise light intensitity level setup then might be a good idea to take a look :)
What we will need:
- ESP8266 nEXT EVO Board ( Also bare PCBs are available directly at DirtyPCB's Shop )
- BH1750FVI Module . Can be ordered in packs of ONE, FIVE or even TEN from the corresponding links. My 10 one was backordered but received it quite quickly.
- MPDMv4 AC MAINS Dimmer board . Available also on Tindie Store!
- For programming and uploading the driver and the software we will continue to use the LuaUploader as before.
Connection with the ESP8266 nEXT EVO Board is very easy, as MPU6050 GY-521 Module connector is fully compatible with the nEXT Bus connector. Depending on how to you choose you socket type, you can install it on TOP or Bottom of the ESP8266 nEXT EVO Board :
|BH1750FVI Module directly connected to the ESP8266 nEXT EVO Board|
And the whole project setup, with MPDVv4 AC Dimmer connected on ESP8266 GPIO13 (pin 7):
|MPDM v4 + nEXT EVO + BH1750FVI|
|Closer look, MPDMv4 connected at ESP8266 GPIO13 (Pin7) for PWM control|
You will need also the code from the previous BH1750FVI article. Please take also a look there for more details.
1. Ligth level auto-adjust function
ll = light - hst --lower level
lh = light + hst --upper level
if (lux < ll) then
i = i - step
if (i<0) then i = 0
if (lux >lh) then
i = i + step
if (i>880) then i = 880
--print("Auto Level Adjust : "..i)
if (ll< lux and lux < lh) then
if (p<1) then p=1
if (p<2) then
print(string.format("\nLight Level: %0.2f lux",lux))
print("Auto Level Adjust : "..i)
--PWM testing for MPDMv4 AC Dimmer Board
pwm.setup(7, 500, 850) --MPDMv4 control pin
i=10 --initial Light Level
pwm.setduty(7, i) --set initial ligfht level
light = 250 --light level
hst = 40 --histeresis coef for desired light interval
step = 1 --light step
--read light intensity value every 50 and autoadjust Light Dimmer Driver accordingly
tmr.alarm( 1, 50, 1, function()