BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

ESP32 doesn't connect to wifi

Hi I am struggling a lot with just getting started, seems dumb but I tried the quick start several times and can not get my esp32 to connect to wifi router.
Below is the code copied and pasted from quckstart link with the exception of adding my wifi network and password. That’s it , nothing more. What am I doing wrong here.
I have a ESP32 Dev board and using latest Arduino IDE, have uploaded Blynk library for wifi.
Serial monitor shows

��%�a%�%�x�b���1344

load:0x40078000,len:13864

load:0x40080400,len:3608

entry 0x400805f0

[23] Connecting to Optus_616E3B

ets Jun 8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

configsip: 0, SPIWP:0xee

clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

/*************************************************************

  This is a simple demo of sending and receiving some data.
  Be sure to check out other examples!
 *************************************************************/

// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID           "TMPLRfo6Wj-B"
#define BLYNK_DEVICE_NAME           "Quickstart Device"
#define BLYNK_AUTH_TOKEN            "baZiDYca9lMoUJCYyWqfQizDJtLX1k-i"


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


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

char auth[] = BLYNK_AUTH_TOKEN;

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Optus_616E3B";
char pass[] = "hills56236ya";

BlynkTimer timer;

// This function is called every time the Virtual Pin 0 state changes
BLYNK_WRITE(V0)
{
  // Set incoming value from pin V0 to a variable
  int value = param.asInt();

  // Update state
  Blynk.virtualWrite(V1, value);
}

// This function is called every time the device is connected to the Blynk.Cloud
BLYNK_CONNECTED()
{
  // Change Web Link Button message to "Congratulations!"
  Blynk.setProperty(V3, "offImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");
  Blynk.setProperty(V3, "onImageUrl",  "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.png");
  Blynk.setProperty(V3, "url", "https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/how-quickstart-device-was-made");
}

// This function sends Arduino's uptime every second to Virtual Pin 2.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V2, millis() / 1000);
}

void setup()
{
  // Debug console
  Serial.begin(115200);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  Blynk.run();
  timer.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}```

![image|690x384](upload://t2PLoMzBqYRTM6mhWP9Qer7klkP.png)

How is your board powered ? Is it capable to supply the current that your esp32 needs ?

Are there any sensor or external device attached to the GPIO’s?

Are you sure your SSID & PASS are correct?

Hi Madhukesh,
The board is connected straight to my laptop vis USB cable, no sensors, I’m just starting out with the ESP32 .
I am absolutely sure about SSID & Password

Cheers

It looks like the USB port is not supplying enough power. I may be totally wrong.

Try powering up the module with an external power supply.

If you have a spare module try uploading the same code n see if the problem still occurs. Sometimes these dev modules can go bad.

Hi Madhukesh, the board is brand new, I ran a blinking LED sketch on the esp32 to the GPIO pin 32 and it worked well no issues powered by my laptop with same cord. Just can’t seem to get wifi connected, I don’t have a 3.3v external power supply except mobile phone chargers. I don’t have a spare module either.
Cheers

Use your mobile phone charger

The WiFi module on the ESP32 consumes a lot of power, so it’s entirely plausible that you can run a non-WiFi sketch without any problems, but when you fire-up the WiFi module the device reboots because it’s not getting enough power.

Poor quality USB cables are usually the culprit, but swapping to a different USB port on your computer may also help.

I don’t think anyone has suggested so far that you power the ESP32 via the 3.3v pin.
The simplest way to power the board it to plug it into a suitable 5v USB charger with a good quality cable. You won’t be able to see the serial output this way, but if the device shows as being online in Blynk then you’ve proved it was a power issue.

Pete.

Hi Pete, the reason I said I don’t have external 3.3v power supply is cause I thought esp32 could only take 3.3v, I had in my mind a proper adjustable power supply, I only use the usb for power never a GPIO pin as I’m too new to this stuff.
I tried a phone charger but how do I test it is connected to wifi with out a serial monitor display? Do I have to make a circuit ? I look on the app and I see 2x Quick start Devices, both show off line as their status. I’ve tried 5 different usb cables and with these cables I can upload a sketch to esp 32 so I don’t understand that it would be a dodgy usb cable.

Cheers

The USB port of your laptop outputs 5v. The ESP32 has an onboard 5v to 3.3v regulator, so it is designed to receive 5v via the micro USB port on the board.

And that is EXACTLY what we want you to do - just a different USB power source and a different et USB cable.

I covered that already…

Once again, I’ve explained…

You seem to be reading the suggestions from people and interpreting them in a different way to how they were intended, or simply not taking on board information that is being provided to you.

Try taking a step back and re-reading the whole topic from start to finish, then taking a structured approach to testing so that you can eliminate the power supply as a potential issue.

Pete.

1 Like

Hi Pete, sorry if it seems if my interpretation of peoples answers to my questions is different to what they intend, I have used a 1A 5v phone charger, 5x different usb cords and on the Blynk app the “Quickstart Device” that was created shows “offline” .
If I can upload a sketch with each of these cables then I fail to see how these cables would restrict power supply to ESP Board.
Have re read topic a couple of times now, Have tested each cable,laptop and phone charger. Would power supply be still an issue?

Cheers

Ok ok. Forget about blynk for now.
Go to your examples in your arduino ide and open a sketch with wifi
Like ESP32 WiFi or something like that.

Open the sketch

Fill in your router’s credentials and upload the code.

See what your serial monitor shows.

I’ve explained that twice already, so I’ll take a step back from this discussion and leave you to it.

Good luck.

Pete.

I completely understand how utterly frustrating this can be. This specific issue nearly made me give up using ESP32s. I verified cables, checked adapter specs against ESP requirements.

Pretty much as a rule - when an ESP32 attempts to connect to wifi, but ends up rebooting, it is a power issue. Yep, you can do anything else. Blink away, upload sketches, monitor the serial port etc. All of that just means its most likely a power supply issue.

My old iphone 5v/1A adapter should have worked perfectly. But it doesn’t. It’s optimized to charge phone batteries, not instantaneously respond to current changes. It doesn’t have a lot of capacity, so when current requirements change there’s a lag as it pulls AC to convert.

As Pete said, when WIFI turns on and tries to connect, the ESP starts pulling a LOT of current. This is where having extra power available helps. When the ESP turns on wifi, if the current isn’t there it just reboots. It doesn’t try again or wait around for your adapter. It just reboots.

The cables working to download a sketch only mean that you have a data cable. It means nothing about how much power that cable can transfer.

Are you using ‘full size’ board? If you’re using a mini ESP32 - pretty much all of the ones for sale now (Dorhea, Aitrip, Aceirmc) outside of the S2 were made with a 300ma regulator and can’t connect to wifi.

-Mike

Hi Mike, I double checked the sketch to ensure I had the correct wifi credentials, then I tried what you suggested, I bought a new usb cable that says it can take 2a fast charge, coupled this to a 1amp phone charger and then changed to a 2amp phone charger and in every occasion no wifi, the devices show “off line” . At each stage of trying different cords and chargers I would try one thing leave for a couple of minutes then press the reset button then check again if device is on line…nothing. I can’t show a serial monitor but I attached pics of the cable - I’ll try what Madhukesn suggested shortly
IMG_20220802_190739 IMG_20220802_190725 IMG_20220802_185510Screenshot_20220802_191453_cloud.blynk

Hi Madhukesh, I have tried what you suggested. I uploaded this sketch, pressed the boot button and looked at serial monitor. All I get from the serial monitor is dots across the page, even for several minutes. I have esp32 connected to my laptop with a 2a capable charge cord. Thoughts? Do I have a dud board or is still power supply? I have tried 2a phone charger with 2a capable cord using the Blynk Wifi sketch which didn’t work

/*

 WiFi Web Server LED Blink

 A simple web server that lets you blink an LED via the web.

 This sketch will print the IP address of your WiFi Shield (once connected)

 to the Serial monitor. From there, you can open that address in a web browser

 to turn on and off the LED on pin 5.

 If the IP address of your shield is yourAddress:

 http://yourAddress/H turns the LED on

 http://yourAddress/L turns it off

 This example is written for a network using WPA2 encryption. For insecure

 WEP or WPA, change the Wifi.begin() call and use Wifi.setMinSecurity() accordingly.

 Circuit:

 * WiFi shield attached

 * LED attached to pin 5

 created for arduino 25 Nov 2012

 by Tom Igoe

ported for sparkfun esp32

31.01.2017 by Jan Hendrik Berlin

 

 */

#include <WiFi.h>

const char* ssid     = "Optus_616E3B";

const char* password = "hills56236ya";

WiFiServer server(80);

void setup()

{

    Serial.begin(115200);

    pinMode(5, OUTPUT);      // set the LED pin mode

    delay(10);

    // We start by connecting to a WiFi network

    Serial.println();

    Serial.println();

    Serial.print("Connecting to ");

    Serial.println(ssid);

    WiFi.begin(ssid, password);

    while (WiFi.status() != WL_CONNECTED) {

        delay(500);

        Serial.print(".");

    }

    Serial.println("");

    Serial.println("WiFi connected.");

    Serial.println("IP address: ");

    Serial.println(WiFi.localIP());

   

    server.begin();

}

int value = 0;

void loop(){

 WiFiClient client = server.available();   // listen for incoming clients

  if (client) {                             // if you get a client,

    Serial.println("New Client.");           // print a message out the serial port

    String currentLine = "";                // make a String to hold incoming data from the client

    while (client.connected()) {            // loop while the client's connected

      if (client.available()) {             // if there's bytes to read from the client,

        char c = client.read();             // read a byte, then

        Serial.write(c);                    // print it out the serial monitor

        if (c == '\n') {                    // if the byte is a newline character

          // if the current line is blank, you got two newline characters in a row.

          // that's the end of the client HTTP request, so send a response:

          if (currentLine.length() == 0) {

            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)

            // and a content-type so the client knows what's coming, then a blank line:

            client.println("HTTP/1.1 200 OK");

            client.println("Content-type:text/html");

            client.println();

            // the content of the HTTP response follows the header:

            client.print("Click <a href=\"/H\">here</a> to turn the LED on pin 5 on.<br>");

            client.print("Click <a href=\"/L\">here</a> to turn the LED on pin 5 off.<br>");

            // The HTTP response ends with another blank line:

            client.println();

            // break out of the while loop:

            break;

          } else {    // if you got a newline, then clear currentLine:

            currentLine = "";

          }

        } else if (c != '\r') {  // if you got anything else but a carriage return character,

          currentLine += c;      // add it to the end of the currentLine

        }

        // Check to see if the client request was "GET /H" or "GET /L":

        if (currentLine.endsWith("GET /H")) {

          digitalWrite(5, HIGH);               // GET /H turns the LED on

        }

        if (currentLine.endsWith("GET /L")) {

          digitalWrite(5, LOW);                // GET /L turns the LED off

        }

      }

    }

    // close the connection:

    client.stop();

    Serial.println("Client Disconnected.");

  }

}

Hi Mike, this is my board , think it’s a full size esp32 dev board. Isn’t it?


Are you trying to connect to a 2.4GHz network?

Try removing the board from the breadboard and having nothing connected to it other than the USB cable.

Oh, and please don’t paste screenshots of code or serial output. Copy the text and paste it between triple backticks.

Pete.

Hi Pete, I thought I had an ah ha moment for a sec, my SSID is a 5Ghz network sorry I didn’t realise, I switched network to the 2.4 Ghz and retried the below Blynk sketch. From the lap top and new cable - no go, I then connected the board (off bread board) to a phone charger and rechecked the Bylnk app and still devices are “off line”.
I have tried other wifi sketches from Arduino ESP32 library and no luck with that either, no wifi connection.
I know I’m doing something wrong here but what?

Sorry about sketch being screen shotted.

/*************************************************************

  This is a simple demo of sending and receiving some data.
  Be sure to check out other examples!
 *************************************************************/

// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID "TMPLQPQz8rzC"
#define BLYNK_DEVICE_NAME "Quickstart Template"
#define BLYNK_AUTH_TOKEN "ROm1XzZNz8BMEEFeWQN4LA0JD2FRJ6g8"


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


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

char auth[] = BLYNK_AUTH_TOKEN;

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "It Burns When IP";
char pass[] = "hills56236ya";

BlynkTimer timer;

// This function is called every time the Virtual Pin 0 state changes
BLYNK_WRITE(V0)
{
  // Set incoming value from pin V0 to a variable
  int value = param.asInt();

  // Update state
  Blynk.virtualWrite(V1, value);
}

// This function is called every time the device is connected to the Blynk.Cloud
BLYNK_CONNECTED()
{
  // Change Web Link Button message to "Congratulations!"
  Blynk.setProperty(V3, "offImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");
  Blynk.setProperty(V3, "onImageUrl",  "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.png");
  Blynk.setProperty(V3, "url", "https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/how-quickstart-device-was-made");
}

// This function sends Arduino's uptime every second to Virtual Pin 2.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V2, millis() / 1000);
}

void setup()
{
  // Debug console
  Serial.begin(115200);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  Blynk.run();
  timer.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}
���H}B����Xlen:1344
load:0x40078000,len:13864
load:0x40080400,len:3608
entry 0x400805f0
[23] Connecting to It Burns When IP

Hi I have now realised I was using a 5Ghz network, I switched to a 2 Ghz network but no luck with other arduino sketches either.

Your dev module is the culprit. Buy a new one.