Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Cant conect to MYSQL? #1

Open
darrenjlobb opened this issue Feb 7, 2024 · 6 comments
Open

Cant conect to MYSQL? #1

darrenjlobb opened this issue Feb 7, 2024 · 6 comments

Comments

@darrenjlobb
Copy link

Connects to WiFi, have existing working MySQL server, have setup a new database called water, and imported the water table using the provided instruction, however upon programming / reboot, the ESP dosnt seem to connect... Have configued IP / User / Pass and database name...

Just get a cycle:

....trying...
...got: 0 retrying...
...trying...
...got: 0 retrying...
...trying...
...got: 0 retrying...
....trying..

@EdwinGH
Copy link
Owner

EdwinGH commented Feb 11, 2024

Hi @darrenjlobb , I don't recognize the test you are getting back from the ESP. Could you post a longer serial log that does include serial print statements from the code, so we can see where in the code it gets stuck in the cycle?

@darrenjlobb
Copy link
Author

darrenjlobb commented Feb 11, 2024

Hi @darrenjlobb , I don't recognize the test you are getting back from the ESP. Could you post a longer serial log that does include serial print statements from the code, so we can see where in the code it gets stuck in the cycle?

Here is the full serial print from reboot.... Thanks for replying so soon!

ets Jun 8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13964
load:0x40080400,len:3600
entry 0x400805f0
Setup: Serial opened
INFO: Connecting to WiFi SSID EDIT
..
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13964
load:0x40080400,len:3600
entry 0x400805f0
Setup: Serial opened
INFO: Connecting to WiFi SSID EDIT
..
WiFi connected
IP address: 10.0.0.136
Connecting to MySQL ...trying...
...got: 0 retrying...
...trying...
...got: 0 retrying...
...trying...
...got: 0 retrying...

And then just loops over and over... I should add, I am trying to run this on an ESP32, not an 8266, so have changed code to include WiFi.h rather than the 8266 file.

@EdwinGH
Copy link
Owner

EdwinGH commented Feb 12, 2024

This seems to be a MySQL connection problem more than linked to my Watermeter code.
Maybe the following thread will help you: https://forum.arduino.cc/t/mysql-connect-not-connect/951634/6
The recommendation is to check if you are allowed to remotely log into your MySQL server (MySQL user/remote rights or firewall issue) via MySQL logs, trying to log in from another host, or checking TCP traffic with wireshark.
Hope this helps!

@darrenjlobb
Copy link
Author

This seems to be a MySQL connection problem more than linked to my Watermeter code. Maybe the following thread will help you: https://forum.arduino.cc/t/mysql-connect-not-connect/951634/6 The recommendation is to check if you are allowed to remotely log into your MySQL server (MySQL user/remote rights or firewall issue) via MySQL logs, trying to log in from another host, or checking TCP traffic with wireshark. Hope this helps!

Thanks again for the reply, Sadly have already tried these steps.... Hence my confusion / post on here! I can sucessfully login to my MYSQL server no problem from multiple hosts on my network, using the user I have created for this application... So the SQL side of it seems to be working ok, Im guessing its because im using ESP32 and not 8266 as you were and the WiFi.h is somehow different?

@EdwinGH
Copy link
Owner

EdwinGH commented Feb 16, 2024

I'm not an expert, but the main difference I know between ESP32 and 8266 is the WiFi libraries to use (the ESP8266 includes start with '8266' for WiFi.h and HTTPClient.h).
So it could be that the WiFi/IP/TCP connection is not working on your hardware; maybe you can try to ping your database server or connect to another service on that server before connecting to the MySQL service, to make sure there is a connection?

@darrenjlobb
Copy link
Author

I'm not an expert, but the main difference I know between ESP32 and 8266 is the WiFi libraries to use (the ESP8266 includes start with '8266' for WiFi.h and HTTPClient.h). So it could be that the WiFi/IP/TCP connection is not working on your hardware; maybe you can try to ping your database server or connect to another service on that server before connecting to the MySQL service, to make sure there is a connection?

Just as an update to this, I decided to try the code on an 8266, and other than having to roll a few libarys back to older versions to allow it to compile, it now works great! Have got 8 water meters running this code to central sql server, which am then using node-red and HA to present data to end users.

No idea why it wont work on the ESP32 but assume some kind of libary issue!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants