Monitor 24VDC lights in arduino

Hello guys,

I am starting a new project and I am trying to read, with an arduino, multiple signals that are entering a switchboard.

Basically, there is a switch that lights up a 24VDC light and (probably) there's a relay after it that keeps it from going off, until another button gets pressed.

There are 10 of this switches, which means 10 of these lights to monitor.

Assuming these lights are all connected to the same switchboard, how can I read them as arduino inputs?

Thanks a lot for your help.

Depends on how they are connected and what connections you can make to them. Please post a circuit diagram of the whole thing, and where you would want to connect the Arduino.

If you don't know if you can connect Arduino ground to device ground,
then the safest way is to use optocouplers.
Look for "8 channel opto isolator" on ebay.
Leo..

Several questions and points...

Are the lights driven with AC or DC ?
Do you want to monitor the light, or the voltage going to it?
(You could monitor both to detect blown bulbs).

Monitoring could be performed one-to-one, or using a 74165 style multiplexer.

Trying to answer the questions made:

  • I can probably connect the GROUNDs between devices
  • the lights are 24VDC
  • just want to monitor if the lights are on or off

I was thinking about using a voltage divider like this one:

Thank you all for your replies.

(edit) I am begginer in this matters so, if you can, explain it in the simplest way

It seems you have full access, so it can be a lot simpler:
schematic.png
Left hand side: the switch is connected between GND (0V) and the lamp; connect the Arduino to the switch. 0V side of the switch to GND of the Arduino; the other side of the switch with diode (mind the direction!) to the Arduino. When the switch is closed, it connects the pin to GND, pulling it low. When the switch is open, the diode blocks the 24V from reaching the pin while the internal pull-up pulls it high. So your pin will read LOW when the lights are on, HIGH when they're off.

Right hand side: the switch is connected between 24V and the lamp (I expect yours is like this - check carefully). Connect the lamp side of the switch to the Arduino pin via the diode (again, mind the direction), and connect grounds (0V - the other side of the lamp in this situation). Now when the switch is open, the low resistance of the lamp pulls down the pin, and when the switch is closed 24V is supplied, the diode blocks, and the internal pull-up does its thing.

It's best to use a fast diode here, like the 1N4148 or even a Schottky, or add a resistor (1-5k or so - not too big or you can't pull low the pin, it's a voltage divider together with the ~30k internal pull-up) if you have a slow diode like the 1N400x to protect your pin.

Beware: if you connect the diode the wrong way, the 24V will destroy your Arduino in an instant.

Just to reiterate my question...
The way you’re going, you’re monitoring if the supply is present, not whether the lamp is actually working.

@wvmarle... if you omit the pullup, and current limit the input, the bulb itself will provide the bias to identify when it’s actually on.

True. Replace the diode with a resistor and use the clamping diodes of the pin.
These clamping diodes are rated up to 0.5 mA iirc (you have to double check this with the data sheet before implementing!) which at 24V (well, 19V after deducting the 5V of the Arduino's supply but let's be safe in case of the Arduino switched off) means you need a resistor with value >48k. A 100k one would do fine in this case.

@wvmarle
So that way I don't even need that voltage divider circuit for each lamp, with just 1 diode (1N4148) per lamp I can do it? You've just put it waaaay simpler that I was thinking.

Meanwhile you posted another answer, so now you are saying that I replace that diode in the schematic with a 100k resistor?

@lastchancename
I mentioned the lamp because it's the visual evidence that the switch was pressed. What I really want to know is if the switch has been pressed.

Once again, thank you for your replies.

Post #5 (left side diagram) plus Post #7

  • both our brains combined == the best solution, but make sure to follow wvmarle's thoughts completely - or you'll smoke the Arduino.
    The 100K resistor is really important!

If the input is HIGH - the LAMP is ON
If the input is LOW, the LAMP is OFF (or blown!)

noodlesadobencha:
@wvmarle
So that way I don't even need that voltage divider circuit for each lamp, with just 1 diode (1N4148) per lamp I can do it? You've just put it waaaay simpler that I was thinking.

Meanwhile you posted another answer, so now you are saying that I replace that diode in the schematic with a 100k resistor?

Yes - can do. The Arduino's processor's pins have clamping diodes to keep the input voltage under control (that's why you have to stay between +5.5V and -0.5V normally). These actually can be used in the exact way as I described - this is even written in the data sheet - to keep the voltage under control, as long as you keep the current under control with a resistor.

This works as long as you can be sure that your 24V doesn't have spikes or so, like in automotive applications. I'm assuming a nice clean 24V supply here. Lamps are also nice and clean almost purely resistive loads (incandescents are really just resistors, but also LEDs), so no problems there either. If these assumptions are wrong you have to let us know, as my very simple circuits are not suitable for all situations.

lastchancename:
Post #5 (left side diagram) plus Post #7

  • both our brains combined == the best solution, but make sure to follow wvmarle's thoughts completely - or you'll smoke the Arduino.
    The 100K resistor is really important!

wvmarle:
Yes - can do. The Arduino's processor's pins have clamping diodes to keep the input voltage under control (that's why you have to stay between +5.5V and -0.5V normally). These actually can be used in the exact way as I described - this is even written in the data sheet - to keep the voltage under control, as long as you keep the current under control with a resistor.

This works as long as you can be sure that your 24V doesn't have spikes or so, like in automotive applications. I'm assuming a nice clean 24V supply here. Lamps are also nice and clean almost purely resistive loads (incandescents are really just resistors, but also LEDs), so no problems there either. If these assumptions are wrong you have to let us know, as my very simple circuits are not suitable for all situations.

So to sum up, I identify which of the diagrams I have - left or right side - I go with a 100k resistor and DON'T use that diode and then use only INPUT instead of the PULLUP?

Use the LEFT diagram...
The bulb itself is what replaces the PULLUP.

The reason is as noted above -
If the input is HIGH - the LAMP is ON
If the input is LOW, the LAMP is OFF (or blown!)

The 100K resistor is really important!

In theory, you could use an input to sense the 'driving signal', and if that is ON, but the bulb is OFF - the globe is dead - as explained above.

lastchancename:
Use the LEFT diagram...
The bulb itself is what replaces the PULLUP.

The reason is as noted above -
If the input is HIGH - the LAMP is ON
If the input is LOW, the LAMP is OFF (or blown!)

The 100K resistor is really important!

In theory, you could use an input to sense the 'driving signal', and if that is ON, but the bulb is OFF - the globe is dead - as explained above.

Ok, left diagram and the pin as an INPUT only.

As a sequence to the project, if I want to read the signal in a computer that is 10 meters away from the arduino (wifi or ethernet), in an interface that shows the bulbs and if they are ON or OFF.

Like this but in a computer interface:


Any suggestions on how to do this? (or should I create a new topic?)

Thanks a lot for your help.

I'm expecting you need the right-hand diagram (switch wired high side, but that's maybe less important with 24VDC than 240VAC) but it depends on the actual wiring. In the case of the right-hand diagram the bulb would act as pull-down when the switch is open.

And for the fun of it I started to think on how you could sense whether the bulb is broken. This can be done with a network of resistors and two diodes:
schematic.png
This can be sensed with an analog pin. I didn't try to optimise values, these should work fine.

Lamp good, switch open: current via R18 and lamp+D2+R20, then R19 to ground. Output 4V.
Lamp good, switch closed: current via lamp+D2+R20 and R18, then R19 and R21+D4 to GND. Output 1.1V.
Lamp broken, switch open: current via R22+R20 and R18, then R19 and to GND. Output 3.5V.
Lamp broken, switch closed: current via R22+R20 and R18, then R19 and R21+D4 to GND. Output 1.9V.

noodlesadobencha:
As a sequence to the project, if I want to read the signal in a computer that is 10 meters away from the arduino (wifi or ethernet), in an interface that shows the bulbs and if they are ON or OFF.

WiFi is easiest, use an ESP8266 based board such as the NodeMCU or WeMOS mini. Then you run a web server on your PC, to which you send the status as http POST.

Note that you can't use a resistor network as shown here on either... the ESP8266's ADC is 0-1V, so both these development boards add a voltage divider to bring this to 0-3.3V. That voltage divider messes up the voltage coming out of this network.

Nice work!

wvmarle:
I'm expecting you need the right-hand diagram (switch wired high side, but that's maybe less important with 24VDC than 240VAC) but it depends on the actual wiring. In the case of the right-hand diagram the bulb would act as pull-down when the switch is open.

And for the fun of it I started to think on how you could sense whether the bulb is broken. This can be done with a network of resistors and two diodes:
schematic.png
This can be sensed with an analog pin. I didn't try to optimise values, these should work fine.

Lamp good, switch open: current via R18 and lamp+D2+R20, then R19 to ground. Output 4V.
Lamp good, switch closed: current via lamp+D2+R20 and R18, then R19 and R21+D4 to GND. Output 1.1V.
Lamp broken, switch open: current via R22+R20 and R18, then R19 and to GND. Output 3.5V.
Lamp broken, switch closed: current via R22+R20 and R18, then R19 and R21+D4 to GND. Output 1.9V.

This could actually be a good addition to the project, the only problem is, as I will have 5+ lamps, it would get a little messy for a reduced space application. But I appreciate your help.
I will try to find out how the switch is connected and update the diagram.

What software do you use to draw those circuits wvmarle?

Drawn using KiCAD.

It got a bit more complex than I expected at first, but I don't see an obvious way of simplifying the circuit.

It's not that big, really. You can place all the components for a single light on a piece of perfboard of just 5x7 holes. By not placing the components flat you can make that even smaller, an area of just 4x5 holes fits. Add a little space for connecting the wires.

It seems you're going to need either an Arduino (the Pro Micro has 8 analog pins available) with separate ESP-01 module or so for the network connection, or an ESP based board with ADC expansion board (like 2x ADS1115 connecting over I2C). The second will be easier to implement.

wvmarle:
WiFi is easiest, use an ESP8266 based board such as the NodeMCU or WeMOS mini. Then you run a web server on your PC, to which you send the status as http POST.

Note that you can't use a resistor network as shown here on either... the ESP8266's ADC is 0-1V, so both these development boards add a voltage divider to bring this to 0-3.3V. That voltage divider messes up the voltage coming out of this network.

wvmarle:
It seems you're going to need either an Arduino (the Pro Micro has 8 analog pins available) with separate ESP-01 module or so for the network connection, or an ESP based board with ADC expansion board (like 2x ADS1115 connecting over I2C). The second will be easier to implement.

I didn't undestand if you're saying that I can't use the diagram in the beggining with these boards.
Should those boards connect into the arduino? Or are they replacing it? Is it a wifi module only? Are they programmed as an arduino?

I really don't have any experience in this area.

Thank you for you help, once again