ESP8266 Projects Blog
Home of CBDB / MPDMv4 /SmartMon Development boards (ESP-12/ESP-07).
Guidelines and ESP8266 programming examples using LUA, Eclipse and Arduino IDE, ESP Basic and many more!
The install process is pretty straight forward so I will not insist to much on it:
1. Install Domoticz 2. Install CURL 3. Save LUA script in Domoticz \scripts\lua folder 4.
Check that you don't have any Firewall/AV/Whatever program blocking the
Network IN/OUT traffic for the needed programs and Ports !
For the used version of CURL for Windows installed I was forced to change a bit the sintax, nothing fancy, just see below:
UPDATE !! If you are using Domoticz under Windows, please take a look also at the PART3
Part 2 of the ESPEasy Series. This time we will go further and complete a full ESP8266 / Domoticz Dimmer setup on a RPi2 Board using the MPDMv4 Universal AC Dimmer Board.
commandArray = {} DomDevice = 'MPDMv4_Dimmer'; IP = '192.168.1.169'; PIN = "5"; if devicechanged[DomDevice] then if(devicechanged[DomDevice]=='Off') then print ("OFF dimm = "..uservariables['dimm']); CalcValue = 890; else if(devicechanged[DomDevice]=='On') then DomValue = uservariables['dimm']; print ("ON dimm = "..uservariables['dimm']); CalcValue = DomValue; else print("Other"); DomValue = otherdevices_svalues[DomDevice]; CalcValue = 900-(DomValue*9); commandArray['Variable:dimm'] = tostring(CalcValue); print ("dimm Level = "..uservariables['dimm']); end end runcommand = "curl 'http://" .. IP .. "/control?cmd=PWM," ..PIN.. "," .. CalcValue .. "'"; os.execute(runcommand); print("PWM calculated value= "..CalcValue); end return commandArray
You need to save it in your Domoticz folder under "/scripts/lua/" subfolder as "script_device_MPDMv4_Dimmer.lua"
If followed step-by-step setup as done in the Youtube Video Tutorial above and all OK, you should end up with a working MPDMv4 AC Dimmer interface as below:
In Part 3 you can find details about changes that need to be done for a Domoticz for Windows installation.
Happy Breadboarding!!
ESP Easy Series, Part 1: Firmware upload and MPDMv4 driver simple test
The ESP Easy firmware can be used to turn the ESP module into an easy
to use multifunction sensor device for Home Automation solutions, been easy to integrate it in setups based on Domoticz, OpenHUB, etc.
The configuration process of the ESP Easy is entirely web based, so once you've got
the firmware loaded, you don't need any other tool besides a common web
browser.
First thing that I want to mention, as I found that a lot of people
sometime forget about this simple one: You DAC/ADC/PWM, etc Input/Output
is as good as your Power Supply/Voltage regulator!! If you have a crap
power supply/regulator output with bad filtering & stuff, don't expect
miracles happening!
It is working OK as long as you don't have any blocking process running
on the ESP8266 that can badly interrupt your PWM signal (1/2 second and
more). With a bit of attention to some details and also for not to
complicated lighting setup scenarios is working very nice.
I will do also a more complicated setup example Youtube Video showing you the MPDMv4 AC Dimmer working OK driven directly by
ESP8266 PWM pin, connected as a daughter board on the MPRSx8 Home Automation board.
From Domoticz you can drive thru ESPEasy the MPRSx8 8ON/OFF AC Relays
AND MPDMv4 AC Dimmer channel without any problems at all!
MPDMv4 AC Dimmer board has a first order filter on the VCNT input so can handle even noisy PWM and decent level of duty cycle skipping/derating.
2.Dedicated PWM IC.
I have used with a lot of success the PCA9685, working very smooth and has no
problem related with ESP8266 workload process, etc. You can find more
about a PCA9685 Board here. Probably the best solution for multiple AC Dimmer boards (upto 16 per each PCA9685 Extension Board).
3. Digital driver using a dedicated DAC IC.
VCNT input voltage driven from a MCP4726 12 bit DAC output is working very smooth and has no problem related
with ESP8266 workload process, etc, same as with PCA9685.
As been a 12 Bit DAC it's giving you
very fine VCNT control. I have designed also a Dimmer board with
integrated DAC and digital control, but that's another story.
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:
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.
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
function set_light() read_input(dev_addr) ll = light - hst --lower level lh = light + hst --upper level if (lux < ll) then p=0 i = i - step if (i<0) then i = 0 end pwm.setduty(7, i) end if (lux >lh) then p=0 i = i + step if (i>880) then i = 880 end pwm.setduty(7, i) end --print("Auto Level Adjust : "..i) --print(ll) --print(lh) if (ll< lux and lux < lh) then if (p<1) then p=1 end if (p<2) then print(string.format("\nLight Level: %0.2f lux",lux)) print("Auto Level Adjust : "..i) p=2 end end end
Main Program --PWM testing for MPDMv4 AC Dimmer Board
WARNING!! You will play with LIVE MAINS!! Deadly zone!!
If you don't
have any experience and are not qualified for working with MAINS power I
will not encourage you to play arround!. The
author take no responsibility for any injury or
death resulting, directly or indirectly, from your inability to
appreciate the hazards of household mains voltages.
The circuit diagrams are as accurately as possible, but are offered with no
guarantees whatsoever.
There is no guarantee that this design meets any Rules which may be in
force in your country so please check before your local
rules/regulations.
For any new orders/requests please feel free to use as usual: tech (at) esp8266-projects.com. MPDMv4 Boards are also available on Tindie: AC MAINS Dimmer - MPDMv4
For today we have a short but comprehesive Tutorial on how to drive the MPDMv4 AC MAINS Dimmer board using the Arduino IDE:
Arduino IDE code example for the Youtube Video Tutorial:
/* Dimmer
Demonstrates the sending data from the computer to the Arduino board, in this case to control the brightness of MPDMv4 AC MAINS Dimmer. The data is sent in individual bytes, each of which ranges from 0 to 255. Arduino reads these bytes and uses them to set the VCNT brightness command .
The circuit: MPDMv4 Board attached from digital pin 3 to ground. Serial connection to Processing, Max/MSP, or another serial application
created 2006 by David A. Mellis modified 30 Aug 2011 by Tom Igoe and Scott Fitzgerald modified 14 Apr 2016 by TJ for esp8266-projects.com AC MAINS Power Dimmer MPDMv4 Driver This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Dimmer
*/
const int vcntPin = 3; // the pin that the MPDMv4 VCNT pin is attached to
void setup() { // initialize the serial communication: Serial.begin(9600); // initialize the VCNTPin as an output: pinMode(vcntPin, OUTPUT); // set default brightness value analogWrite(vcntPin, 230); }
void loop() { byte brightness;
// check if data has been sent from the computer: if (Serial.available()) { // read the most recent byte (which will be from 0 to 255): brightness = Serial.parseInt(); Serial.print("Command received : "); Serial.println(brightness); // set the brightness of the LED: analogWrite(vcntPin, brightness); } }
WARNING!! You will play with LIVE MAINS!! Deadly zone!!
If you don't
have any experience and are not qualified for working with MAINS power I
will not encourage you to play arround!. The
author take no responsibility for any injury or
death resulting, directly or indirectly, from your inability to
appreciate the hazards of household mains voltages.
The circuit diagrams are as accurately as possible, but are offered with no
guarantees whatsoever.
There is no guarantee that this design meets any Rules which may be in
force in your country so please check before your local
rules/regulations.
For any new orders/requests please feel free to use as usual: tech at esp8266-projects.com. MPDMv4 Boards are also available on Tindie: AC MAINS Dimmer - MPDMv4
As been a Voltage controled AC MAINS Dimmer you can control it with:
PWM signal
DAC output Voltage
or if you don't want any kind of MCU involved, just user a 10k Potentiometer in a voltage divider as part of a simple VCNT input circuit!
In this example we will use a MCP4728 4 channels/12 Bit DAC as a VCNT (voltage control) command source for our MPDMv4 Dimmer Board.