Reverse polarity on inputs?

Hi, I am hoping for some help on how to progress with my project..

I am trying to make a data logger for my floor heater control box. I have three thermostats that each activate a 24V valve depending on temperature. I want to latch on to these 24V signals, voltage divide them down to 5V and connect them to three input pins on the Arduino so I can do digitalReads.

I use three separate voltage dividers so the pin voltages don't depend on how many valves are switched on. The dividers have common ground on the arduino. I tried connecting the control box negative terminals to arduino gnd too. But I couldn't make it work, and was very confused why.

Until I discovered that the heating control box creates its 24v voltage difference, not by pulling up its positive terminal like I am used to, but by pulling down the negative. This means that the positive terminals act as common ground for the control box, while the negative terminals are generally not at the same voltage.

This messes up my approach because the arduino needs a common negative ground to get distinct positive signal inputs. My first thought was that I need to flip the signal polarity, but I don't know how to do that or if I am missing some easy solution.

I will make a schematic if the text doesn't make sense, so please let me know if it is necessary. Thanks for your help in advance!

Yes, please do so.

Think about opto-isolators.

I am not that experienced in making schematics so I hope it makes sense. The bunch on the right is the control box, with the switches being thermostats and the solenoids being the valves.
The bunch on the left is my breadboard with ESP32s and voltage dividers.
The schematic shows how I thought it would go, with the control box having common negative. That's not the case. Instead I'm seeing this:

Now that I think of it, 3 relays switched by the control box could do the job of providing 5V signals to the pins with the correct polarity.. Thanks for reminding me of that!
Is there a specific reason it needs to be opto-isolators?

+1 for optoisolators.

You don't need to worry about possibly very dangerous ground loops (you do not need to connect the control box GND to the Arduino GND), and all you have to do is get the two individual, independent polarities of each optoisolator correct.

I'm not sure I follow what would be dangerous in my case, but I guess I'll go with opto-isolators. Thanks for replying.
Also, I've been using relays with 5V input to close a 230V connection with inductive load (btw I see the need for optoisolators in this case) - but I've never used a relay with 24V to control 5V.

Is it normal practice to use a relay to step down the signal voltage like this?

Hi @androandra
Do not use 5V on the ESP32 GPIOs, they support a maximum of 3.3V.
Connecting 5V to the ESP32 GPIOs could damage either the GPIO or even the ESP32.

RV - mineirin

Connecting grounds between two pieces of independently mains-powered equipment is frequently dangerous. Look up the term "ground loops".

Optoisolators are much cheaper and more reliable than relays. Basic hookup:


Huh! Thanks a bunch!


Do not use 5V on the ESP32 GPIOs, they support a maximum of 3.3V.
Connecting 5V to the ESP32 GPIOs could damage either the GPIO or even the ESP32.

RV - mineirin

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.