Go Down

Topic: Monitor 24VDC lights in arduino (Read 638 times) previous topic - next topic

wvmarle

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.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

lastchancename

Experienced responders have a nose for laziness, (they were beginners once)... expecting the poster to contribute to the learning experience.

noodlesadobencha

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:

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?

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.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

noodlesadobencha

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

wvmarle

NodeMCU and WeMOS are development boards, very similar to the Arduino Nano in form factor, but with a different microprocessor: the ESP8266, which has WiFi connectivity built in. They can be programmed using the Arduino IDE (just install the ESP8266 core).
Some key differences include the number of I/O pins - the ESP has less of them than the Arduino. Enough digital ones for your project; not enough analog ones if you want to use that extra bulb detection. It also runs at 3.3V instead of 5V.
Also note that you have to change the resistor values of the network, as the ESP8266's ADC goes from 0-1V, and as said the development boards add their own voltage divider which makes the whole thing a bit more complex. Hence the external ADC. You'll anyway have to change the values in the resistor network that I suggested, as you have to go to <3.3V outputs.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

noodlesadobencha

Also note that you have to change the resistor values of the network, as the ESP8266's ADC goes from 0-1V, and as said the development boards add their own voltage divider which makes the whole thing a bit more complex. Hence the external ADC. You'll anyway have to change the values in the resistor network that I suggested, as you have to go to <3.3V outputs.
If I go with your first option, the one without the 'broken bulb sensor', do I need to worry about the ADC?
Or can I only adjust the 100k resistor to a more adequate value, to have <=3,3V inputs?

Thank you

wvmarle

You can use the same approach as the Arduino: use a big enough resistor (100k at least) to connect the switching side of the switch directly to one of the NodeMCU's digital pins, or use a diode and the internal pull-up method. Both will work just fine. The ESP8266 also has these clamping diodes.

Of note: some pins of the ESP8266 have special function in the boot process (0, 2 and 15 specifically - you have to check to which Dxx they're mapped) and are best avoided unless you know what you're doing.. Pin 1 and 3 are TX and RX which can be used but are also used to program the thing, and you may want to use them for debugging. That leaves you with 4, 5, 11, 12, 13 and 14 that can be used without issues.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

noodlesadobencha

You can use the same approach as the Arduino: use a big enough resistor (100k at least) to connect the switching side of the switch directly to one of the NodeMCU's digital pins, or use a diode and the internal pull-up method. Both will work just fine. The ESP8266 also has these clamping diodes.

Of note: some pins of the ESP8266 have special function in the boot process (0, 2 and 15 specifically - you have to check to which Dxx they're mapped) and are best avoided unless you know what you're doing.. Pin 1 and 3 are TX and RX which can be used but are also used to program the thing, and you may want to use them for debugging. That leaves you with 4, 5, 11, 12, 13 and 14 that can be used without issues.
So, if I want to monitor 10 light bulbs, I don't have enough pins to do so, right?

wvmarle

Correct.
So just add a port expander. An MCP23008 or PCF8574 to add 8 ports, or an MCP23017 or PCF8575 for 16 more ports, or use shift registers.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

noodlesadobencha

Correct.
So just add a port expander. An MCP23008 or PCF8574 to add 8 ports, or an MCP23017 or PCF8575 for 16 more ports, or use shift registers.
And the nodemcu and the expander can be programmed within the arduino IDE?

wvmarle

Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

noodlesadobencha

Yes.
Well, I think I settled with a solution then.

You were really helpful and patient with your quick responses, thanks a lot.

wvmarle

Do also read this ESP beginner's guide with lots of useful info on this processor. It is very similar in many respects to the Arduino but does have some important differences, especially due to the WiFi parts.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

noodlesadobencha

Do also read this ESP beginner's guide with lots of useful info on this processor. It is very similar in many respects to the Arduino but does have some important differences, especially due to the WiFi parts.
Ok, thank you once again.
When I was preparing to implement this solution, someone who saw it said something like 'there will be too much noise in that solution, you should go with relays or even opto couplers' - would I need to use solid state relays or the eletromechanical would do?

Go Up