Hi friends
can anybody tell me why my Blynk app and serial monitor in Arduino IDE keep getting the same EC value? It’s only printing a value of 20,117. I have tried with two different functions (one is commented out in the Void sendSensor. the result of both functions is still 20,117…
hope someone knows what to do!
best Frederik
#define BLYNK_PRINT Serial
#include "DFRobot_ESP_EC.h"
#include "EEPROM.h"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
DFRobot_ESP_EC ec;
#define ESPADC 4096.0 //the esp Analog Digital Convertion value
#define ESPVOLTAGE 3300 //the esp voltage supply value
#define ECPIN 15
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxx";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxx";
char pass[] = "xxx";
BlynkTimer timer;
float voltage, ecValue, temperature = 25;
void sendSensor()
/*
{
float temperature = 25;
float voltage = analogRead (ECPIN)/4095*3300;
float ecValue = ec.readEC(voltage , temperature);
if (isnan (ecValue)){
Serial.println("Failed to read from EC Probe!");
return;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V7, ecValue); //// another try out :-D
*/
{
static unsigned long timepoint = millis();
if (millis() - timepoint > 1000U) //time interval: 1s
{
timepoint = millis();
//voltage = rawPinValue / esp32ADC * esp32Vin
voltage = analogRead(ECPIN) / ESPADC * ESPVOLTAGE; // read the voltage
ecValue = ec.readEC(voltage, temperature); // convert voltage to pH with temperature compensation
Serial.print("EC:");
Serial.println(ecValue, 4);
Blynk.virtualWrite(V7, ecValue);
}
ec.calibration(voltage, temperature); // calibration process by Serail CMD
}
void setup()
{
Serial.begin(9600);
EEPROM.begin(32);//needed EEPROM.begin to store calibration k in eeprom
ec.begin();//by default lib store calibration k since 10 change it by set ec.begin(30); to start from 30
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
// Setup a function to be called every second
timer.setInterval(1000L, sendSensor);
}
void loop()
{
Blynk.run();
timer.run();
}