Thanks. Did you make any revisions to produce the above code? Or is it verbatim from the other thread? Where did it come from?
...and, the wiring diagram? In the other thread, there were also suggestions to improve or fix the hardware design... did you follow them, or investigate at all?
Considering the code, it would be best to set aside the sketch for now, and use a simple test sketch that only reports raw ADC values. Then you can be sure whether it's a hardware or software problem.
Post a picture of the setup.
The other poster seems to have connected the sensor to A0 instead of A1 in the code.
A mistake easily made.
Yep, DFRobot made a real mess of this.
Only 393 A/D values spread over 5000mm, and the wrong analogReference.
They should have used an ADS1115 between sensor and Arduino. This would have been a better option, and it doesn't need a 24volt supply.
Leo..
Was on the page OP linked to. This one, and it comes with a voltage follower, with 2.4volt output at 20mA.
Which is a poor match for a 5volt Arduino, and double bad if default Aref is used.
Leo..
Hi,
So its a pressure sensor. @ejhammer7777 have you measured the current in the 4-20mA loop?
Is the air pipe open to the atmosphere?
What reading do you get with the sensor out of the water?
What reading do you get when at a measured depth?
@ TomGeorge
I think you're in industrial electronics. Don't you think it's strange that the current to voltage converter is used in the + line. Is that ever done?
I think it's not a problem if one of the supplies is floating, but if the Arduino and sensor supply have a shared ground then sensor voltage is outside common mode voltage of the opamp on that board.
Leo..