Throw-in Liquid Level - Returns several levels

0 44938 Medium

Please,

I have set up the liquid level sensor with an Arduino, a current to voltage converterĀ  and a 24V DC power supply.Ā 

But this scheme returns several different levels:
Ā 


Ā 

depth:197.92mm
depth:338.54mm
depth:1075.52mm
depth:338.54mm
depth:796.88mm
depth:184.90mm
depth:171.88mm
depth:171.88mm
depth:364.58mm
depth:1036.46mm
depth:286.46mm....
Ā 

Ā 

Ā 

CODE:

#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ā€);
}
}

Ā 

Thank you for your help

projectImage
License
All Rights
Reserved
licensBg
0