Hi,
I am trying to evaluate a DFRobotic Pressure level sensor and interface it with an Arduino UNO as outlined in the pdf documentation. That can be read HERE
The setup seems very straight forward. The sensor reads between 0 and 5m of liquid. I am using water. The documentation states the input voltage to the sensor is between 12 and 36v. I am using a 12v transformer with an output of about 13v. The connections to the UNO are as per the diagram.
I am also using the example code with no alterations.
/***********************************************************
DFRobot Gravity: Analog Current to Voltage Converter(For 4~20mA Application)
SKU:SEN0262
GNU Lesser General Public License.
See <http://www.gnu.org/licenses/> for details.
All above must be included in any redistribution
****************************************************/
#define ANALOG_PIN A1
#define RANGE 5000 // Depth measuring range 5000mm (for water)
#define CURRENT_INIT 4.00 // Current @ 0mm (uint: mA)
#define DENSITY_WATER 1 // Pure water density normalized to 1
#define DENSITY_GASOLINE 0.74 // Gasoline density
#define PRINT_INTERVAL 1000
int16_t dataVoltage;
float dataCurrent, depth; //unit:mA
unsigned long timepoint_measure;
void setup()
{
Serial.begin(9600);
pinMode(ANALOG_PIN, INPUT);
timepoint_measure = millis();
}
void loop()
{
if (millis() ‐ timepoint_measure > PRINT_INTERVAL) {
timepoint_measure = millis();
dataVoltage = analogRead(ANALOG_PIN);
dataCurrent = dataVoltage / 120.0; //Sense Resistor:120ohm
depth = (dataCurrent ‐ CURRENT_INIT) * (RANGE/ DENSITY_WATER / 16.0); //Calculate
depth from current readings
if (depth < 0) depth = 0.0;
//Serial print results
Serial.print("depth:");
Serial.print(depth);
Serial.println("mm");
}
}
I am placing the sensor in a 5lt container and slowly filling up the container. The output to serial print doesn't change regardless of the volume in the container. I checked with my multimeter and it looks like I am getting about 105mah when out of water or in about 6" of water. But the reading doesn't change.
Can anyone see an issue with the connections or the example code?
I'm not sure this is a good idea. With an unregulated transformer, the output voltage will vary with the current drawn from the transformer. Your sensor is trying to control the current based on pressure, but if it's input voltage varies as it is attempting to control the current, who knows what the result will be.
Thanks for your replies. I'm thinking that 12v is at the lower end so not reading properly. I will get hold of a regulated 24v power supply and see how that that goes.
It is supposed to give a mAh value between 4 and 120
It is depth that I am trying to measure. I had it in a 5lt container about 25cm high and filled from 0 to full so was expecting a reading to vary with the changing depth, but the reading didn't change. It stayed at 0mm. I'll report back once I try the higher voltage.
My typo I agree 4 to 20 ma. I am only getting 3.7 empty and this value doesn't change even when immersed. So I am concluding that the power supply is part of the issue. I can get hold of a 24v power supply tomorrow and will try it again.
That's something I did wonder about but the pipe hasn't been bent in any way beyond the initial coiling. No obvious kinks. I did wonder about the terminal as it has shrink plastic but there is a gap. Thanks
I left it running for about an hour, but no difference in the reading. It stayed at 3.7 the whole time whether immersed or not.
I hopefully will get a 24v power supply later today (assuming Amazon delivery on time) so will try that and see if there is a difference. Fingers crossed.
When I measure the voltage. The converter board is wired with red 5v from Uno, GND, and Blue to A1. I am getting 4.8v from the uno connected to the Red wire and 0.11v on the blue signal wire. The sensor was dry.
When I measure across the sensor V in and V out on the board I get 3.7mA with the sensor dry. That reading doesn't change wet or dry. Which is why I suspect the power supply which is marked as 12v 1Amp supply, although I get 13v.
You can't measure current that way. You are basically shorting out the sensor output. Hopefully nothing was damaged.
You should only read the converter board output voltage.
0.11V indicated that something is wrong.
If the power supply reads 13V, then I suspect that the sensor or converter board is damaged.