I’m trying to put notification in my blynk. The concept of my project is that it can monitor the ph reading, tds reading and water level of water using blynk. I can now see the readings of each sensor. Now this time I want to add notification that if for example, the reading of pH sensor is less than the desired value, it will notify me with gmail. I added some code in my sketch but the error is this.
Compilation error: conversion from 'int' to 'const String' is ambiguous
This is the code that I uploaded
// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID "TMPL7li3j7BK"
#define BLYNK_DEVICE_NAME "PH TDS and FLOAT sensor"
#define BLYNK_FIRMWARE_VERSION "0.1.0"
#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define APP_DEBUG
// Uncomment your board, or configure a custom board in Settings.h
#define USE_WROVER_BOARD
//#define USE_TTGO_T7
//#define USE_ESP32C3_DEV_MODULE
//#define USE_ESP32S2_DEV_KIT
#include "BlynkEdgent.h"
BlynkTimer timer; // Announcing the timer
#define PH_Pin 33 //pH meter Analog output to Arduino Analog Input
unsigned long int avgValue; //Store the average value of the sensor feedback
float b;
int buf[10],temp;
int fl_Sensor=32;
int fval=0;
int Redled=5;
int f; // for float value to string converstion
float val; // also works with double.
char buff2[10];
String valueString = "";
String PH_Val = "";
int DSPIN = 14; // Dallas Temperature Sensor
int TDS_Sensor = 34;
float Aref = 2.3;
float ec_Val = 0;
unsigned int tds_value = 0;
float ecCal = 1;
WidgetLED ledglow(V5); // add virtual LED to V5
void float_Data()
{
fval = digitalRead(fl_Sensor);
if (fval == LOW)
{
digitalWrite(Redled, HIGH);
ledglow.on();
Serial.println( "WATER LEVEL - HIGH");
}
else
{
digitalWrite(Redled, LOW);
ledglow.off();
Serial.println( "WATER LEVEL - LOW" );
}
/*
if(fval = 1)
{
Blynk.email("capstonegroup718@gmail.com","Alert","Water Level High!");
Blynk.logEvent("float_sensor","Water Level High!");
}
*/
}
void TDS_Data()
{
// double wTemp = TempRead()* 0.0625; // conversion accuracy is 0.0625 / LSB
double wTemp= 27;
float V_level= Aref / 3500.0;
float rawEc = analogRead(TDS_Sensor) * V_level; // Raw data of EC
float T_Cof = 1.0 + 0.02 * (wTemp - 25.0); // Temperature Coefficient
ec_Val = (rawEc / T_Cof) * ecCal;// temperature and calibration compensation
tds_value = (133.42 * pow(ec_Val, 3) - 255.86 * ec_Val * ec_Val + 857.39 * ec_Val) * 0.5;
double Far= (((wTemp *9)/5) + 32); // Temp in Far*
Serial.print("TDS:"); Serial.println(tds_value);
Serial.print("EC:"); Serial.println(ec_Val, 2);
Serial.print("Temperature (oC):"); Serial.println(wTemp,2);
Serial.print("Temperature (oF):"); Serial.println(Far,2);
Serial.print("");
/*
if(tds_value < 150)
{
Blynk.email("capstonegroup718@gmail.com","Alert","Low Nutrients!");
Blynk.logEvent("nutrient_warning","Low Nutrients!");
}
*/
Blynk.virtualWrite(V1, wTemp);
Blynk.virtualWrite(V2, Far);
Blynk.virtualWrite(V3, tds_value);
Blynk.virtualWrite(V4, ec_Val);
}
void PH_Data()
{
for(int i=0;i<10;i++) //Get 10 sample value from the sensor for smooth the value
{
buf[i]=analogRead(PH_Pin);
delay(10);
}
for(int i=0;i<9;i++) //sort the analog from small to large
{
for(int j=i+1;j<10;j++)
{
if(buf[i]>buf[j])
{
temp=buf[i];
buf[i]=buf[j];
buf[j]=temp;
}
}
}
avgValue=0;
for(int i=2;i<8;i++) //take the average value of 6 center sample
avgValue+=buf[i];
float phValue=(float)avgValue*3.0/1024/14; //convert the analog into millivolt
phValue=4.5*phValue; //convert the millivolt into pH value
PH_Val = dtostrf(phValue, 4, 2, buff2); //4 is mininum width, 6 is precision
Serial.print(PH_Val);
valueString = "";
delay(1000);
Blynk.virtualWrite(V0, PH_Val);
if (PH_Val < 4)
{
Blynk.email("capstonegroup718@gmail.com","Alert","PH reading low level!");
Blynk.logEvent("ph_warning","PH reading low level!");
}
}
void setup()
{
Serial.begin(9600);
delay(100);
pinMode(fl_Sensor, INPUT_PULLUP); // Float Sensor
pinMode(Redled, OUTPUT); // Red LED
timer.setInterval(1000L, PH_Data); //timer will run every sec
timer.setInterval(1000L, TDS_Data); //timer will run every sec
timer.setInterval(1000L, float_Data); //timer will run every sec
BlynkEdgent.begin();
}
void loop() {
BlynkEdgent.run();
timer.run(); // run timer every second
}