ArduinoGeneral

Gravity analog electrical conductivity sensor meter reading unknown values

userHead ethanczc 2018-09-15 11:33:58 5085 Views4 Replies
Hi, i bought a gravity analog electrical conductivity sensor from dfrobot.
I used the sample code as provided by dfrobot and used DFRobot_EC.h library.
I dipped the EC sensor into the 1.413 ms/cm solution.
I used a ds18b20 sensor for temperature reading.
I got a reading of "nan" instead of anything near 1.413. It is the same without using temperature compensation.
As expected, the probe is not able to be calibrated due to unknown ec value.
I could not find any meaning of the value from the library .cpp file. Is anyone able to help?
icon ec sensor error.PNG Download(0)
2018-09-25 18:41:21 Hi.
I found the problem that you needed to run the following program line before running the example code.
This is due to EEPROM storage value conflict.
#include <EEPROM.h>
#define KVALUEADDR 0x0A
void setup(){
for(byte i = 0;i< 8; i++ ){
EEPROM.write(KVALUEADDR+i, 0xFF);
}
}
void loop(){
}
userHeadPic makermuyi
2018-09-19 15:12:43 Hi.
when I looked at the library files DFRobot_EC.cpp and DFRobot_EC.h. I don't konw why you got the 'nan', In the absence of a EC sensor, I run the code and the results are as follows.If the sensor is not connected, run the sample code to observe the return result to determine if the sensor is broken.
userHeadPic makermuyi
2018-09-18 16:47:24 For simplicity sake, i have followed exactly the same as the setup in the wiki.
Here is the code i used, it is from the product wiki
https://www.dfrobot.com/wiki/index.php/ ... KU:DFR0300
Code: Select all
/*
 * file DFRobot_EC.ino
 * @ https://github.com/DFRobot/DFRobot_EC
 *
 * This is the sample code for Gravity: Analog Electrical Conductivity Sensor / Meter Kit V2 (K=1.0), SKU: DFR0300.
 * In order to guarantee precision, a temperature sensor such as DS18B20 is needed, to execute automatic temperature compensation.
 * You can send commands in the serial monitor to execute the calibration.
 * Serial Commands:
 *   enter -> enter the calibration mode
 *   cal -> calibrate with the standard buffer solution, two buffer solutions(1413us/cm and 12.88ms/cm) will be automaticlly recognized
 *   exit -> save the calibrated parameters and exit from calibration mode
 *
 * Copyright   [DFRobot](http://www.dfrobot.com), 2018
 * Copyright   GNU Lesser General Public License
 *
 * version  V1.0
 * date  2018-03-21
 */

#include "DFRobot_EC.h"
#include <EEPROM.h>

#define EC_PIN A1
float voltage,ecValue,temperature = 25;
DFRobot_EC ec;

void setup()
{
  Serial.begin(115200);  
  ec.begin();
}

void loop()
{
    static unsigned long timepoint = millis();
    if(millis()-timepoint>1000U)  //time interval: 1s
    {
      timepoint = millis();
      voltage = analogRead(EC_PIN)/1024.0*5000;  // read the voltage
      //temperature = readTemperature();  // read your temperature sensor to execute temperature compensation
      ecValue =  ec.readEC(voltage,temperature);  // convert voltage to EC with temperature compensation
      Serial.print("temperature:");
      Serial.print(temperature,1);
      Serial.print("^C  EC:");
      Serial.print(ecValue,2);
      Serial.println("ms/cm");
    }
    ec.calibration(voltage,temperature);  // calibration process by Serail CMD
}

float readTemperature()
{
  //add your code here to get the temperature from your temperature sensor
}
The hookup is exactly the same as in the wiki page.
userHeadPic ethanczc
2018-09-17 10:14:09 Hi.
In order to help you better, I hope that you can provied the sample code and connection diagram of your projict ?
userHeadPic makermuyi