uno+wifi r3 MySQL connection problem
Posted: Tue Aug 24, 2021 5:11 am
Good day.
Can someone please help?
I am trying to connect to a MySQL server with and ESP2866. The board I use is the uno+wifi r3 atmega328p+esp8266.
I get WIFI connection, but when the board want to connect to the MySQL server I get "Exception (28)"
WiFi Connected
MAC: A8:1F:F5:12:CF:A4
Assigned IP: 192.168.8.110
Connecting to database
...trying...
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Exception (28):
epc1=0x40201670 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000049 depc=0x00000000
>>>stack>>>
Here is my code:
--------------------
#include <MySQL_Connection.h>
#include <MySQL_Packet.h>
#include <MySQL_Cursor.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
char ssid[] = "**-2"; // Network Name
char pass[] = "TGBKJIHU@#"; // Network Password
byte mac[6];
WiFiServer server(80);
IPAddress ip(192, 168, 8, 110);
IPAddress gateway(192, 168, 8, 1);
IPAddress subnet(255, 255, 255, 0);
WiFiClient client;
MySQL_Connection conn((Client *)&client);
//char INSERT_SQL
char INSERT_SQL[] = "INSERT INTO sensors.sensor_data (sensor_number, humid_1, humid_2, humid_3) VALUES (%d,%d,%d,%d)";
char query[128];
IPAddress server_addr(192,168,8,108); // MySQL server IP
char user[] = "root"; // MySQL user
char password[] = "password"; // MySQL password
void setup() {
Serial.begin(115200);
//pinMode(sensorPin1, INPUT);
//pinMode(sensorPin2, INPUT);
Serial.println("Initialising connection");
Serial.print(F("Setting static ip to : "));
Serial.println(ip);
Serial.println("");
Serial.println("");
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.config(ip, gateway, subnet);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(2000);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi Connected");
WiFi.macAddress(mac);
Serial.print("MAC: ");
Serial.print(mac[5],HEX);
Serial.print(":");
Serial.print(mac[4],HEX);
Serial.print(":");
Serial.print(mac[3],HEX);
Serial.print(":");
Serial.print(mac[2],HEX);
Serial.print(":");
Serial.print(mac[1],HEX);
Serial.print(":");
Serial.println(mac[0],HEX);
Serial.println("");
Serial.print("Assigned IP: ");
Serial.print(WiFi.localIP());
Serial.println("");
Serial.println("Connecting to database");
while (conn.connect(server_addr, 3306, user, password) != true) {
delay(2000);
Serial.print ( "." );
}
Serial.println("");
Serial.println("Connected to SQL Server!");
}
void loop() {
//int soil_hum = 1024 - analogRead(sensorPin1);
//float t = dht.readTemperature();
//Serial.println(t);
delay(10000); //10 sec
//sprintf(query, INSERT_SQL, soil_hum);
//sprintf(query, INSERT_SQL, soil_hum, t);
//Serial.println("Recording data.");
//Serial.println(query);
MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
//cur_mem->execute(query);
delete cur_mem;
}
----------------------
Hope someone can help me with this.
Thank you.
Can someone please help?
I am trying to connect to a MySQL server with and ESP2866. The board I use is the uno+wifi r3 atmega328p+esp8266.
I get WIFI connection, but when the board want to connect to the MySQL server I get "Exception (28)"
WiFi Connected
MAC: A8:1F:F5:12:CF:A4
Assigned IP: 192.168.8.110
Connecting to database
...trying...
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Exception (28):
epc1=0x40201670 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000049 depc=0x00000000
>>>stack>>>
Here is my code:
--------------------
#include <MySQL_Connection.h>
#include <MySQL_Packet.h>
#include <MySQL_Cursor.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
char ssid[] = "**-2"; // Network Name
char pass[] = "TGBKJIHU@#"; // Network Password
byte mac[6];
WiFiServer server(80);
IPAddress ip(192, 168, 8, 110);
IPAddress gateway(192, 168, 8, 1);
IPAddress subnet(255, 255, 255, 0);
WiFiClient client;
MySQL_Connection conn((Client *)&client);
//char INSERT_SQL
char INSERT_SQL[] = "INSERT INTO sensors.sensor_data (sensor_number, humid_1, humid_2, humid_3) VALUES (%d,%d,%d,%d)";
char query[128];
IPAddress server_addr(192,168,8,108); // MySQL server IP
char user[] = "root"; // MySQL user
char password[] = "password"; // MySQL password
void setup() {
Serial.begin(115200);
//pinMode(sensorPin1, INPUT);
//pinMode(sensorPin2, INPUT);
Serial.println("Initialising connection");
Serial.print(F("Setting static ip to : "));
Serial.println(ip);
Serial.println("");
Serial.println("");
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.config(ip, gateway, subnet);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(2000);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi Connected");
WiFi.macAddress(mac);
Serial.print("MAC: ");
Serial.print(mac[5],HEX);
Serial.print(":");
Serial.print(mac[4],HEX);
Serial.print(":");
Serial.print(mac[3],HEX);
Serial.print(":");
Serial.print(mac[2],HEX);
Serial.print(":");
Serial.print(mac[1],HEX);
Serial.print(":");
Serial.println(mac[0],HEX);
Serial.println("");
Serial.print("Assigned IP: ");
Serial.print(WiFi.localIP());
Serial.println("");
Serial.println("Connecting to database");
while (conn.connect(server_addr, 3306, user, password) != true) {
delay(2000);
Serial.print ( "." );
}
Serial.println("");
Serial.println("Connected to SQL Server!");
}
void loop() {
//int soil_hum = 1024 - analogRead(sensorPin1);
//float t = dht.readTemperature();
//Serial.println(t);
delay(10000); //10 sec
//sprintf(query, INSERT_SQL, soil_hum);
//sprintf(query, INSERT_SQL, soil_hum, t);
//Serial.println("Recording data.");
//Serial.println(query);
MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
//cur_mem->execute(query);
delete cur_mem;
}
----------------------
Hope someone can help me with this.
Thank you.