Skip to content

Arduino Nano ESP S3 can not connect to MySQL Server ' user: 'unauthenticated' #219

Open

Description

@jonesek

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 :
pic1

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

  1. ChuckBell commented on Jan 2, 2024

    @ChuckBell
    Owner
  2. jonesek commented on Jan 2, 2024

    @jonesek
    Author

    The first thing I see is you are using port 3307. MySQL uses ports 3306 and 33060. So, unless you have configured your MySQL server to use 3307, this code will not connect over port 3307.
    …
    On Dec 30, 2023, at 6:15 AM, jonesek @.***> wrote: Greetings to all, specialy to Dr. Chuck Bell. first of all Thak You for tis 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 : pic1.png (view on web) https://github.com/ChuckBell/MySQL_Connector_Arduino/assets/44143932/091b0c6a-0c34-4dea-9ff5-6ec2a123188c 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); } — Reply to this email directly, view it on GitHub <#219>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6SHYFNELFE2ICUSWA6TT3YL7ZVVAVCNFSM6AAAAABBHOOOQ2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGA3DANZRG4YDIOA. You are receiving this because you are subscribed to this thread.

    Yes, thats correct . my mysql is listening on 3307
    Pavel

  3. ChuckBell commented on Jan 2, 2024

    @ChuckBell
    Owner
  4. jonesek commented on Jan 2, 2024

    @jonesek
    Author

    Can other IoT devices connect to the same MySQL server with the same user id and password? I’d check that first.
    …
    On Jan 2, 2024, at 11:28 AM, jonesek @.> wrote: The first thing I see is you are using port 3307. MySQL uses ports 3306 and 33060. So, unless you have configured your MySQL server to use 3307, this code will not connect over port 3307. … x-msg://2/# On Dec 30, 2023, at 6:15 AM, jonesek @.> wrote: Greetings to all, specialy to Dr. Chuck Bell. first of all Thak You for tis 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 : pic1.png (view on web) https://github.com/ChuckBell/MySQL_Connector_Arduino/assets/44143932/091b0c6a-0c34-4dea-9ff5-6ec2a123188c 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); } — Reply to this email directly, view it on GitHub <#219 <#219>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6SHYFNELFE2ICUSWA6TT3YL7ZVVAVCNFSM6AAAAABBHOOOQ2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGA3DANZRG4YDIOA. You are receiving this because you are subscribed to this thread. Yes, thats correct . my mysql is listening on 3307 Pavel — Reply to this email directly, view it on GitHub <#219 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6SHYCQZBCPL67OS3VZ4Q3YMQYSDAVCNFSM6AAAAABBHOOOQ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZUGI2TCMZWGU. You are receiving this because you commented.

    Yes, correct , other connections from other platforms with same password and username are fine.

  5. ChuckBell commented on Jan 3, 2024

    @ChuckBell
    Owner
  6. jonesek commented on Jan 9, 2024

    @jonesek
    Author

    I use no special library, once i have added library for ESP nano it should be fine.
    image

    Pavel

  7. ChuckBell commented on Jan 9, 2024

    @ChuckBell
    Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions