Go Down

Topic: Gravity: Throw-in Type Liquid Level Transmitter - pressure sensor (Read 174 times) previous topic - next topic

cristma762

hello everyone, right now im working with my sensor ( Gravity: Throw-in Type Liquid Level Transmitter), you all could find information on the next link ( https://www.dfrobot.com/product-1864.html?search=liquid%20level%20&description=true ) so, i am have trouble with the results, i used the electronic distribution that said on the page aun used the code that said on the page but i have wrong results, pleas ewho can i help me? my result with this senosr are like 4 meters but i put the sensor in 10 cm of water column




more information about the sensor on the netx page
https://wiki.dfrobot.com/Throw-in_Type_Liquid_Level_Transmitter_SKU_KIT0139

the code used was :
/***********************************************************
  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");
  }
}

JCA34F

Which Arduino?
Post a drawing of exactly how the sensor, load resistor and Arduino are connected together and powered.

jremington

Please read and follow the directions in the "How to use this forum" post. Edit your post to add code tags.

cristma95

arduino uno
powered 12v
i used the next ink

https://raw.githubusercontent.com/DFRobot/Wiki/master/KIT0139/image/KIT0139_Arduino_connection(EN).png

i use the next code
Code: [Select]
/***********************************************************
  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");
  }
}

Wawa

That current/voltage module setup has a resolution of about 400 levels with the potentially unstable default Aref of the Uno. And I think the code is mostly nonsense. 400 levels over 5meters is readout steps of 1.25cm at best.

A single ~51ohm resistor, and maybe some surrounding protection parts, would have given you about 800 levels, with a more stable supply-independent readout.
A resistor with ADS1115 module would have given you several thousand levels.
Many examples on this site. Enter "4-20" in the search field on top of this page.
Leo..

MarkT

Surely that line:
Code: [Select]

    dataVoltage = analogRead(ANALOG_PIN);

needs to be
Code: [Select]

    dataVoltage = 5.0 * analogRead(ANALOG_PIN) / 1024;

So its an actual voltage, not a number between 0 and 1023...
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Wawa

But the Arduino (Uno) does not reliable read/return a voltage with default Aref.
The A/D returns a ratio of it's own supply, which could be 4.8 or 5.1volt.

If you want to read a voltage you must use a fixed/stable Aref, like the internal 1.1volt Aref.
Or link the Aref to the more stable 3.3volt supply. DFRobot should know better.
Leo..

Go Up