Hi, currently using XAMPP to host a local database, accessed through 3 Arduino's, 2 of which are Uno WiFI V2 and one is Uno Ethernet. The Ethernet Arduino connects to the database with no issues and enters data to the database, though the WiFi version will not connect to the database itself.
/*
MySQL Connector/Arduino Example : connect by wifi using WiFi 101 shieldThis example demonstrates how to connect to a MySQL server from an
Arduino using using the new WiFi Shield 101 from arduino.cc.NOTICE NOTICE NOTICE
The new WiFi 101 library is quite large. You should use this sketch and the
shield with the new Arduino Due or Zero.You should also use the latest Arduino IDE from arduino.cc. This sketch was
tested with release 1.6.7 from https://www.arduino.cc/en/Main/Software
running on a Due board.Also, make sure your hardware libraries are uptodate by visiting the
boards manager and installing updates for the boards you are tying to use
(e.g. Due, Zero).INSTRUCTIONS FOR USE
- Change the address of the server to the IP address of the MySQL server
- Change the user and password to a valid MySQL user and password
- Change the SSID and pass to match your WiFi network
- Connect a USB cable to your Arduino
- Select the correct board and port
- Compile and upload the sketch to your Arduino
- Once uploaded, open Serial Monitor (use 115200 speed) and observe
If you do not see messages indicating you have a connection, refer to the
manual for troubleshooting tips. The most common issues are the server is
not accessible from the network or the user name and password is incorrect.Note: The MAC address can be anything so long as it is unique on your network.
Created by: Dr. Charles A. Bell
*/
#include <SPI.h>
#include <WiFiNINA.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server_addr(192,168,1,3); // IP of the MySQL server here
char user[] = "root"; // MySQL user login username
char password[] = "pass"; // MySQL user login password
int keyIndex = 0;
// WiFi card example
char ssid[] = ""; // your SSID
char pass[] = ""; // your SSID Password
int status = WL_IDLE_STATUS;
WiFiServer server(80);
WiFiClient client;
MySQL_Connection conn((Client *)&client);void setup() {
Serial.begin(115200);
while (!Serial); // wait for serial port to connect
delay(4000);
// 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)) {
delay(10000);
}
else
Serial.println("Connection failed.");}
void loop() {
}
The serial monitor shows that it connects to the WiFi network but will go no further, after trying to connect to the database, after a while it displays connection failed message.
Note this is code by Dr. Charles A. Bell and isn't my own but edited, any help or advice would be appreciated, as we wish to not use PHP, even though we understand the memory constraints on arduino