For my project, I need to create a mobile based automatic pH concentration and meter.
I tried uploading the code before and the serial monitor displays the right output. Then, I proceed to add some coding to connect them with Blynk app. But, the lcd widget in Blynk app can’t display the pH meter (the readings from the serial monitor). May I know where did it went wrong?
The components that I used in my project is:
Hardware: ESP32, pH sensor probe
#define SensorPin V5
#define BLYNK_PRINT Serial
#include <stdlib.h>
#include <SoftwareSerial.h>
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEsp32.h>
char auth[] = "T-DU0SRXD3AB3HaqSmsQgN9GByytJYyU";
char ssid[] = "jaydina@unifi";
char pass[] = "2BIXI7fo1L";
WidgetLCD lcd(V5);
SoftwareSerial nodemcu(2,3);
unsigned long int avgValue;
float b;
int buf[10],temp;
int f;
float val;
char buff2[10];
String valueString = "";
String Value = "";
void setup()
{
pinMode(13,OUTPUT);
Serial.begin(9600);
nodemcu.begin(9600);
Blynk.begin(auth, ssid, pass);
lcd.clear();
lcd.print(3, 0, "pH meter is");
lcd.print(6, 1, Value);
}
void loop()
{
Blynk.run();
for(int i=0;i<10;i++) //Get 10 sample value from the sensor for smooth the value
{
buf[i]=analogRead(SensorPin);
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*5.0/1024/6; //convert the analog into millivolt
phValue=3.5*phValue; //convert the millivolt into pH value
Value = dtostrf(phValue, 4, 2, buff2); //4 is mininum width, 6 is precision
valueString = valueString + Value +",";
Serial.println(valueString);
nodemcu.println(valueString);
valueString = "";
delay(1000);