4-20mA Sensor using analogRead

I’m attempting to use this distance sensor to read a tank level. I’ve got it setup where I’m reading the voltage drop across a 150ohm resistor. It all seems to be working good except I’m having difficulty dialing in on the accuracy this device claims to have. According to my multi-meter, the sensor is working like it should. the trouble is that analogRead is returning a value that jumps around by .02 - .03VDC. which make the distance reading jump around by a couple inches, so my question, surely I’m not expecting to much from this argon?? what resolution can be expected from analogRead?
Here’s how I’m getting a voltage reading so I can compare it with my meter:

    tankLevel = analogRead(LPUSig);  //A5
    sensorVoltage = tankLevel * .0008;

(analogRead is on a 5 sec timer)

Think about this a little more, I guess resolution isn’t quit the right word as there’s .0008V per step. But I still don’t understand what I’m doing wrong here. I’ve left the sensor in the same spot for the last 15 min. My volt meter shows .71 volt constant… never changes — the output from A5 on the argon has ranged from .685 - .732
I wonder what I’m doing wrong.

This is an inherent issue with the inbuilt ADC of most micro controllers - they aren’t known for their precision nor stability :wink:

If you want high precision readings you should use a dedicated ADC chip and for 4…20mA current loops you’d even better use a dedicated board for that exact purpose with a calibrated and temperature compensated shunt resistor.


Ok, thanks @ScruffR!! I’ll quit banging my head against the wall over this, and just go looking for some more hardware. I’d make a guess there’s plenty of options out there for this, and I’ll just go pick one, but if anyone has a favorite, or one that just works I’d like to know about it.

@lsfarm - Wow… that’s an expensive tank level sensor. Are you fixed on using that exact model or maybe there is something specific you need from that model? I’ve had pretty good luck with Maxbotix sonar sensors. They can operate off of the 3.3V from the Particle Device and I currently use a standard analogRead() with their analog version. It’s been pretty darn consistent measurement for me if setup right. They do have RS232 versions as well but I didn’t try that yet. Generally speaking you can pick up a Maxbotix for $100 or so vs nearly 10X for your APG one referenced above. Maybe there is something special about your application though. Here is one for $85 that might work well for you. Maxbotix Weather-Resistant Ultrasonic Rangefinder [MB7092 XL-MaxSonar-WRMA1] : ID 1137 : $84.95 : Adafruit Industries, Unique & fun DIY electronics and kits

1 Like

yeah- scruffR is right - as usual :wink: get a nice adc… also make sure that the bias has some headroom… so that the voltage drop of you’re sense resistor doesent bring the voltage across the sensor down below it’s minimum… calc that in the worst case-20 ma :slight_smile:

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