I’m still fairly new to esp but I’ve read through every relevant source on the subject and can’t get it work, I’ve tried 3 of my boards and some seem to work better than others but still not really. I don’t get any errors and my serial monitor and RGB works as a wifi status indicator, but it rarely connects, I just get WL_Disconnected (6).
To drive the on board rgb led, no external library is needed!
Remove that library and use the builtin function neopixelWrite() (Arduino 2.x) or rgbLedWrite() (Arduino 3.x)
I have 3, when first testing the 2 that I didn’t solder the rgb seemed to have more success so I thought it might be a power draw issue as mentioned other forums where they are powering servos but you’re right, it doesn’t seem to be that.
You could turn things around and operate the ESP as an access point. You can then use your smartphone to display the RSSI strength of the access point and try to connect to the ESP…
I dont have much undertanding of the .ini is there something in there that could be an issue or maybe the board selected? Im still using the same one as mentioned above
I GOT IT, thanks to an amazon customer review that suggested (though counterintuitive) reducing the wifi transmission power. That was all that was needed; now it connects instantly. Code below:
#include <Arduino.h>
#include <esp_wifi.h>
#include <WiFi.h>
const char* WIFI_SSID = "SSID";
const char* WIFI_PASSWORD = "Pass";
void setupWiFi() {
Serial.print("Connecting Wifi");
WiFi.mode(WIFI_STA);
// Set max TX power to 40 (~20 dBm)
esp_wifi_set_max_tx_power(40);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
neopixelWrite(RGB_BUILTIN, 0, 0, 255); // Blue blink to show connecting
delay(100);
neopixelWrite(RGB_BUILTIN, 0, 0, 0); // Off
delay(100);
}
Serial.println("\nConnected!");
neopixelWrite(RGB_BUILTIN, 0, 255, 0);
Serial.print("IP: ");
Serial.println(WiFi.localIP());
}
void setup() {
Serial.begin(115200);
setupWiFi();
}
void loop() {
// You can add code here to do something after connecting
}
Also for future readers, one customer comment said to “never use the usbc marked COM” and to use the usb for RTOS maked usb, I don’t know how to make that one work wit the serial monitor, I used the COM one just fine.
I am glad you found the solution. Just wondering whats going on.Looks like your boards are of poor quality. I had similar issues with a ESP32-S3 fake module where the PCB antenna was of poor quality.
I remember there is a way to fix the antenna by soldering a short piece of wire to a specific point.
Mate. I’m trying the same thing but failing miserably. You lost me here though. In the WiFi.h library that I have there’s no option for esp_wifi_set_max_tx_power. I only see WiFi.setTxPower which uses an enum instead of an integer as a parameter. Also, in your last example you’re using an esp_wifi.h library that wasn’t there before… where did that come from? Any help will much appreciated. Thanks