ESP32 board manager version

Hi there,

I’m going to to use ESP32 DEV KIT V1 board for my project.
What is the recomended board version shuld I use in Arduino.
The latest version as of this post, is 3.0.7v, however I’m currently using 2.0.14v after seeing posts.
image

Thanks.

Are you planning on using the Edgent sketch?

Pete.

No.

following is the project.
I’m trying to witch on/off some outer parameter flood lights, using SSR’s as the high voltage/current switchs.
Total of 9 lights. 9 individual buttons + 1 button to switch all at once.

#define BLYNK_TEMPLATE_ID   "TMPxxx...."
#define BLYNK_TEMPLATE_NAME "hello world"
#define BLYNK_AUTH_TOKEN    "zsLXq......."

#define BLYNK_PRINT Serial

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

#define OUT01     4
#define OUT02     12
#define OUT03     13
#define OUT04     14
#define OUT05     15
#define OUT06     16
#define OUT07     17
#define OUT08     18
#define OUT09     19

char ssid[] = "my-ssid";
char pass[] = "my-wifi-pwd";

int output_pins[] = {2,5,4,12,13,14,15,16,17,18,19};

BlynkTimer timer;

BLYNK_CONNECTED() {
   Blynk.syncAll();
}

BLYNK_WRITE(V0) {digitalWrite(OUT01, param.asInt());}
BLYNK_WRITE(V1) {digitalWrite(OUT02, param.asInt());}
BLYNK_WRITE(V2) {digitalWrite(OUT03, param.asInt());}
BLYNK_WRITE(V3) {digitalWrite(OUT04, param.asInt());}
BLYNK_WRITE(V4) {digitalWrite(OUT05, param.asInt());}
BLYNK_WRITE(V5) {digitalWrite(OUT06, param.asInt());}
BLYNK_WRITE(V6) {digitalWrite(OUT07, param.asInt());}
BLYNK_WRITE(V7) {digitalWrite(OUT08, param.asInt());}
BLYNK_WRITE(V8) {digitalWrite(OUT09, param.asInt());}

//switch all lights at once
BLYNK_WRITE(V9)
{
  for (int i = 2; i < 11; i++) {
    digitalWrite(output_pins[i], param.asInt());
    delay(100);
  }
}

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

  for (int i = 0; i < 11; i++) {
    pinMode(output_pins[i], OUTPUT);
    digitalWrite(output_pins[i], LOW);
    delay(100);
  }

  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}

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

so far I have mixed thopughts about this whole Blynk system.
Most of the time, my device is offline and the buttons no longer work.

[1982418] Connecting to blynk.cloud:8080
[1987419] Connecting to blynk.cloud:80
[1987419] Connecting to blynk.cloud:8080
[1992420] Connecting to blynk.cloud:80
[1992420] Connecting to blynk.cloud:8080
[1997421] Connecting to blynk.cloud:80
[1997421] Connecting to blynk.cloud:8080
[2002422] Connecting to blynk.cloud:80
[2002422] Connecting to blynk.cloud:8080
[2007423] Connecting to blynk.cloud:80
[2007423] Connecting to blynk.cloud:8080
                                                                oud:80
[2012424] Connecting to blynk.cloud:8080
[2017425] Connecting to blynk.cloud:80
[2017425] Connecting to blynk.cloud:8080
[2022426] Connecting to blynk.cloud:80
[2022426] Connecting to blynk.cloud:8080
[2027427] Connecting to blynk.cloud:80
[2027427] Connecting to blynk.cloud:8080

So was wondering maybe I might have selected a wron ESP32 core version?

And I see lot of answeres by you saying Not to use Blynk.begin(), but all of Examples uses it.

Either version of the ESP32 core should be fine in that case.

Your code is a bit weird, but nothing that should be causing the connection issues.

I’d try removing your ESP32 from the SSD circuitry and just powering it from a USB cable and seeing what happens

You should also synchronise your lights with the virtual buttons on startup with a B:YNK_CONNECTED() function, and also improve your BLYNK_WRITE() commands so that they mirror the switch widget status rather than just toggling.

BTW, when you post serial output please post it the same was as when you post code, not screenshots.

Pete.

Yes it is currently powered through USB. Solid State Relays are later in the project. For the pourpose of testing, I have connected the ESP outputs to LEDs through resistors.

Could you kindly eleoborate what is it that made you think like that? I’m a novice, so I am alwasy open for improments.

could you kindly eloborate this through a sample code?

understood.

Okay, but it would have been useful if you’d stated tgat, instead of saying…

You create aliases like OUT1, OUT2 etc for your pins…

but then don’t use them later…

which defeats the object of using aliases.

There are also two extra pins in this array, but no indication of what they’re used for.

Read the documentation for BLYNK_CONNECTED() and Blynk.virtualWrite() and it will all become clear.

Pete.

You are absolutely correct there. Apologies for your troubles sir.

Sorry, but I have.

BLYNK_WRITE(V0) {digitalWrite(OUT01, param.asInt());}
BLYNK_WRITE(V1) {digitalWrite(OUT02, param.asInt());}
BLYNK_WRITE(V2) {digitalWrite(OUT03, param.asInt());}
BLYNK_WRITE(V3) {digitalWrite(OUT04, param.asInt());}
BLYNK_WRITE(V4) {digitalWrite(OUT05, param.asInt());}
BLYNK_WRITE(V5) {digitalWrite(OUT06, param.asInt());}
BLYNK_WRITE(V6) {digitalWrite(OUT07, param.asInt());}
BLYNK_WRITE(V7) {digitalWrite(OUT08, param.asInt());}
BLYNK_WRITE(V8) {digitalWrite(OUT09, param.asInt());}

The array is used so that I do not have to write 11 lines of code to set the pin type and it default states. Furthermore, I have a button to switch all outputs onn/off. So having this array and switching the sates within a for loop I though is best.

for (int i = 0; i < 11; i++) {
    pinMode(output_pins[i], OUTPUT);
    digitalWrite(output_pins[i], LOW);
    delay(100);
  }
BLYNK_WRITE(V9)
{
  for (int i = 2; i < 11; i++) {
    digitalWrite(output_pins[i], param.asInt());
    delay(100);
  }
}

Aplogies for that, I had missed to put that on my initial post.
Those are 2 seperate output pins to indicate the Online status and void loop activity.

This is not my final project code, I’m still experimenting to get the basics of switching 9 outputs to work in a realiable way. So far my device keeps on showing as offline and due to that reason, mobile app inputs does not get reflected to my device.

1 Like

Do you mean to say I must call this function in the setup{} routine?

I have already implimented this function in my code above,

BLYNK_CONNECTED() {
   Blynk.syncAll();
}

You clearly aren’t that interested in my feedback on your code, despite saying…

Well written code should be able to be read and understood by anyone, without the need to refer to any external documentation.
The idea behind pin aliases is that you declare them once, at the start of your code, then use them at every point afterwards where you need to reference those pins. That way, if you decide to swap to using different pins, or swap to an entirely different device, you just update the list in one place.
You haven’t done that, because those pin numbers are re-used there, along with two additional ones which have no aliases and no in-code documentation relating to their purpose…

You should have used your aliases when defining this array of pins.

The use of

is a very bad approach. The syncAll command doesn’t synchronise all datastreams in Blynk IoT, it only synchronises those that have the “Sync with latest server value every time device connects to the cloud” option enabled. The command is only really included in Blynk IoT to provide Legacy compatibility, and its use isn’t recommended.
You should be syncing each datastream separately, either via multiple Blynk.suncVirtual(vPin) commands, or via a loop as you have elsewhere.

But, synchronising a pin only causes the corresponding BLYNK_WRITE(vPin) function to be called and the server sends the latest value for that datastream. Unless your code actually looks at that value and uses it, the Blynk.syncVirtual(vPin) will simply toggle the current state of your relays, so they won’t be synchronised, they’ll just be in the opposite state to what they were before.
You need to be using the param.asInt() value sent from the server to turn your corresponding relay on or off, nit simply toggle its value.

Pete.

Oh you understood me wrong sir, I am interested, and now I know what you meant. I am not like many, it takes a bit of time for me to GET what others are saying.
Thank you so much for pointing my mistakes and I will correct it in my code.

int output_pins[] = {StatusLed, WifiLed, OUT01, OUT02, OUT03, OUT04, OUT05, OUT06, OUT07, OUT08, OUT09};

@PeteKnight following code is not the whole source, but a part of the source.
it keeps on timming out.
what am I doing wrong here?

#define BLYNK_AUTH_TOKEN    "xx..."
#define BLYNK_SERVER        "blynk.cloud"
#define BLYNK_SERVER_PORT   443

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

  timer.setInterval(2000L, connectWiFi); 
  timer.setInterval(2000L, connectBlynk);
}

void loop()
{
  timer.run();
  if(Blynk.connected()) Blynk.run();
}

void connectBlynk() {
  if (WiFi.status() == WL_CONNECTED) {
    if (!Blynk.connected()) {
      Serial.println("Configuring Blynk...");
      Blynk.config(BLYNK_AUTH_TOKEN, BLYNK_SERVER, BLYNK_SERVER_PORT);
      Serial.println("Connecting to Blynk...");

      if (Blynk.connect()) {
        Serial.println("Connected to Blynk...");
      }
      else {
        Serial.println("Timmed out connecting to Blynk...");
      }
      // digitalWrite(StatusLed, HIGH);
    }
    else
    {
      Serial.println("Blynk is still connected...");
    }
  }
}
02:11:19.873 -> Configuring Blynk...
02:11:19.873 -> [474750] 
02:11:19.920 ->     ___  __          __
02:11:19.920 ->    / _ )/ /_ _____  / /__
02:11:19.920 ->   / _  / / // / _ \/  '_/
02:11:19.920 ->  /____/_/\_, /_//_/_/\_\
02:11:19.920 ->         /___/ v1.3.2 on ESP32
02:11:19.920 -> 
02:11:19.920 ->  #StandWithUkraine    https://bit.ly/swua
02:11:19.920 -> 
02:11:19.920 -> 
02:11:19.920 -> Connecting to Blynk...
02:11:19.920 -> [474772] Connecting to blynk.cloud:443
02:11:25.130 -> [479989] Connecting to blynk.cloud:443
02:11:30.261 -> [485109] Connecting to blynk.cloud:443
02:11:35.557 -> [490433] Connecting to blynk.cloud:443
02:11:37.907 -> Timmed out connecting to Blynk...
02:11:37.907 -> WiFi is still connected...
02:11:37.907 -> Configuring Blynk...
02:11:37.907 -> [492772] 
02:11:37.907 ->     ___  __          __
02:11:37.907 ->    / _ )/ /_ _____  / /__
02:11:37.907 ->   / _  / / // / _ \/  '_/
02:11:37.907 ->  /____/_/\_, /_//_/_/\_\
02:11:37.907 ->         /___/ v1.3.2 on ESP32
02:11:37.942 -> 
02:11:37.942 ->  #StandWithUkraine    https://bit.ly/swua
02:11:37.942 -> 
02:11:37.942 -> 
02:11:37.942 -> Connecting to Blynk...
02:11:37.942 -> [492794] Connecting to blynk.cloud:443
02:11:43.149 -> [498011] Connecting to blynk.cloud:443
02:11:48.485 -> [503336] Connecting to blynk.cloud:443
02:11:53.808 -> [508661] Connecting to blynk.cloud:443
02:11:55.943 -> Timmed out connecting to Blynk...
02:11:55.943 -> WiFi is still connected...

You don’t understand how to use Blynk.config(), and you’re not calling Blynk.connect().
Can’t advise further without seeing your full sketch.

Pete.

Could you please point me to a resource that explains how to use it?

what do yo mean? I am calling it.

okay full sketch below;

#define BLYNK_TEMPLATE_ID   "TEMPLATE_ID"
#define BLYNK_TEMPLATE_NAME "TEMPLATE_NAME"
#define BLYNK_AUTH_TOKEN    "xxxx...."
#define BLYNK_SERVER        "blynk.cloud"
#define BLYNK_SERVER_PORT   443

#define BLYNK_PRINT Serial

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

#define OUT01     4
#define OUT02     12
#define OUT03     13
#define OUT04     14
#define OUT05     15
#define OUT06     16
#define OUT07     17
#define OUT08     18
#define OUT09     19

#define StatusLed 5
#define WifiLed   2

char ssid[] = "ssid";
char pass[] = "password";

int output_pins[] = {StatusLed, WifiLed, OUT01, OUT02, OUT03, OUT04, OUT05, OUT06, OUT07, OUT08, OUT09};

BlynkTimer timer;

BLYNK_CONNECTED() {
 Serial.println("BLYNK_CONNECTED...");
}

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

 for (int i = 0; i < 11; i++) {
   pinMode(output_pins[i], OUTPUT);
   digitalWrite(output_pins[i], LOW);
   delay(100);
 }

 timer.setInterval(2000L, connectWiFi);
 timer.setInterval(2000L, connectBlynk);
}

void loop()
{
 timer.run();
 if(Blynk.connected()) Blynk.run();
}

void connectWiFi() {
 if (WiFi.status() != WL_CONNECTED) 
 {
   Serial.println("Connecting to WiFi...");

   WiFi.mode(WIFI_STA);
   WiFi.begin(ssid, pass);

   int waittime = 0;

   while (WiFi.status() != WL_CONNECTED) 
   {
     Serial.print("*");

     waittime += 1;

     if (waittime >= 15){
       Serial.println("");
       Serial.println("Connection Failed! Rebooting...");

       ESP.restart();
     }

     delay(900);
   }

   Serial.println("");
   Serial.println("WiFi connected");  
   Serial.println("IP address: ");
   Serial.println(WiFi.localIP());

   WiFi.setAutoReconnect(true);
 }
 else {
   Serial.println("WiFi is still connected...");  
 }
}

void connectBlynk() {
 if (WiFi.status() == WL_CONNECTED) {
   if (!Blynk.connected()) {
     Serial.println("Configuring Blynk...");
     Blynk.config(BLYNK_AUTH_TOKEN, BLYNK_SERVER, BLYNK_SERVER_PORT);
     Serial.println("Connecting to Blynk...");

     if (Blynk.connect()) {
       Serial.println("Connected to Blynk...");
     }
     else {
       Serial.println("Timmed out connecting to Blynk...");
     }
   }
   else
   {
     Serial.println("Blynk is still connected...");
   }
 }
}

Thank you Sir

This forum is your best resource, do a quick search and you’ll see some examples.

No, you’re using Blynk.connect() in an if statement instead of Blynk.connected(), but you aren’t commanding a connection to Blynk, and the way that your void loop functions you will never see the first occurrence of Blynk.run() to command that connection instead.

I really don’t understand why you’ve switched from Blynk.begin to Blynk.config and Blynk.connect().
The only reason to take this approach is to allow your device to continue functioning in offline mode if it can’t connect to either WiFi or the Blynk server.
But, your WiFi routine doesn’t allow for an offline scenario, and you have no physical buttons that could be use to control your lights if Blynk isn’t available.
You’ve just added much more complexity to your sketch, and started using an advanced feature that you clearly don’t understand, for no good reason

Pete.

Well, in several posts the forum, I’ve seen you adviced not to use Blynk.begin, and to manually manage the conetions.

Wrong, those are not my intensions.

Well, I do not know where to find helpful Blynk official documnetaton to read about these advanced features. That is why I’m here asking.

Yes, in situations where users want to have offline control of their hardware - via physical buttons - when
either WiFi, the Internet or the Blynk server is unreachable.
But you’ve said that…

so there’s no point in exploring the Blynk.config and Blynk.connect() functionality. You should revert to the Blynk.begin() functionality in your initial sketch.

Pete.

1 Like