Page 1 of 1

ESP PWM output possible to control a dimmer?

Posted: 15 Aug 2016, 01:47
by sheppy
I'm running ESP Easy on 2 Wemos D1 Mini's for DS18B20 temperature readings and also to control relays, and it works very well.
I would like to add in a AC Dimmer and wonder if ESP Easy can output a stable PWM signal which I can convert into a DC voltage using a low pass filter and then connect to a voltage controlled dimmer such as this one

http://www.esp8266-projects.com/2016/04 ... witch.html

The designer cautions against using an ESP directly with PWM but doesn't mention using a low pass filter to create DC.
Alternatively can anyone suggest a way of getting a MQTT Mains Dimmer? Its a Linear Halogen Bulb so I can't easily replace it with a dimmable LED

Re: ESP PWM output possible to control a dimmer?

Posted: 16 Nov 2016, 14:46
by DeNB3rt
Hi, I'm looking for the same.
Did you order that dimmer? Did some testings?

Thanks!

Re: ESP PWM output possible to control a dimmer?

Posted: 29 Nov 2016, 22:08
by Shardan
Hello,

surely the output can be used for that.
I know there are some commercial devices using an ESP and some power FET's for that.

But be aware that some other devices / tasks may interrupt the PWM for a short moment.
I have this effect with using PWM for fan speed control and some rules aside.
The fan is without power every second or two for a moment. On a LED stripe this says it flickers.

A PCA9685 might be a nice answer for that problem and gives more possible channels.
It's a 16chan PWM chip driven via I²C. A breakout board can be obtained at elecronic shops or Aliexpress.

I'm waiting for a PCB i've ordered for building a prototype of a multichannel dimmer based on ESP-01 and PCA9685 breakout.

For directly dimming mains voltage i would prefer to use a ready made dimmer module.
Mains voltage is dangerous!

Regards
Shardan

Re: ESP PWM output possible to control a dimmer?

Posted: 30 Nov 2016, 22:23
by DeNB3rt
Shardan wrote:Hello,

surely the output can be used for that.
I know there are some commercial devices using an ESP and some power FET's for that.

But be aware that some other devices / tasks may interrupt the PWM for a short moment.
I have this effect with using PWM for fan speed control and some rules aside.
The fan is without power every second or two for a moment. On a LED stripe this says it flickers.

A PCA9685 might be a nice answer for that problem and gives more possible channels.
It's a 16chan PWM chip driven via I²C. A breakout board can be obtained at elecronic shops or Aliexpress.

I'm waiting for a PCB i've ordered for building a prototype of a multichannel dimmer based on ESP-01 and PCA9685 breakout.

For directly dimming mains voltage i would prefer to use a ready made dimmer module.
Mains voltage is dangerous!

Regards
Shardan
Thanks for the PCA9685 hint! :)

Re: ESP PWM output possible to control a dimmer?

Posted: 01 Dec 2016, 11:09
by trackerj
It is working very well if your setup will respect some simple conditions.

I have opened a related post, so everybody that has related questions about, can keep an eye here:
viewtopic.php?f=2&t=2362

Happy breadboarding,
TJ.

Re: ESP PWM output possible to control a dimmer?

Posted: 08 Dec 2016, 12:50
by DeNB3rt
confirmed :)
Only when cold boot, I see that my pwm is giving a sort of signal;

Re: ESP PWM output possible to control a dimmer?

Posted: 23 Mar 2017, 09:00
by ledfreak3d
Here you go this script will control all your espeasy lights both rgb and single channel lights can be dimmed

Code: Select all

local lights = {
  ['Aqua Dimmer R/W'] = {ip = '192.168.1.98', pin = '14', rgb = false},
  ['Aqua Dimmer B/W'] = {ip = '192.168.1.98', pin = '4', rgb = false},
  ['keuken'] = {ip = '192.168.1.65', pin = '12', rgb = false},
  ['Blokhut'] = {ip = '192.168.1.93', pin = '14', rgb = false},
  ['Lampjes'] = {ip = '192.168.1.93', pin = '4', rgb = false},
  ['Trap'] = {ip = '192.168.1.40', pin = '5', rgb = false},
  ['Kontorhylde W'] = {ip = '192.168.33.67', red = '15', grn = '13', blu = '12', rgb = true},
  ['Stuereol W'] = {ip = '192.168.33.61', red = '15', grn = '13', blu = '12', rgb = true},
  ['Seng W'] = {ip = '192.168.33.66', red = '15', grn = '13', blu = '12', rgb = true}
}

function setlight (ip, pin, dvalue)
    os.execute("curl 'http://" .. ip.. "/control?cmd=PWM,".. pin .."," .. tostring(dvalue) .. ",1150'")
end

commandArray = {}

for deviceName,deviceValue in pairs(devicechanged) do
    if (lights[deviceName]) then
        if (deviceValue == 'Off') then
            dvalue = 0 ; 
        elseif (deviceValue == 'On') then
            dvalue = 1024
        else
            inputValue = tonumber(otherdevices_svalues[deviceName])
            
            curve = 1.5848931924611
            normalizedCurVal  =  (inputValue - 1.0) / 99.0
            rangedValue =  (math.pow(normalizedCurVal, curve) * 1023.0) + 1.0
            
            dvalue = math.ceil(rangedValue)
        end
    
        if (lights[deviceName]['rgb']) then
            setlight(lights[deviceName]["ip"], lights[deviceName]["red"], dvalue)
            setlight(lights[deviceName]["ip"], lights[deviceName]["grn"], dvalue)
            setlight(lights[deviceName]["ip"], lights[deviceName]["blu"], dvalue)
        else
            setlight(lights[deviceName]["ip"], lights[deviceName]["pin"], dvalue)
        end
    end
end
return commandArray