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() {
}