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("
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");
}
}