WiFiESP (used with ESP8266) working with MySQL_Connector_Arduino problem

hi to all,

i made some quick searches and i didn’t found any similar post, so i added one by myself.
here is my problem :

i recently bought on amazon an ESP8266 to connect with my arduino mega2560 and i want to build a datalogger that directly stores data on my MySQL database running on a raspberry pi.

i think this application can be very interesting because allows small standalone arduino projects to interface with databases.

i made the ESP8266 to connect to my wifi network using the WiFiESP library.

after this i have modified one example of the MySQL_connector_arduino library to fit with the WiFiESP library, in poor words i tried to substitute the Ethernet library and create a client with the WIFiESP.
here is my code:

#include "WiFiEsp.h"
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>

//----------------------------------------------------------------------

char ssid[] = "router";     // your network SSID (name)
char pass[] = "password";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status

// Initialize the Ethernet client object
WiFiEspClient client;

//----------------------------------------------------------------------


byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress server_addr(192,168,178,114);  // IP of the MySQL *server* here
char user[] = "user";             // MySQL user login username
char password[] = "******";        // MySQL user login password

MySQL_Connection conn((Client *)&client);
// Sample query
char INSERT_SQL[] = "INSERT INTO test_arduino.hello_arduino (message) VALUES ('Hello, Arduino!')";

void setup() {
  Serial.begin(115200); // initialize serial for ESP module
  while (!Serial); // wait for serial port to connect
  
  Serial1.begin(115200); // initialize ESP module
  WiFi.init(&Serial1);
  status=WiFi.begin(ssid, pass);

  if ( status != WL_CONNECTED) {
    Serial.println("Couldn't get a wifi connection");
    while(true);
  }else {
    Serial.println("Connected to network");
    IPAddress ip = WiFi.localIP();
    Serial.print("My IP address is: ");
    Serial.println(ip);
  }
  
  Serial.println("Connecting...");
  if (conn.connect(server_addr, 3306, user, password)) {
    delay(1000);
  }else
    Serial.println("Connection failed.");
 conn.close();
}


void loop() {} //empty because for now i just want to connect succesfully

and what i get on the device manager is that:

[WiFiEsp] Initializing ESP module
[WiFiEsp] Initilization successful - 1.5.4
[WiFiEsp] Connected to EOLO - FRITZ!Box NW
Connected to network
Connecting…
[WiFiEsp] Connecting to 192.168.178.114
[WiFiEsp] TIMEOUT: 57
ERROR: Timeout waiting for client.
[WiFiEsp] TIMEOUT: 60
ERROR: Timeout waiting for client.
Error: 86 = Access denied forarduino⸮H⸮⸮׮⸮⸮⸮[Y⸮Ж⸮⸮⸮⸮⸮root⸮⸮⸮޽⸮.
Connection failed.

I have not modified anything on both libraries, I’m asking if someone has more experience on this two libraries and/or somehow made a similiar project to work.
i know that with this device is possible to write data on a web page (i did it already as a test) and then feed the MYSQL database though a php script but i’m not interested on that solution for now

am i making any stupid mistake (like always :confused: ) ?

thanks to all for your time
cheers

Hi
can you connect to that MySQL database from other computer?

Yes I did.
I can access the database with my smartphone using the same credentials...

Thank you for replying

perhaps longer timeout would help

I've tried, by modifying the delay time to 5seconds in the mysql_connection.cpp library...
I still get the same error... Can it be a problem related more to the database part? I don't know maybe some settings...
Is there another way to test the Arduino code?

francescofabbro89:
I've tried, by modifying the delay time to 5seconds in the mysql_connection.cpp library...

delay is no timeout. I meant TCP timeout. on server side

Buenos dias amigos

escribo para ver si por favor me prodrian orientar. veran es que deseo realizar la medicion de un electrocardiograma con arduino y AD620, de manera que la señal analoga obtenida pueda ser transmitida con el modulo wifi ESP8266 para que pueda ser visualizada en cualquier parte del mundo a traves de internet en un celular o pc. agradezco si me pueden colaborar con consejos, tambien si saben de como diseñar una aplicacion en el celular que se enlace a internet y pueda ver la señal.

agradezco su ayuda