UNO R4 WIFI - Attempting to connect to SSID

Hi all

I bought an Arduino UNO R4 WIFI and I can't manage to connect the board to my home wifi network.
I used the code I found on the documentation on the arduino website:


#include <WiFiS3.h>

#include "arduino_secrets.h" 

char ssid[] = SECRET_SSID;        // your network SSID (name)
char pass[] = SECRET_PASS;    // your network password (use for WPA, or use as key for WEP)
int status = WL_IDLE_STATUS;     // the WiFi radio's status

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }

  String fv = WiFi.firmwareVersion();
  if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
    Serial.println("Please upgrade the firmware");
  }

  // attempt to connect to WiFi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }

  // you're connected now, so print out the data:
  Serial.print("You're connected to the network");
  printCurrentNet();
  printWifiData();

}

void loop() {
  // check the network connection once every 10 seconds:
  delay(10000);
  printCurrentNet();
}

void printWifiData() {
  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  
  Serial.println(ip);

  // print your MAC address:
  byte mac[6];
  WiFi.macAddress(mac);
  Serial.print("MAC address: ");
  printMacAddress(mac);
}

void printCurrentNet() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print the MAC address of the router you're attached to:
  byte bssid[6];
  WiFi.BSSID(bssid);
  Serial.print("BSSID: ");
  printMacAddress(bssid);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.println(rssi);

  // print the encryption type:
  byte encryption = WiFi.encryptionType();
  Serial.print("Encryption Type:");
  Serial.println(encryption, HEX);
  Serial.println();
}

void printMacAddress(byte mac[]) {
  for (int i = 0; i < 6; i++) {
    if (i > 0) {
      Serial.print(":");
    }
    if (mac[i] < 16) {
      Serial.print("0");
    }
    Serial.print(mac[i], HEX);
  }
  Serial.println();
}

When I run this bit of code, I've got the message "attempting to connect to SSID" endlessly.

I can't find where there's a problem (if I run a network scan, my home network is detected). Do you have any solution, please?

Thanks

Do you have MAC filtering on your router?

try to run the ScanNetworks example

Did you update your home network information in arduino_secrets.h ?

Not to my knowledge. Each new device we've bought can be connected to our internet box.

We've done that and it works. Found 2 networks including the one declared in the secrets file.

yes we did that and we search for quite a long time to know where to save this file :wink: We put it in the directory with the .ino file

The fact that the filename is enclosed in quotation marks indicates that the compiler will look for it first in the same folder as the .ino file before looking in the standard library locations

If the filename were in angle brackets the local folder would not be searched for the file

Hmm. Turning on MAC filtering was the only way I managed to get the sample code not to connect.

OK. thanks for the explanation. That's what we've done so it doesn't explain that the connection doesn't go through

Check the spelling and capitalisation of the SSID and password very carefully

Temporarily print both in the sketch so that you know exactly what is being tried

Hello guys. R4 is not capable of 5G wifi. Please check if your wifi is set to 2.4G channels :slight_smile:

@jeemzzfancier that is why I asked to run ScanNetwokrs example

that's it

If it found my network when I ran ScanNetwork, it means that it should be able to connect. there's no Wifi incompatibility ?
actually, my internet box is so old, there's no way it does 5G wifi! :wink:

btw it is 5 GHz, not fifth generation

Thx, I thought it was weird 5G Wifi. Just checked and it's 2.4GHz

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