Hello,
I am operating motorized ball valve using ESP32 and relay module, ball valve has two feedback voltage to detect close and open position of valve, there are two output wires one to detect close state and one to detect open state of valve. see below image.
**My question is how to collect feedback using Arduino/ESP32 to detect open/close state of valve ? ** Open state voltage between "R1(BLUE) and Negative(BLACK) will be 24v DC Close state voltage between "R2(YELLOW) and Negative(BLACK) will be 24v DC
Based on my read and my interpretation of your post. I would just either divide down the Open/Close outputs or as suggested use an opto coupler as cedarlakeinstruments suggested and I would lean towards the latter. Actually since the valve only has two states you only need one digital I/O channel.
The optoisolator is the best way to ensure you don't damage anything. There are a few other advantages.
Your number 2., however, is meant to go the other way, that is to say it is used to take a microprocessor output and use that to control a higher voltage.
It may well be that your number 1. is indeed implemented using an optoisolator.
Do you have a part number or where you saw that a link to the product?
The number 2. is also oddly labeling its output as low level, this is not how I understand the reg of what's going on with that module, so post a link to that part, also.
PC817 2 CH Optocoupler Isolation Module is actual module i planned to use, but i feel that voltage sensor will be best choice, right?
Here i found PC817 use case
I'm not sure what the difference is. I suspect the voltage sensor is doing that with the same kind of circuit.
But I'm still interested in your option 1. above, what is and where did you find that product?
Where did you get the circuit you posted? Share a link.
The resistor for the LED looks high for a 24 volt driving signal. Check the datasheet to make sure the current is correct.
On the output side, it is more common to see the resistor placed between Vcc and the collector of the phototransistor, with the emitter going to ground. In that configuration, the presence of the 24 volt signal woukd result in the input being pulled LOW. This is easily accounted for in the software.
Don't use voltage dividers for this. Voltage dividers are for cases where you can guarantee that you won't overvolt whatever is at the load end. The safe and simple solution is an optocoupler or a transistor. Go with the optocoupler: this is not the kind of thing worth spending days thinking about.