I am using the "connect_wifi" example from MySQL Connector Arduino library, it is using the WiFi.h header file instead of the Cytron ESPWiFi Shiled library. I cannot successfully connect the Wifi shield to the internet. Is it possible that the "WiFi.h" header file be used on Cytron ESPWiFi Shield? If not, can anyone help to provide the solution? Thank you very much.
*Attached is the link to the MySQL Connector Arduino library:
https://github.com/ChuckBell/MySQL_Connector_Arduino
Below shows the coding from the example: "connect_wifi" from MySQL Connector Arduino Library
- CODE: SELECT_ALL_CODE
#include <WiFi.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(10,0,1,35); // IP of the MySQL *server* here
char user[] = "root"; // MySQL user login username
char password[] = "1234"; // MySQL user login password
// WiFi card example
char ssid[] = "BatmanBB16"; // your SSID
char pass[] = "password"; // your SSID Password
WiFiClient client; // Use this for WiFi instead of EthernetClient
MySQL_Connection conn((Client *)&client);
void setup() {
Serial.begin(115200);
while (!Serial); // wait for serial port to connect. Needed for Leonardo only
// 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...");
if (conn.connect(server_addr, 3306, user, password)) {
delay(1000);
}
else
Serial.println("Connection failed.");
conn.close();
}
void loop() {
}