I have a capstone project entitled Arduino-Based Smart Irrigation and plant monitoring system. It involves esp32 and Various sensors such as soil moisture sensor, dht22, rain sensor etc. (I ditched the arduino for a Esp32) What i have a problem on is the Soil pH sensor. There are 3 outputs that come with those soil pH sensors such as RS485, 0-5V and a 4-20mA output.
I want to know what the difference are between those 3 and what do you recommend that i should use for my Capstone Project.
the RS485 output is used to transmit the pH over a Serial line, you receive bytes that represent (in ASCII or some binary protocol) the value of the pH. You read this through an RS485 to Serial TTL converter and use a Serial port of your arduino. there is no possible added error on the reading circuit, you get what the sensor has sampled out (so depends on its ADC quality)
the 0-5 V is the range of the output. may be at 0V you are at pH 0 and at 5V you are at pH 14 or something like that. You read this with an analogRead() on a pin. Your ESP can only support 3.3V and is not linear at both ends, so you will need to add a voltage divider and have possible challenges near both ends.
the 4-20mA is the range of the output. may be at 4mA you are at pH 0 and at 20mA you are at pH 14 or something like that. You can't read this directly on your Arduino as there is no component to measure current. You could use a resistor and measure the voltage across the resistor (going back to previous case) using Ohm's law to see how many mA are being sent out or use a dedicate amp reader.
The beauty of the 4-20 mA option is that with the correct resistor in loop, you can have whatever voltage you want for the ADC to convert. For example, with a 150 ohm resistor, you'd have a range of 0.6V to 3V for in-range signals. With an input range of 0-3,3 V for the ADC, a value less than 0.6 volts indicates out-of-range low, or possibly open circuit, while a voltage higher than 3.0 indicates too much current, or shorted-to-power.
HOWEVER, the downside of 4-20 is that the transmitter often needs higher voltages for supply e.g. 3V more than the max output, than the ADC is tolerant of, so if your resistor fails open, or is disconnected without first removing the supply voltage, your ADC sees a possibly damaging input voltage. Commercial 4-20 receivers usually have protection from this failure mode, but hobbyists are vulnerable.
As usual, no benefit without risk.
Agreed. Just remember to select the right resistor, calculate the voltage range you're expecting(and use map(), or similar, to generate your signal range), and NEVER connect/disconnect parts of the circuit while still powered.
if you go for the mA output, you need a resistor (1% or 5% error are usual) and then you have the error due to the quality of the ADC on your ESP and possibly interferences on the wire between the sensor and the Arduino - but then coding is pretty straightforward (just a analogRead)
In your case the Serial communication needs an RS485 to Serial 3.3V converter which costs more and take more space than resistors and the code to parse whatever payload is sent is more complicated than an analogRead (although not rocket science either).
if budget or space on your PCB matters and are not worried about a few percent additional error possibly or want straightforward coding, then the mA sensor is a good way to meet your needs as long as your wires stay relatively short.
I prefer serial communication when I get a chance because I don't add errors along the reading path so you get whatever the specs say the reading error is and RS485 is known for its robustness in industrial communication applications.
I neglected to mention that the ESP is notorious for challenging conversions, so there is that. But, as I was describing, as it's non-linearities are, IIRC, at the ends of the range, and in those areas you're into the 'failed' states(open/short) anyway. Problem is, you're throwing away conversion range to do this.
The RS485 approach is more robust, for sure, it's just more software, plus the MAX485 converter, wiring, et.
Do you have an email so i can email you the link? It registers as spam when i post the link in the replies so i have to put extra dots so it wont be removed