Closed jcd420 closed 2 years ago
I need a wee bit more information. What isn’t working? Is there an error? What board are you using and what are you using the multi library?
On Sun, Jan 27, 2019 at 14:51 jcd420 notifications@github.com wrote:
what am I doing wrong?
include
include
include
ESP8266WiFiMulti WiFiMulti; WiFiClient client;
IPAddress server_addr(192, 168, 0, 103); // IP of the MySQL server here char user[] = "admin"; // MySQL user login username char password[] = "my123"; // MySQL user login password
MySQL_Connection conn((Client *)&client);
void setup() { Serial.begin(9600); // Open serial connection to report values to host Serial.println("Starting up"); delay(10);
// We start by connecting to a WiFi network WiFi.mode(WIFI_STA); WiFiMulti.addAP("JC", "1234abcd"); Serial.print("Wait for WiFi... "); while (WiFiMulti.run() != WL_CONNECTED) { Serial.print("."); delay(500); } Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP());
}
void loop() {
if (conn.connect(server_addr, 3306, user, password)) { delay(1000); Serial.println("Connection made :)");
} else Serial.println("Connection failed."); conn.close(); }
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/82, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0j4KjqIvAe5JA7tpFk9yfneBEymBEwks5vHgNBgaJpZM4aU5wH .
The board is ESP8266 NodeMCU Lua the erro I get is: Connection failed.
I am new to programming and I copied the scrip from another site. I will remove the multi.
i can connect from other computers to the SQL server. I can not connect to server. I connect to DHCP server and get an IP. Is there any other mistakes I make on my script?
I think that the WiFiMulti is need to get internet connection.
I did a script with out the Multi. but same error.
//#include
const char ssid = "JC"; const char password = "1234abcd";
IPAddress server_addr(192, 168, 0, 103); // IP of the MySQL server here char user[] = "admin"; // MySQL user login username char passwordSQL[] = "my123"; // MySQL user login password WiFiClient client;
MySQL_Connection conn((Client *)&client);
void setup() { Serial.begin(115200); delay(10);
// We start by connecting to a WiFi network
Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); }
Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP());
}
void loop() {
if (conn.connect(server_addr, 3306, user, passwordSQL)) { delay(1000); Serial.println("Connection made :)");
} else Serial.println("Connection failed."); conn.close(); }
Ok, I understand. First, you don't need the multi library. Second, to use a
library other than the included Arduino libraries, you must modify one of
the connector files. You must replace #include
the multi code, your sketch should be Ok. Look at other posts on the forum regarding ESP8266 for more hints and solutions. I don't use those boards very often because they're far too small for some of my projects, but I have tested (and used) the connector with several varieties of ESP boards for small projects.
On Sun, Jan 27, 2019 at 4:49 PM jcd420 notifications@github.com wrote:
I think that the WiFiMulti is need to get internet connection.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/82#issuecomment-457957486, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0j4DL2nnQcZY3kXG5li03_Xz3K77iNks5vHh7fgaJpZM4aU5wH .
I already did it: https://github.com/ChuckBell/MySQL_Connector_Arduino/compare/master...Bolukan:master I think it is a good guess for all ESP8266 users (using WiFi in stead of Ethernet) this is a good solution. I will change my code change to a conditional one and do a pull request.
Ok, and if everything is working correctly, we can close the issue.
On Mon, Jan 28, 2019 at 10:12 AM Bollie notifications@github.com wrote:
I already did it: master...Bolukan:master https://github.com/ChuckBell/MySQL_Connector_Arduino/compare/master...Bolukan:master I think it is a good guess for all ESP8266 users (using WiFi in stead of Ethernet) this is a good solution. I will change my code change to a conditional one and do a pull request.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/82#issuecomment-458169194, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0j4B-C6OT3pfYrruE_dkYw_YPImZW0ks5vHxNDgaJpZM4aU5wH .
I did it all and still same erro :( this is how the code look now
IPAddress server_addr(192, 168, 0, 103); // IP of the MySQL server here char user[] = "admin"; // MySQL user login username char password[] = "my123"; // MySQL user login password
WiFiClient client; MySQL_Connection conn((Client *)&client);
void setup() { //----------------wifi ---------------------------------- Serial.begin(115200); Serial.println(); WiFi.begin("JC", "1234abcd"); Serial.print("Connecting"); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(); Serial.print("Connected, IP address: "); Serial.println(WiFi.localIP()); //---------------------wifi-----------------------------------
Serial.println("Connecting..."); if (conn.connect(server_addr, 3306, user, password)) { delay(1000); } else Serial.println("Connection failed."); conn.close(); }
If you are getting a connection failed error, it is a good possibility either your board isn't connected to the right network (has no route to the server), or you can one or more of the common problems listed in the user's manual such as MySQL permissions issues, wrong IP address for the server, a firewall blocking port 3306, etc.
BTW, are you sure your server is listening on 192.168.0.103? Read the manual for more hints on how to diagnose connection issues.
What IP address is shown in the serial monitor for your board?
what am I doing wrong?
include
include
include
ESP8266WiFiMulti WiFiMulti; WiFiClient client;
IPAddress server_addr(192, 168, 0, 103); // IP of the MySQL server here char user[] = "admin"; // MySQL user login username char password[] = "my123"; // MySQL user login password
MySQL_Connection conn((Client *)&client);
void setup() { Serial.begin(9600); // Open serial connection to report values to host Serial.println("Starting up"); delay(10);
// We start by connecting to a WiFi network WiFi.mode(WIFI_STA); WiFiMulti.addAP("JC", "1234abcd"); Serial.print("Wait for WiFi... "); while (WiFiMulti.run() != WL_CONNECTED) { Serial.print("."); delay(500); } Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP());
}
void loop() {
if (conn.connect(server_addr, 3306, user, password)) { delay(1000); Serial.println("Connection made :)");
} else Serial.println("Connection failed."); conn.close(); }