nodeMCU-32s not connecting to WiFi

Hey guys, i am really new to this and i got a kindle book (ESP32 Development using the Arduino IDE) and one of the example is trying to create a web server to flash an LED. My problem is that my board seems to not want to connect to my WiFi? I’m not really sure what to do here, anyone could help?

#include <Arduino.h>
#include <WiFi.h>

// Replace with your network credentials
const char* ssid     = "My_ssid";
const char* password = "My_password";

WiFiServer server(80);

const int led =  32;      // the number of the LED pin

// Client variables 
char linebuf[80];
int charcount=0;

void setup() 
{
  // initialize the LED as an output:
  pinMode(led, OUTPUT);
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while(!Serial) {
  }
  
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  
  // WiFi.config(router_ip);
  WiFi.begin(ssid, password);
  
  // attempt to connect to Wifi network:
  while(WiFi.status() != WL_CONNECTED) 
  {
    // Connect to WPA/WPA2 network.
    delay(2000);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP()); 
  server.begin();
}

On the monitor it just shows “Connecting to: ssid” with the dots at the bottom from the delay of the “// Connect to WPA/WPA2 network.” I’ve replace the My_ssid, My_password and router_ip with my own.

Thank you in advance!

Can you instead of Serial.print("."); do

Serial.println("Connecting.. status: " + String(WiFi.status()));

to see what the status is?

1 Like

This is what i get from my monitor:

Connecting to Party_799
Connecting.. status: 6
Connecting.. status: 1
Connecting.. status: 1
Connecting.. status: 1
Connecting.. status: 1
Connecting.. status: 1
Connecting.. status: 1
Connecting.. status: 1
Connecting.. status: 1
Connecting.. status: 1

According to

6 = Disconnected (initially ok) and then to “No SSID Available”.

Your ESP32 doesn’t seem to see the WiFi network you’re trying to connect to. Maybe it has bad reception at that place, the antenna is too weak or broken.

Can you run the following sketch to verify that your WiFi is beeing seen? You might want to change the Serial.begin(115200); to 9600 for the same baud rate as your last sketch.

It prints the line Setup done?

Yes, at the end of setup(). Then it should print scan start and after a short while the networks should be listed. No output? Have you change it to 9600 baud? (or add monitor_speed = 115200 if you use 115200 as in the original sketch).

Exactly it prints nothing! But does my ssid have to bee the original of my WiFi or just the name of the WiFi that appears when i connect to it lets say on my phone? and yeah i’ve set it to the 9600.

Are these not the same? The router should advertise its WiFi network always under the same name (=SSID).

Were there any errors uploading? Pressing the reset button on the board has no effect? Trying a different baud rate neither? There has to be atleast some output from the bootloader after reset at 115200 baud. For my board the sketch works with the platformio.ini

[env:esp32]
board = esp32doit-devkit-v1
framework = arduino
platform = espressif32
monitor_speed = 115200

with output after pressing the reset button

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_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
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5828
entry 0x400806ac
Setup done
scan start
scan done
13 networks found
1: You shall not pass (-40)*
[...]

Nothing happened, I tried in a new projet just to put the setup(), changed the monitor_speed = 115200 and this is the output on my monitor:

18,len:4
lo���fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5828
entry 0x400806ac
Setup done

If you just copied the setup() then this is correct because the WiFi networks are printed in the loop() function of the sketch.

There does seem to be some UART corruption going on though. Can you try another USB cable and use the USB port directly on your computer, not through a USB hub or anything?

Oh that might be the problem then, good ole apple doesn’t seem to want to make it easy on us so i have to use a usb-c adaptor to put in a usb to micro-usb in order to plug in my device. I even tried it in the arduino IDE and still nothing.

Usually seeing corruption like ��� points to a power supply issue, like a bad or long USB cable with high losses or the source (like a USB hub) not being able to provide the peak current when the ESP32 turns on its WiFi radio… But if you’re already plugged into your computer’s main USB port (and especially it’s Type-C so it can power quite a bit…) that doesn’t seem likely… Maybe just a different microUSB cable helps?

At least the output is consistent with Arduino IDE here :sweat_smile:

1 Like

Yeah i’ve tried the only two other cables that i have to plug into this:
MUF82
and it’s still giving me nothing. I’ll try to order a usb-c to micro-usb and see if it still does the same thing. Anyway, thank you very much for you time! It is really appreciated :slight_smile:

Hi Philpep54,
just as I made this mistake: Did you see that the code in this thread is truncated and you have to get the complete code from

hth,
Karl

2 Likes

Yes i realised it in another post i made after that, my esp32 has since been connecting to the internet! It was a silly mistake from me ahah! But thank you for the response!

1 Like

Hi there, My esp32 couldn’t also connect to my modem.
After debugging I noticed i was using the WiFi esp3866 library instead of the esp32 library.
After changing to the correct library; Everything worked!
I hope that I have helped.

1 Like

I basically have the same problem. I have a node MCU 32 that I cannot get to connect to Wi-Fi. I used the sample code above and all I get is a number one status. I ran a different set of code that displays all of the Wi-Fi networks and the one I need to connect to is listed so I know the board can see him. I have the correct password but I can’t connect.

From what i remember i had an issue with my wifi not connecting because the network was 5ghz and not 2.4ghz. This makes a difference since the esp32 can only connect to 2.4

I checked that. The ssid is for the 2.4G. I logged into it on my laptop and checked the wifi settings. It says I’m on the 2.4G.