What's the difference of RS485 / 0-5V / 4-20mA

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.

Your replies are much appreciated

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.

1 Like

How far away is the soil sensor from the ESP32?

1 Like

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.

1 Like

Around 2-4 meters away from the main microcontroller

What do you recommend that i buy then sir?

round 2-4 meters away from the main microcontroller

Then use either RS485 or 4-20ma
The 4-20mA will be the simplist to use.

1 Like

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.

1 Like

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.

Can you give me some insight on how i can use the Rs485 one? All my other sensors are pretty straightforward so I'm a bit lost in this part

First thing any of us would need is a link to the exact part you've got.

These are the links for the components

https://s.lazada.com.ph/s.RoYCS (i didn't buy the soil pH as I'm still deciding what to buy)
https://shp.ee/8p43gyy (esp32. I have the 38 pin one)
https://shp.ee/32e5ux8
https://shp.ee/kjwtfua

Which one is for the sensor in question - but please find a non-invasive link to the product. Or, find a datasheet provided by the supplier.

These are some of the info that i found on the sensor if this helps

Electrical power supply

DC4.5-30V

Max power consumption

0.5W 24V DC

Protection level

IP68, long-term immersion in water use

Cable length

Default is 2m (can be customized)

Working environment

-40°C-80°C

Overall size

4515123mm

Output

RS485/4-20mA/0-5V/0-10V

High temperature

Accuracy: ±5°C(25)°C)

Long-term stability: ≤ 0.1%°C/Y

Response time: ≤ 15s

Measurement range: 0-100% RH

Humidifiers

Accuracy: 2% within 0-50%, 3% within 50-100%

Long-term stability: ≤ 1% rh/y

Response time: ≤ 4S

Measurement range: 0-20000us/cm

Conductive conductivity (EC)

PH

Accuracy: ± 3% (0-10000 us/cm); ± 5% (10000-20000 us/cm)

Long-term stability: ≤ 1% us/cm

Response time: ≤ 15

Measurement range: 3-9 Ph

Accuracy: 0.3ph ±

Long-term stability: ≤ 5%/year

Response time: ≤ 10s

It's RS485? That implies it doesn't talk unless asked. Do you have to query the device?
Which of your above 4 links was for this device?

Do you have the operators manual and the Arduuino library for the soil moisture sensor?

It was the first one.

This is the link. It's in lazada, a online shopping app so no need to worry

https://s.lazada.com.ph/s.RoXlr

Well, that link doesn't work for me. If you can't find a datasheet, helping is impossible. Good luck!

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