Trying to communicate with a local host database using wamp and MySQL, failing to connect and unsure why, tried using ethernet too. If you require further details to help solve please ask, new to this. Thanks in advance.
#include <WiFiNINA.h> // Use this for WiFi instead of Ethernet.h
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>//byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server_addr(192,168,1,24); // IP of the MySQL server here
char user[] = "root"; // MySQL user login username
char password[] = ""; // MySQL user login password// WiFi card example
char ssid[] = ""; // your SSID
char pass[] = ""; // your SSID PasswordWiFiClient client; // Use this for WiFi instead of EthernetClient
MySQL_Connection conn((Client *)&client);void setup() {
Serial.begin(115200);// 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 sectionSerial.println("Connecting...");
if (conn.connect(server_addr, 3306, user, password)) {
Serial.println("Connected");
delay(1000);
}
else
Serial.println("Connection failed.");
conn.close();
}void loop() {
delay(2000);
Serial.println("Connected");
}