esp32+Blynk

hi everyone I need your help with my project.
I have esp32 connected with ORP sensor and I did the coding after I finished compiling the code and I press on the monitor serial in Arduino it shows error in this message ((Board at COM4 is not available)) also in Blynk show that the ORP sensor not online thank you

//libraries
//pH and ORP variables
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#define samplingInterval 10       //sample values every 10 milliseconds
#define ORP_Pin 1                 //orp meter output,connect to Arduino controller ADC pin

#define ORP_OFFSET 98             //zero drift voltage

#define arrayLenth 40             //times of collection

char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxx";
char ssid[] = "Mashi";
char pass[] = "mashithah";

double ORP_Value;

int ORP_Array[arrayLenth];
int ORP_ArrayIndex=0;
int data_point_counter=0;

//general variables
#define voltage 3.30              //system voltage
#define printInterval 800       //write values every 800 milliseconds

//general formula returning average
double avergearray(int* arr, int number){
        int i;
        int max,min;
        double avg;
        long amount=0;
        if(number<=0) {
  printf("Error number for the array average!/n");
 return 0;
        }
 if(number<5) { //less than 5, calculated directly statistics
 for(i=0; i<number; i++) 
amount+=arr[i];
 }
 avg = amount/number;
return avg;
        }else{
                if(arr[0]<arr[1]) {
                        min = arr[0]; max=arr[1];
                }
                else{ 
                        min=arr[1]; max=arr[0];
                }
                for(i=2; i<number; i++) {
                        if(arr[i]<min) {
                                amount+=min;
                                min=arr[i];
                        }else {
 if(arr[i]>max) {
amount+=max;
  max=arr[i];
 }else{
 amount+=arr[i];
  }
   }
 }
 avg = (double)amount/(number-2);
 }
 return avg;
}

void setup()
{
 
  Serial.begin(9600);
  Serial.println("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, pass);
  int wifi_ctr = 0;
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
 Serial.println("WiFi connected"); 
  Blynk.begin(auth, ssid, pass);
}
      

void loop()
{      
static unsigned long GENERAL_printTime = millis();
ORP_Value=((30*(double)voltage*1000)-(75*avergearray(ORP_Array, arrayLenth)*voltage*1000/1024))/75-ORP_OFFSET;
 if(millis() - GENERAL_printTime >= printInterval) //print to serial monitor and write to file
        {
 Serial.print(millis()/1000);
Serial.print(" sec -- ");
 Serial.print("ORP value: ");
 Serial.print((int)ORP_Value);
  Serial.print(" mV -- ");
  GENERAL_printTime=millis();

              

                } 
                
        }



Hi,

First thing . . .

Second, you have assigned the ORP sensor pin to GPIO 01 . . . on te ESP32 GPIO 01 is the serial TX pin (UART 0 TX), launching the Serial Monitor will also try to use this pin . . . blocking the serial monitor and the sensor. Try a different sensor PIN (hint, look at the ESP32 pin map to find a suitable pin).

Does the sketch compile and upload OK?

cul

billd

1 Like