Forum >Replies by chanaweerom
userhead chanaweerom
Replies (2)
  • You Reply:

    #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}

  • You Reply:

    #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}