Repository navigation
Arduino Nano ESP S3 can not connect to MySQL Server ' user: 'unauthenticated' #219
Description
Greetings to all, specialy to Dr. Chuck Bell.
first of all Thank You for this connector. It helps me a lot in many home usecases.
I have problem with Arduino Nano ESP and only with this type. On others (Wifi Rev2, Iot 33) it works without any problem. During try to connect to MySQL it get stuck. ( pics1) . after 12 hours of trying i give up :)
on MySQL server i have error says
"[Warning] Aborted connection 6 to db: 'unconnected' user: 'unauthenticated' host: '10.1.4.5' (This connection closed normally without authentication)"
others non ESP arduino borads works perfectly.
on Serial monitor i see this :

notes:
- temperature is wrong because sensor is disconnected. tested with simple connection to wifi and then connect to MySQL
Thank You in advance.
Pavel
#include <Arduino.h>
#include <ESPping.h>
#include <ping32.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#include <WiFi.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
//#include <MySQL_Encrypt_Sha1.h>
#include <MySQL_Packet.h>
// pin, for sensor
#define pin 5
OneWire oneWire(pin);
//onewire do Dallasu
DallasTemperature sensors(&oneWire);
char INSERT_DATA1[] = "INSERT INTO data_zarizeni.udirna (TeplotaDoleLeva,TeplotaDolePrava,TeplotaHorniLeva,TeplotaHorniPrava,time) VALUES (%f,%f,%f,%f,now())";
char query[1024];
float TeplotaDoleLevaInt = 0;
float TeplotaDolePravaInt = 0;
float TeplotaHorniLevaInt = 0;
float TeplotaHorniPravaInt = 0;
//SQL sekce
IPAddress server_addr(10, 1, 2, 6); // IP of the MySQL server here
char usr[] = "username"; // MySQL user login username - TAB MySQL.h
char pwd[] = "passwd"; // MySQL user login password
WiFiClient client;
MySQL_Connection conn((Client *)&client);
// wifi
char ssid[] = "iot"; // your network SSID (name)
char pass[] = "Passwd"; // your network password
int status = WL_IDLE_STATUS; // the Wifi radio's status
void setup() {
Serial.begin(9600);
sensors.begin();
delay(2000);
Serial.println("Start in 3...2....1...");
delay(500);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.print(" Gateway: ");
Serial.println(WiFi.gatewayIP());
const IPAddress remote_ip(10, 1, 2, 6);
Serial.print(remote_ip);
if (Ping.ping(remote_ip) > 0) {
Serial.printf(" response time : %d/%.2f/%d ms\n", Ping.minTime(), Ping.averageTime(), Ping.maxTime());
} else {
Serial.println(" Error !");
}
}
void loop() {
for (int index = 0; index < 4; index++) {
sensors.requestTemperatures();
Serial.print("Teplota je: ");
Serial.print(sensors.getTempCByIndex(index)); //0 je index toho čidla
Serial.println(" stupnu Celsia");
switch (index) {
case 0:
TeplotaDoleLevaInt = sensors.getTempCByIndex(index);
case 1:
TeplotaDolePravaInt = sensors.getTempCByIndex(index);
case 2:
TeplotaHorniLevaInt = sensors.getTempCByIndex(index);
case 3:
TeplotaHorniPravaInt = sensors.getTempCByIndex(index);
}
delay(200);
}
delay(1000);
// vlozeni teplot
Serial.println("Connecting...");
if (conn.connect(server_addr, 3307, usr, pwd)) {
// Initiate the query class instance
delay(1000);
Serial.println("pripojen?");
MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
// Save
sprintf(query, INSERT_DATA1, TeplotaDoleLevaInt, TeplotaDolePravaInt, TeplotaHorniLevaInt, TeplotaHorniPravaInt);
// Execute the query
cur_mem->execute(query);
// Deleting the cursor also frees up memory used
delete cur_mem;
Serial.println("Data recorded.");
}
delay(30000);
}
Activity
ChuckBell commentedon Jan 2, 2024
jonesek commentedon Jan 2, 2024
Yes, thats correct . my mysql is listening on 3307
Pavel
ChuckBell commentedon Jan 2, 2024
jonesek commentedon Jan 2, 2024
Yes, correct , other connections from other platforms with same password and username are fine.
ChuckBell commentedon Jan 3, 2024
jonesek commentedon Jan 9, 2024
I use no special library, once i have added library for ESP nano it should be fine.

Pavel
ChuckBell commentedon Jan 9, 2024