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.

You can find more details about ESP Easy firmware HERE, on the ESP Easy WIKI page

What we will need:
ESP8266 NextEVO Board
MPDMv4 Universal AC Dimmer – available also on Tindie Store !
ESP Easy firmware
Raspberry PI 2 Board
Domoticz
Lates available bin on a Raspberry PI 2 Board install :  

      sudo curl -L install.domoticz.com | bash

Software 

LUA Script for Domoticz MPDM4 Universal AC Dimmer implementation:

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!!


Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

ESPBasic

ESPBasic Series: Web Interface Slider demo

How easy or complicated is in ESPBasic to have a instant response slider for your MPDMv4 AC Dimmer Web interface? Just look at the code below: cls let xpv = 0 let PWMpin = 5 Read more…

AC Dimmer

Part 2 – Raspberry Pi + Domoticz AC Dimmer

     —————————————————————————————————————————                    Special April Sale Discounts!! Special Spring Sale discounts for all the products available on Tindie Store: https://www.tindie.com/stores/nEXT_EVO1/ Including the popular MPDMv4 Universal AC Mains Read more…

AC Dimmer

Raspberry Pi + Domoticz AC Dimmer – Part 1

—————————————————————————————————————————                    Special April Sale Discounts!! Special Spring Sale discounts for all the products available on Tindie Store: https://www.tindie.com/stores/nEXT_EVO1/ Including the popular MPDMv4 Universal AC Mains Dimmer and Read more…