How to add codes of ph sensor and ec sensor using esp32 and blynk 2.0

Okay, here’s a clue for you…
Go back to the Edgent example sketch and compare the void loop in that to the command you are using - which is throwing the error.

Hopefully you’ll be able to spot the difference.

Then, take a look at the compiler message and you’ll see that the answer was there all along.

Pete.

// Fill-in information from your Blynk Template here
//#define BLYNK_TEMPLATE_ID           "TMPLxxxxxx"
//#define BLYNK_DEVICE_NAME           "Device"

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

void setup()
{
  Serial.begin(115200);
  delay(100);

  BlynkEdgent.begin();
}

void loop() {
  BlynkEdgent.run();
}

This is the code in the void loop, it does not include the timer.run();

It not the timer.run() command that’s the issue is it?

Pete.

I removed the timer.run() but I get the same error

So you’ve narrowed it down to the problem line.

I guess you’re not very good at those “spot the difference” puzzles?

Pete.

Yeah I guess I’m not good at those

This is now the error

An error occurred while uploading the sketch
A fatal error occurred: Failed to connect to ESP32: Wrong boot mode detected (0x13)! The chip needs to be in download mode.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html

Holding the boot button while the esptool is resetting the board over USB should restart the esp32 in download mode.

I don’t get this part. How to do restart the board?

More details here
https://docs.espressif.com/projects/esptool/en/latest/esp32/advanced-topics/boot-mode-selection.html#automatic-bootloader

You can hold the boot button while uploading the sketch as well.

Thanks, I’ll try this one

Is it normal that it takes 5-8 minutes for it to compile the codes? Because when I use nodemcu, it only takes 2-3 minutes to compile the codes

It shouldn’t take that much. It should be a couple of seconds.

Why does it take too long?

Thank you so much Pete and also John93. You helped me so much. Now my problem is how do I add the code of EC sensor to this sketch

#define BLYNK_TEMPLATE_ID "TMPLUos6FU1I"
#define BLYNK_DEVICE_NAME "PH EC SENSOR WITH BLYNK"

#define BLYNK_FIRMWARE_VERSION "0.1.0"

#define BLYNK_PRINT Serial

#define APP_DEBUG

#define USE_ESP_WROOM_32

#include "BlynkEdgent.h"

BlynkTimer timer;

unsigned long int avgValue;  //Store the average value of the sensor feedback
float b;
int buf[10],temp;


int f;  // for float value to string converstion
float val; // also works with double. 
char buff2[10];
String valueString = "";
String Value = ""; 

void sensorDataSend()
{
  for(int i=0;i<10;i++)       //Get 10 sample value from the sensor for smooth the value
  { 
    buf[i]=analogRead(34);
    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.3/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.print(Value);
  Serial.print("    ");
  Serial.println(valueString);
  valueString = "";
  Blynk.virtualWrite(V0, Value);
}

void setup() {
  Serial.begin(115200);
  BlynkEdgent.begin();
  timer.setInterval(1000L, sensorDataSend); //timer will run every sec 
}

void loop() {
  BlynkEdgent.run();
  timer.run();
}

You seem to have ignored what I said back in post #2

You need to be clear in your own mid what it is that you are wanting to achieve with this second sketch, as it wont work as it is.
In another topic you also mentioned controlling relays. I guess this is intended to be done based on the readings from your sensors.
It’s often best to lay-out your aims and expectations for a project before you start to write any code, as it can have an impact on how your structure your sketch.

Pete.

Yes thank you Pete, you are right. We will also use 5 solenoid water valve controlled by a 5V channel relay that is also connected to ESP32 board. It is not an automated solenoid water valve. We will just control the valve using Blynk for dispensing Acid, Base and nutrient solutions. We will also use Water float sensor. What should I do first?

Explain what you are hoping to achieve with your EC sensor.

Pete.

I’m hoping I could also read the ec value of water like ph sensor in blynk. But what I always see in youtube and other websites, they are using temperature sensor to get the value of EC. But the codes that I uploaded here does not use temperature sensor. That’s why I copied his codes

You don’t seem to have read what I wrote in post #2 or if you have, you don’t appear to want to comment on what I said.

Any reason for this?

Pete.