mysqlmariadbraspberry-pi3esp8266raspberry-pi-zero

Issues accessing MySQL on Raspberry Pi (3 & Zero) through ESP8266


not sure whether this is the right place to open this topic, but I'll give it a try.

Recently I am experiencing an unexpected behavior on my (two) Raspberry Pi´s (one is a raspberry Pi 3 B and on a Zero).

I tried out the following configurations:

  1. The RasPi Zero is connected via eth0 to the Router. It opens a WiFi with its wlan0 (refer to: https://www.raspberrypi.org/documentation/configuration/wireless/access-point-routed.md).

a. If I connect a Laptop or an ESP8266 NodeMCU to the "Home Wifi" both can access the MySQL (MariaDB) database.

b. If I connect a Laptop or an ESP8266 NodeMCU to the "RasPi Wifi" only the Laptop can access the MySQL (MariaDB) database. The ESP82866 connection to database is "blocked" but no error message.

I made a sketch you ca refer to: Configuration 1 (with RasPi Zero)

  1. The RasPi 3 is connected via wlan1 to the Router. It opens a WiFi with its wlan0 (refer to: https://www.raspberrypi.org/documentation/configuration/wireless/access-point-routed.md).

a. If I connect a Laptop or an ESP8266 NodeMCU to the "Home Wifi" both can access the MySQL (MariaDB) database.

b. If I connect a Laptop or an ESP8266 NodeMCU to the "RasPi Wifi" only the Laptop can access the MySQL (MariaDB) database. The ESP82866 connection to database is "blocked" but no error message.

see my sketch: Configuration 2 (with RasPi 3)

Who has experienced the sam issue? For my understanding it makes no sense that the Laptop (MacBook Pro) can access the database connected to any network via Python and als with phpmyadmin. The ESP can only connect to the database when it is in the "Home Network" The code running on the ESP is always the same except the SSID and the IP address of the MySQL Server).

Thank you.
Alex


Solution

  • I tried out a lot of workarounds and other ideas to get rid of the issue. Like to share some experiences I made (and unfortunately can not understand 100%).

    1. If an ESP (tried out the NodeMCU, WemosD1 mini and ESP12F) is connected to a WiFi which is provided by the Raspberry Pi thru hostapd it cannot ping/access any device inside this network. I do not understand why, because any other device (e.g. RasPi or Laptop) can ping the ESP.

    2. BUT the ESP can connect to a device outside it's own network. E.g. it can ping the second IP dress of the RasPi.

    In my example the ESP receives the IP 192.168.4.96 (DHCP from RasPi with hostapd provided by the wlan0). It can Ping the wlan1 of the same RasPi with IP 192.168.188.37.

    With this little success the ESP can than access to the Database on the RasPi. (After following the hint from The Impaler - using GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;).

    The main question still is open: Is there an explanation and solution to the initial issue I am facing - no access to the Database / any other device within the network the ESP is connected to?