WiFi Not Working When Arduino nano RP2040 connect is Powered via 5V Adapter

Hello,

I am working on reading voltage data from the A0 pin of my Arduino RP2040. When the board is connected to my laptop via USB (COM port), it successfully connects to my WiFi network, and I can read the A0 values.

However, since my main goal is to get A0 data over WiFi without a USB connection, I tried powering the Arduino with a 5V adapter. In this case, the WiFi connection does not work.

Could anyone please help me understand why this is happening and how I can solve this issue?

I have attached my code for reference.

Thank you!

#include <WiFiNINA.h> // Use WiFiNINA for Arduino with WiFi module

// Replace with your WiFi credentials
const char* ssid = "MY WIFI ID";
const char* password = "MY WIFI PASSWARD";

WiFiServer server(80); // Create a web server on port 80

void setup() {
Serial.begin(115200);
while (!Serial); // Wait for Serial Monitor to open

Serial.println("Connecting to WiFi...");
WiFi.begin(ssid, password);

// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}

Serial.println("\nāœ… Connected to WiFi!");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP()); // Print IP address to connect

server.begin(); // Start the web server
}

void loop() {
WiFiClient client = server.available(); // Check for incoming clients

if (client) {
Serial.println(":globe_with_meridians: New Client Connected!");

// Send HTTP Response
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("<html><head><title>Arduino Web Server</title></head>");
client.println("<body><h1>EMF Sensor Data</h1>");

int emfValue = analogRead(A0);  // Read from analog pin A0
client.println("<p>EMF Value: " + String(emfValue) + "</p>");
client.println("</body></html>");

delay(500);
client.stop();  // Close connection
Serial.println("Client Disconnected");

}
}

It's because of --
while (! Serial)
Make it subject to timeout or some number of attempts.

1 Like

As @anon85221860 suggested, something like:

while(!Serial && millis() < 5000);

will work for you. You can adjust the millisecond value accordingly. As a side note, always post your code in code tags. See this https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966#posting-code

1 Like

Thank you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.