MySQL Forums
Forum List  »  Connector/Arduino

Re: MySQL_Connector with Realtek Ameba WIFI
Posted by: L Prong
Date: May 20, 2019 01:05PM

Thanks for your assistance Chuck. Here is your Connect_wifi example with my parameters:

#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 (192,168,2,43); // this is the IP address of my PC with MySQL on it. I initially tried 127,0,0,1 but that always failed to connect.
char user[] = "LP"; // MySQL user login username
char password[] = "mypassword"; // MySQL user login password
char ssid[] = "BELL148"; // your SSID
char pass[] = "mywifipassward"; // your SSID Password

WiFiClient client; // Use this for WiFi instead of EthernetClient
MySQL_Connection conn((Client *)&client);
//MySQL_Cursor cur = MySQL_Cursor(&conn);

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

I'm running MySQL V8.0.16. The user "LP" has Standard authentication. I discovered that MySQL is logging Aborted Connections with this error:
IP address '192.168.2.56' could not be resolved: No such host is known.
This is the IP address my router assigns the Realtek board.

On the MySQL Workbench it shows the connection for 10 seconds or so, but the user and host are "None".

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: MySQL_Connector with Realtek Ameba WIFI
642
May 20, 2019 01:05PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.