SSL root certificates causing board to not connect to WiFi

I am in the process of trying to send an email using my Arduino WiFi Rev2, I added the google.com and gmail.com domains to the SSL root certificates because the previous errors I would get would be that it could not connect to the server. Once I run the FirmwareUpdater and upload the certificates, it stops being able to connect to the WiFi and never breaks out of this loop.

 while(wifi_status != WL_CONNECTED){ // Checks infinitely for connection until one is reached then breaks out of the loop
    Serial.print("Connecting to SSID: "); Serial.println(ssid);

    wifi_status = WiFi.begin(ssid, pass);
    delay(10000); // Delays for 10 seconds
    if(wifi_status != WL_CONNECTED){
      Serial.println("Incorrect SSID or password"); // Returns message if SSID or password is wrong
    }
  }
  Serial.println("Network Connection Established"); // Gotten through loop meaning it is connected

Code I was using to send an email using the EMailSender library that produced an error before adding SSL root certificates.

  EMailSender emailSend(sendingEmail, sendingPass);
  EMailSender::EMailMessage message;
  message.subject = "Subject Test";
  message.message = "Test message";
  Serial.println(message.subject); Serial.println(message.message);
  EMailSender::Response resp = emailSend.send(receiveEmail, message);

  Serial.println("Sending status: ");
  Serial.println(resp.code);
  Serial.println(resp.desc);
  Serial.println(resp.status);

What is the WiFi Status when it is NOT WL_CONNECTED? That might lead you to an explanation of why it is failing.

It is set to WL_IDLE_STATUS when it is declared.

What value does it have after this?
wifi_status = WiFi.begin(ssid, pass);

What happens if you use File -> Examples -> RETIRED -> WiFi -> ConnectWithWPA and put in your SSID and Password? Does it connect successfully? If not, maybe you are using the wrong WiFi library for your hardware.

After modifying the code, shown below, to print the value of wifi_status to the serial monitor it displays a value of 4 after printing the SSID.

while(wifi_status != WL_CONNECTED){ // Checks infinitely for connection until one is reached then breaks out of the loop
    Serial.print("Connecting to SSID: "); Serial.println(ssid);

    wifi_status = WiFi.begin(ssid, pass);
    Serial.println(wifi_status);
    delay(10000); // Delays for 10 seconds
    if(wifi_status != WL_CONNECTED){
      Serial.println("Incorrect SSID or password"); // Returns message if SSID or password is wrong
    }
  }
  Serial.println("Network Connection Established"); // Gotten through loop meaning it is connected

When I upload the ConnectWithWPA file after adding my SSID and password nothing prints to the serial monitor.

Looks like that means WL_CONNECT_FAILED.

255 = WL_NO_SHIELD
0 = WL_IDLE_STATUS
1 = WL_NO_SSID_AVAIL
2 = WL_SCAN_COMPLETED
3 = WL_CONNECTED
4 = WL_CONNECT_FAILED
5 = WL_CONNECTION_LOST
6 = WL_DISCONNECTED

That seems to mean that it couldn't establish a connection.

Is your Serial Monitor set to 9600 baud? Did you try pressing Reset? If you don't get the "WiFi shield not present" error then you should get at least one "Attempting to connect to WPA SSID: " message.

Weird... There is a WiFi.init() function that calls WiFiDrv::wifiDriverInit() which calls SpiDrv::begin() which calls SPI.begin() but nobody seems to call WiFi.init()!

Try putting WiFi.init() in your setup().

Yes, it is set to 9600 baud, I also tried pressing Reset. Trying the ConnectWithWPA file in Files -> Examples -> WiFiNINA -> ConnectWithWPA ended up working and connecting to the WiFi. I try putting WiFi.init() in my setup and it returns. I should add I am currently using the WiFiNINA library.

Email_Test:36:8: error: 'static void WiFiClass::init()' is private within this context
   WiFi.init();
        ^~~~

Serial.begin(9600);
  while(!Serial){
    ;
  }

  WiFi.init();
  
  //Connecting to WiFi Code. Can be commented out if not needed or else it will not get to the code
  while(wifi_status != WL_CONNECTED){ // Checks infinitely for connection until one is reached then breaks out of the loop
    Serial.print("Connecting to SSID: "); Serial.println(ssid);

    wifi_status = WiFi.begin(ssid, pass);
    Serial.println(wifi_status);
    
    delay(10000); // Delays for 10 seconds
    if(wifi_status != WL_CONNECTED){
      Serial.println("Incorrect SSID or password"); // Returns message if SSID or password is wrong
    }
  }
  Serial.println("Network Connection Established"); // Gotten through loop meaning it is connected

So it sounds like you had been using the wrong library for your hardware. No wonder it wasn't working a expected.

I have been using the WiFiNINA library this whole time

Sorry, I am not familiar with your hardware and made a wrong assumption about what WiFi library you were using.

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