Connecting to MySQL database over eduroam (enterprise network)

Hi, I have a database hosted at " 138-38-181-187.eduroam.bath.ac.uk " that I would like to connect to with my Arduino MKR1000, in order to upload sensor readings into.

When I run the following code I connect to my personal WiFi but fail the connection to the database. I have a feeling that because of where the database is stored that I need to be connected to the Eduroam enterprise network.

After researching online I cannot find a way to connect the Arduino MKR1000 to an enterprise network. This is a problem I had in the past with a Rasperberry Pi but managed to solve by editing the /etc/network/interfaces file and /etc/wpa supplicant/wpa supplicant.conf file. Is there a similar solution for Arduino?

#include <SPI.h>
#include <WiFi101.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>

byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress server_addr(138,38,181,187);  // IP of the MySQL *server* here
char user[] = "my username";              // MySQL user login username
char password[] = "my password";        // MySQL user login password

// WiFi card example
char ssid[] = "my wifi ssid";    // your SSID
char pass[] = "wifi password";       // your SSID Password

WiFiClient client;
MySQL_Connection conn((Client *)&client);

void setup() {
  Serial.begin(9600);
  while (!Serial); // wait for serial port to connect

  // Begin WiFi section
  int status = WiFi.begin(ssid, pass);
  if ( status != WL_CONNECTED) {
    Serial.println("Couldn't get a wifi connection");
    while(true);
  }
  // print out info about the connection:
  else {
    Serial.println("Connected to network");
    IPAddress ip = WiFi.localIP();
    Serial.print("My IP address is: ");
    Serial.println(ip);
  }
  // End WiFi section

  Serial.println("Connecting to database...");
  if (conn.connect(server_addr, 3306, user, password)) {
    delay(1000);
  }
  else
    Serial.println("Connection failed.");
  conn.close();
}

void loop() {
}

Hi, using WIFInina Library you can do it.

check this
https://www.arduino.cc/en/Reference/WiFiNINABeginEnterprise

Thanks for the response Andrea. When I have tried using WiFiNINA I receive the following error as I do not think it supports MKR1000

/Users/edgrove/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp: In static member function 'static void SpiDrv::begin()':
/Users/edgrove/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp:97:15: error: 'NINA_GPIO0' was not declared in this scope
       pinMode(NINA_GPIO0, OUTPUT);
               ^~~~~~~~~~
/Users/edgrove/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp:97:15: note: suggested alternative: 'PIN_PB10'
       pinMode(NINA_GPIO0, OUTPUT);
               ^~~~~~~~~~
               PIN_PB10
/Users/edgrove/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp: In static member function 'static int SpiDrv::available()':
/Users/edgrove/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp:565:25: error: 'NINA_GPIO0' was not declared in this scope
     return (digitalRead(NINA_GPIO0) != LOW);
                         ^~~~~~~~~~
/Users/edgrove/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp:565:25: note: suggested alternative: 'PIN_PB10'
     return (digitalRead(NINA_GPIO0) != LOW);
                         ^~~~~~~~~~
                         PIN_PB10
exit status 1
Error compiling for board Arduino MKR1000.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

You’re correct that the WiFiNINA library is not compatible with the MKR1000. The WiFi101 library must be used for the MKR1000 but I don’t know whether it provides this functionality. According to this, no.

If you’re not set on using your MKR1000, there are some nice boards compatible with the WiFiNINA library, including the Nano 33 IoT and the MKR WiFi 1010.