#include "DFRobot_EC.h"#include <EEPROM.h>
#define EC_PIN A1float voltage,ecValue,temperature = 25;DFRobot_EC ec;
#include "DHT.h"#define DHTPIN 2#define DHTTYPE DHT22DHT dht(DHTPIN, DHTTYPE);void setup(){ Serial.begin(115200); dht.begin(); ec.begin();}
void loop(){ static unsigned long timepoint = millis(); if(millis()-timepoint>1000U) //time interval: 1s { float h = dht.readHumidity(); // ดึงค่าความชื้น float t = dht.readTemperature(); timepoint = millis(); voltage = analogRead(EC_PIN)/1024.0*5000; // read the voltage temperature = t; 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}
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
Hello, which sample code do you use ?
![userHeadPic](https://dfimg.dfrobot.com/62c6fd94aa9508d63a4243be/makelog/6e43d7137cb10d79042a983ec2ce72b9_50x50.png)
#include "DFRobot_EC.h"#include <EEPROM.h>
#define EC_PIN A1float voltage,ecValue,temperature = 25;DFRobot_EC ec;
#include "DHT.h"#define DHTPIN 2#define DHTTYPE DHT22DHT dht(DHTPIN, DHTTYPE);void setup(){ Serial.begin(115200); dht.begin(); ec.begin();}
void loop(){ static unsigned long timepoint = millis(); if(millis()-timepoint>1000U) //time interval: 1s { float h = dht.readHumidity(); // ดึงค่าความชื้น float t = dht.readTemperature(); timepoint = millis(); voltage = analogRead(EC_PIN)/1024.0*5000; // read the voltage temperature = t; 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}