ESP32 Edgent error

I have this code working as a standalone code for Blynk it works
when I try to modify it and add my code to the edgent-esp32 example, all kinds of errors popup

BlynkWIFI
blynkWifiClient
BlynkEsp32Client
VpinWriteonChange
and others



// Fill-in information from your Blynk Template here
//#define BLYNK_TEMPLATE_ID           "TMPLxxxxxx"
//#define BLYNK_DEVICE_NAME           "Device"
#define BLYNK_TEMPLATE_ID "TMPLvidauePR"
#define BLYNK_TEMPLATE_NAME "Air1"
#define BLYNK_AUTH_TOKEN "cewHtn53ncwKOvzGWnokbrKi8gqYqxAB"
#define BLYNK_DEVICE_NAME "Air-10"
#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define MQ2 34
#define GREEN 12
#define RED 14
#define buzzer  13
#define RELAY_PIN 18                                                                             // define the digital output pin for relay
#define ONE_WIRE_BUS 5
#define Smoke_Reset  4
#define VT_PIN A0   // pin VP 36
#define USE_WROVER_BOARD
#define APP_DEBUG
int MQ2_Val = 0;
bool relayState = LOW;                                                                           // initialize the state of the relay to off
//#include <WiFi.h>
//#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <SimpleTimer.h>
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h> 
#include "BlynkEdgent.h"
WidgetLED led(V1);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress Probe01 = { 0x28, 0xFF, 0x2C, 0x7A, 0x76, 0x04, 0x00, 0x27};                     // ds18b20 Address     



BlynkTimer timer;

// temp sensor 
void getTempData()
{
  sensors.requestTemperatures();
  Blynk.virtualWrite(V2, sensors.getTempFByIndex(0));
}


// Voltage Sensor
void getVoltage() 
{

int vt_read = analogRead(VT_PIN);

  Blynk.virtualWrite(V13, vt_read /219.3);                                                  // change this number to adjust voltage readout (Lower = Higher Readout)
}
// MQ2 Sensor
void mySensor()
{
  MQ2_Val = analogRead(MQ2);
  for(int x = 0 ; x < 150 ; x++)
    {
        MQ2_Val = MQ2_Val + analogRead(MQ2);
    }
    MQ2_Val = MQ2_Val/100.0;
  
  Blynk.virtualWrite(V0, MQ2_Val);
    
  if (MQ2_Val > 500)                                                                          // set off buzzer if goes above 500
  {
//    Blynk.notify("Gas Detected!");
    digitalWrite(GREEN, LOW);
    digitalWrite(RED, HIGH);
    digitalWrite(buzzer, HIGH);
    led.on();
  }
  else
  {
    digitalWrite(GREEN, HIGH);
    digitalWrite(RED, LOW);
    digitalWrite(buzzer, LOW);
    led.off();
  }  

 if (MQ2_Val > 600 ) {                                                                        // check if MQ2 value is above 600 and set off strobe. if smoke_reset is currently on
    digitalWrite(RELAY_PIN, LOW);                                                             // turn on relay
    delay(4000);
    digitalWrite(RELAY_PIN, HIGH);
    
                                                                                              //relayState = HIGH;      set the relay state to off
  }
}
void setup()
{
  Serial.begin(115200);
  delay(100);
pinMode(GREEN, OUTPUT);
  pinMode(RED, OUTPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(RELAY_PIN, OUTPUT); // set the relay pin as an output
  digitalWrite(buzzer, HIGH);
  digitalWrite(RELAY_PIN, LOW );
//  pinMode Smoke_Reset, INPUT);
  
//  Blynk.begin(auth, ssid, pass);//Splash screen delay
  delay(2000);
  timer.setInterval(1000L, mySensor);
   timer.setInterval(1500L, getTempData);
    timer.setInterval(2000L, getVoltage); 
  BlynkEdgent.begin();
}

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


Well, you’ve caused the problems by adding-in parts of the original sketch which conflict with Edgent. You should delete the following…

Auth tokens are assigned dynamically during Edgent provisioning.
Device name has been replaced by template name.

The necessary Blynk libraries are already included elsewhere in the Edgent sketch.
You are using BlynkTimer which is included in the Blynk library, SimpleTimer is not used.

You’ve also messed-up the code sequence with the way in which you’ve inserted your code into the Edgent example.

Your #defines, #includes variable declarations, object declarations etc should be inserted after #include "BlynkEdgent.h" and before void setup()

#include "BlynkEdgent.h"

// Your stuff in here...

void setup()

In addition, you’ve created a conflict with…

and…

If you look at the #if defined(USE_WROVER_BOARD) section of Settings.h you will see that GPIO4 is used for the blue channel of an RGB LED…

#if defined(USE_WROVER_BOARD)

  #define BOARD_BUTTON_PIN            15
  #define BOARD_BUTTON_ACTIVE_LOW     true

  #define BOARD_LED_PIN_R             0
  #define BOARD_LED_PIN_G             2
  #define BOARD_LED_PIN_B             4
  #define BOARD_LED_INVERSE           false
  #define BOARD_LED_BRIGHTNESS        128

If you aren’t using a Wrover board with a an RGB LED then you should amend these pin definitions in Settings.h, otherwise, change the pin you are using for Smoke_Reset

There are other problems, like this blocking delay…

but you can fix that when you solved the compilation issue.

Pete.

I changed it as you wrote.
took awhile to find the proper tick button on keypad, nener used the key before.
Thank you, while waiting for your new reply, im going to try changing the order of the way things are loaded thru the code.
Is there some documentation somewhere that goes thru the proper sequence to load the DEFINE and INCLUDE statements ?

I made the adjustments to the code as you suggested.
got an error on the BYLNK_DEVICE _NAME
so, added it back.
Next error was with Engent_Console.int (BLYNK_PRINT) not Declared.
So added, the 2 lines.

#define BLYNK_PRINT Serial // Defines the object that is used for printing
#define BLYNK_DEBUG // Optional, this enables more detailed prints

Hope I got the correct usage of the tick marks,
New code follows.

#define BLYNK_TEMPLATE_ID "TMPLvidauePR"
#define BLYNK_TEMPLATE_NAME "Air1"
//#define BLYNK_AUTH_TOKEN "cewHtn53ncwKOvzGWnokbrKi8gqYqxAB"
#define BLYNK_DEVICE_NAME "Air-10"
#define BLYNK_FIRMWARE_VERSION        "0.1.0"
#include "BlynkEdgent.h"
#define BLYNK_PRINT Serial // Defines the object that is used for printing
#define BLYNK_DEBUG        // Optional, this enables more detailed prints

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define MQ2 34
#define GREEN 12
#define RED 14
#define buzzer  13
#define RELAY_PIN 18                                                                             // define the digital output pin for relay
#define ONE_WIRE_BUS 5
#define Smoke_Reset  19
#define VT_PIN A0   // pin VP 36
#define USE_WROVER_BOARD
#define APP_DEBUG
int MQ2_Val = 0;
bool relayState = LOW;                                                                           // initialize the state of the relay to off
//#include <WiFi.h>
//#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <SimpleTimer.h>
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h> 




WidgetLED led(V1);


OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

DeviceAddress Probe01 = { 0x28, 0xFF, 0x2C, 0x7A, 0x76, 0x04, 0x00, 0x27};                     // ds18b20 Address     
BlynkTimer timer;

// temp sensor 
void getTempData()
{
  sensors.requestTemperatures();
  Blynk.virtualWrite(V2, sensors.getTempFByIndex(0));
}


// Voltage Sensor
void getVoltage() 
{

int vt_read = analogRead(VT_PIN);

  Blynk.virtualWrite(V13, vt_read /219.3);                                                  // change this number to adjust voltage readout (Lower = Higher Readout)
}
// MQ2 Sensor
void mySensor()
{
  MQ2_Val = analogRead(MQ2);
  for(int x = 0 ; x < 150 ; x++)
    {
        MQ2_Val = MQ2_Val + analogRead(MQ2);
    }
    MQ2_Val = MQ2_Val/100.0;
  
  Blynk.virtualWrite(V0, MQ2_Val);
    
  if (MQ2_Val > 500)                                                                          // set off buzzer if goes above 500
  {
//    Blynk.notify("Gas Detected!");
    digitalWrite(GREEN, LOW);
    digitalWrite(RED, HIGH);
    digitalWrite(buzzer, HIGH);
    led.on();
  }
  else
  {
    digitalWrite(GREEN, HIGH);
    digitalWrite(RED, LOW);
    digitalWrite(buzzer, LOW);
    led.off();
  }  

 if (MQ2_Val > 600 ) {                                                                        // check if MQ2 value is above 600 and set off strobe. if smoke_reset is currently on
    digitalWrite(RELAY_PIN, LOW);                                                             // turn on relay
    //delay(4000);                                                                                          
    digitalWrite(RELAY_PIN, HIGH);
    
                                                                                              //relayState = HIGH;      set the relay state to off
  }
}
void setup()
{
  Serial.begin(115200);
  delay(100);
pinMode(GREEN, OUTPUT);
  pinMode(RED, OUTPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(RELAY_PIN, OUTPUT); // set the relay pin as an output
  digitalWrite(buzzer, HIGH);
  digitalWrite(RELAY_PIN, LOW );
//  pinMode Smoke_Reset, INPUT);
  
//  Blynk.begin(auth, ssid, pass);//Splash screen delay
  delay(2000);
  timer.setInterval(1000L, mySensor);
   timer.setInterval(1500L, getTempData);
    timer.setInterval(2000L, getVoltage); 
  BlynkEdgent.begin();
}

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

@LockMan Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard.

Pete.

Have you posted the correct sketch? This one doesn’t have the changes that I said you should make.

In that case you are not using the latest version of the Blynk library.
You should update the library to version 1.2.0 then go to File > Examples > Blynk > Blynk.Edgent and open the latest version of the ESP32 Edgenbt example.

You should then use this as the basis for your sketch, and add-in the necessary code, in the places I’ve pointed-out and leaving-out the lines of code that don’t belong in the Edgent sketch.

Pete.

Thank You
took some doing ,but its up and running. I still has to add the line
#define BLYNK_DEVICE_NAME “Air-12”
to get ride of an error.


// Fill-in information from your Blynk Template here
//#define BLYNK_TEMPLATE_ID           "TMPLxxxxxx"
//#define BLYNK_DEVICE_NAME           "Device"
#define BLYNK_TEMPLATE_ID "TMPLvidauePR"
#define BLYNK_TEMPLATE_NAME "Air1"
#define BLYNK_DEVICE_NAME "Air-12"
#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


#include "BlynkEdgent.h"
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h> 
                                                                                                //#define BLYNK_PRINT Serial // Defines the object that is used for printing
                                                                                                //#define BLYNK_DEBUG        // Optional, this enables more detailed prints

#define BLYNK_PRINT Serial
#define MQ2 34
#define Buzzer_PIN  13
#define RELAY_PIN 18                                                                             // define the digital output pin for relay
#define ONE_WIRE_BUS 5
#define VT_PIN A0                                                                                // pin VP 36
#define USE_WROVER_BOARD
#define APP_DEBUG
int MQ2_Val = 0;

                                                                                                //#include <BlynkSimpleEsp32.h>







OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress Probe01 = { 0x28, 0xFF, 0x2C, 0x7A, 0x76, 0x04, 0x00, 0x27};                     // ds18b20 Address     
BlynkTimer timer;

                                                                                               // temp sensor 
void getTempData()
{
  sensors.requestTemperatures();
  Blynk.virtualWrite(V2, sensors.getTempFByIndex(0));
}


                                                                                               // Voltage Sensor
void getVoltage() 
{

int vt_read = analogRead(VT_PIN);

  Blynk.virtualWrite(V13, vt_read /219.3);                                                     // change this number to adjust voltage readout (Lower = Higher Readout)
}

                                                                                               
                                                                                               // MQ2 Sensor
void mySensor()
{
  MQ2_Val = analogRead(MQ2);
  for(int x = 0 ; x < 150 ; x++)
    {
        MQ2_Val = MQ2_Val + analogRead(MQ2);
    }
    MQ2_Val = MQ2_Val/100.0;
  
  Blynk.virtualWrite(V0, MQ2_Val);
    
  if (MQ2_Val > 500)                                                                          // set off buzzer if MQ2 goes above 500
  {
                                                                                              //    Blynk.notify("Smoke Detected!");   not working
   
    digitalWrite(Buzzer_PIN, HIGH);
    
  }
  else
  {
    
    digitalWrite(Buzzer_PIN, LOW);
   
  }  

 if (MQ2_Val > 600 ) {                                                                        // check if MQ2 value is above 600 and set off strobe. if smoke_reset is currently on
    digitalWrite(RELAY_PIN, LOW);                                                             // turn on relay
    
    digitalWrite(RELAY_PIN, HIGH);
    
                                                                                              //relayState = HIGH;      set the relay state to off
  }
}




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

  BlynkEdgent.begin();

  
  pinMode(Buzzer_PIN, OUTPUT);
  pinMode(RELAY_PIN, OUTPUT); // set the relay pin as an output
  digitalWrite(Buzzer_PIN, HIGH);
  digitalWrite(RELAY_PIN, LOW );

  delay(2000);
   timer.setInterval(1000L, mySensor);
   timer.setInterval(1500L, getTempData);
   timer.setInterval(2000L, getVoltage); 
}

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


.

how do I mark as solved?

In that case you either aren’t using the latest Blynk library, or you aren’t using the Edgent example from the latest library as the basis for your sketch.

Done.

Pete.

its possible I over written the original file, tried getting it back, no luck.
its says the correct version number.

can I remove the library and try a reinstall ?

I don’t understand.

I suspect that you are basing your sketch on an outdated example sketch.

Pete.

I think I have over written the original example sketch “EDGENT_ESP32” file

I doubt it, the Arduino IDE try’s hard to stop you doing that.

You could look at the time stamps on the files to check if they are the same as the other examples and the Blynk library files.

Pete.

Why didn’t I think of that, yep I overwrote them last month.