Suggestion for a device between LED DRIVER output for input on MCP23017

I have a led driver dimmerable and his output is constant 24 volt dimmered with pwm.
I would know his output state, possible solutions:

  1. 24v to 5v converter - for a simple on - off state

  2. A power meter ( like this but i’m not sure if is compatible with pwm modulation )




I can’t help but I’ve moved this to a more appropriate category.

a 24v to 5v converter in the simplest way ist just 2 resistors in series…
Resistor Values have to be calcualted accordingly tho :slight_smile:
(i would choose a 47k and a 10k resistor which would bring the voltage form 24 V to 4.2 V i think)

you could add a large capacitor and measure with an ADC but its probably simpler to have it just look at the timings of the PWM.

Hi Yes take A look at the calculations bellow.

R1 = 47k and the R2 = 10k

Vout = Vin * R2/R1+R2
Vout = 24 * 10/47+10
Vout = 4.2105 V

Our You Can just save this site . it helps a lot.

Nice… Now i remeber that MCP23017 chip has only pull_up internal resistor…
Don’t have pull_down res.
I tried without pull_up resistor but input blink.


This is what PWM does … to make the lights dim, it turns the power on and off very quickly.
If you read that at a digital input, you’ll randomly get on or off.

If you want to ‘read’ the PWM signal, you need something to measure the duty cycle.

But how do you control the dimmer? It has a DALI input that you could pick up as well (it sends "Manchester code’), or are you using a push button?
I can try to come up whith some potentially working solution, but that will take some thought (=time).

blink on other configuration (post) your resp after my post.

i would control the dimmer with a time based rule. i have put a relay, that give 230v on circuit to dali contacts.
that relay is controlled from a mcp23017’s output pin.
Do you know a device that read duty cycle and return as output 5v max?

Many thanks
Lorenzo S.

Two resistors and a capacitor

According to the datasheet it has a PWN frequency of about 1kHz (= 1000 cycles per second). So it would be simple to measure its duty cycle with any MCU.
For example you could use a separate Arduino device and create a simple sketch that measures the ‘ON’ time in microseconds. Since the minimal dim level is 1% and maximum is 100%, you will measure an ON time between ~0.01 ms = dimmed and ~1 ms = full brightness.
The datasheet does not specify if the PWM signal briefly goes low between cycles. If not, you would need a timer to stop measuring. Or you could program the device to set a maximum dim level of 99%.

BTW, The Pi is also capable of reading the PWM signal (but not at 24V). Since this device is handling multiple things, an interrupt and timer driven approach would be needed. And whether that can be accomplished in a simple language like Python, without missing cycles, is uncertain. Programming in for instance C/C++ would also be an option, but that is more complex (e.g. no cross compiler for Windows).

However, I wonder what exactly you want to accomplish. Your initial request was about reading the dim level, but now

you mention that you want to set the dim level from OH. That’s more or less the oposite of measuring it…:grinning:

On a side note: I’m wondering why you want to use these expensive devices for something as simple as control a few LEDs from OH?

input pin from MCP23017 need only to know led driver’s state.
output pin from mcp23017 for (with time based rule) command the led driver. (in this moment just work simple on or off )
eletric plant was made for wife’s reach , the openhab integrations i wish they were with minimal component replace.


What do you mean by state? On/Off or dim level?

i would minim simple on / off , dim level as best wish


If I understand this right … when the dimmer is working, you get on, off, off, on etc. signals from your MCP pin?
If you only get off when the dimmer is off … you already have an on-off indicator.

You just need to use your Item going on to turn another Item on. Do not turn it off. Use a timer or expire binding to turn it off after a few seconds, or however long it is between your “blinking” signals.

In that case I would suggest a simple active low pass filter to convert the PWM signal to a DC level. I’ll create a schematic for that. Be aware that safety should always be a concern and any schematic design needs proper testing.

Will do some calculations tonight…

1 Like

Somthing like this should work and give a voltage relative to the duty cycle. Be aware that there will be some ripple and also a delay of serveral duty cycles before the capacitor is charged and the output voltage matches the pulse width.

Remember, this is not tested…

I solved. Added a device. A shelly 1 pm.


Thing shelly:shelly1pm:FXXXX "shelly1pm-FXXXXX - 192.168.1.XXX" @ "Cucina"    [deviceIp="192.168.1.XXX", userId="", password="", updateInterval=5, eventsCoIoT=true]


Number    GF_Shelly1PM_CucinaPT_watt           "Consumo Led Cucina PT [%.2f W]"                             (GF_Kitchen)                                                         {channel="shelly:shelly1pm:F27605:meter#currentWatts"} /* Power Meter */
Contact   GF_Kitchen_Light                     "Luce Cucina"                   <mylighticon>        (GF_Kitchen, gLightDim)                      ["Lighting"]     {channel=""} 
Number    GF_Shelly1PM_CucinaPT_signal         "Segnale Wifi Led Cucina PT                                [%s]"    <qualityofservice>           (shellypm)                                    {channel="shelly:shelly1pm:F27605:device#wifiSignal"}
Number    GF_Shelly1PM_CucinaPT_TotkW          "Total energia Led Cucina PT [%.2f kWh]"                     (GF_Kitchen)                                                         {channel="shelly:shelly1pm:F27605:meter#totalKWH"}
Switch    GF_Shelly1PM_CucinaPT_button         "Uscita shelly Led Cucina PT"     <switch>                   (GF_Kitchen)                       ["Lighting"]                      {channel="shelly:shelly1pm:F27605:relay#output"} //SWITCH ADD ONLY FOR OPEN VIA PAPERUI - DEFAULT STATE SET TO ON.


rule "Cucina PT glightdim change"
    Item GF_Shelly1PM_CucinaPT_watt received update 
    val mis2 =  GF_Shelly1PM_CucinaPT_watt.state
    if (mis2 > 0) {
        logInfo("Cucina PT glightdim change", "alimentatore maggiore di 0")
        sendCommand(GF_Kitchen_Light, OPEN)
    } else {
        logInfo("Cucina PT glightdim change", "alimentatore = 0")
        sendCommand(GF_Kitchen_Light, CLOSED)