Chat freely about anything...

User avatar
By finexil
#85002 Hello everybody, I'm a newby trying to deal with an ESP-12 to detect home temperature, display it on a local display 1,8" and store it in a Maria DB any 10 minutes. In the Maria DB I created a table where are stored the temperatures on hourly basis I'd want the ESP would report on the local display.
So I need to manage two different pages on the display, one to display the temperature and humidity, and a second with a bar graph that reports the central configuration.
I'm experiencing an issue when I get data from the Maria DB, so I reduced the overall script to a simple loop that query the DB any 10 seconds with the following code:
#include <ESP8266WiFi.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
#include "arduino_secrets.h"

#ifndef STASSID
#define STASSID SECRET_SSID;
#define STAPSK SECRET_PASS;
#endif

const char* ssid = SECRET_SSID;
const char* password = SECRET_PASS;

WiFiClient client;
MySQL_Connection conn((Client *)&client);

IPAddress server_addr(192, 168 , 128, 7);

char INSERT_SQL[300];
int i=0;

void setup() {
Serial.begin(9600);

WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());

Serial.println("\nWaiting for DB");
while (conn.connect(server_addr, 3306, SECRET_DBUSER, SECRET_DBPASSWORD) != true) {
delay(1000);
Serial.print ( "." );
}

}

void loop() {
if (conn.connected()) {
Serial.print("Attempt number: ");
Serial.println(++i);
sprintf(INSERT_SQL,"SELECT * FROM temperature.TermostatSetup WHERE room='pt camera';");
MySQL_Cursor *cur_mem_read = new MySQL_Cursor(&conn);
if(cur_mem_read->execute(INSERT_SQL)) {
cur_mem_read->show_results();
}
cur_mem_read->close();
delete cur_mem_read;
}
delay(10000); // wait 10 seconds
}

Everything goes fine but after the fourth loop I get the following error:
18:25:30.529 -> Soft WDT reset
18:25:30.529 ->
18:25:30.529 -> >>>stack>>>
18:25:30.529 ->
18:25:30.529 -> ctx: cont
18:25:30.529 -> sp: 3ffffd60 end: 3fffffc0 offset: 01b0
18:25:30.562 -> 3fffff10: 00000019 00000004 3ffee540 402031d3
18:25:30.629 -> 3fffff20: 1c000052 00000005 00000019 402024b6
18:25:30.663 -> 3fffff30: 00000019 00000000 3ffefb44 40202be9
18:25:30.731 -> 3fffff40: 00000019 00000000 3ffefb44 40202ce6
18:25:30.764 -> 3fffff50: 00000000 3ffee670 3ffe8731 00000000
18:25:30.832 -> 3fffff60: 00000019 3ffee670 3ffefb44 40202d30
18:25:30.866 -> 3fffff70: 3ffee540 00000001 3ffefb44 40202de1
18:25:30.935 -> 3fffff80: 3ffee540 00000000 3ffefb44 3ffee6e8
18:25:30.970 -> 3fffff90: 3ffee540 3ffee40c 3ffefb44 4020118a
18:25:31.038 -> 3fffffa0: 3fffdad0 00000000 3ffee6a8 40204124
18:25:31.073 -> 3fffffb0: feefeffe feefeffe 3ffe84f0 40100ccd
18:25:31.140 -> <<<stack<<<

The problem happens always at the fourth attempt, following the complete screenshot of the serial monitor:
...............
18:24:52.484 -> WiFi connected
18:24:52.484 -> IP address:
18:24:52.484 -> 192.168.128.5
18:24:52.484 ->
18:24:52.484 -> Waiting for DB
18:24:54.704 -> Connected to server version 5.5.5-10.3.17-MariaDB-0+deb10u1
18:24:54.704 -> Attempt number: 1
18:24:54.804 -> room,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23
18:24:54.857 -> pt camera,16,16,14,14,16,20,22,23,21,18,16,21,24,23,22,18,16,14,18,20,20,20,18,16
18:24:55.742 -> 1 rows in result.
18:25:05.739 -> Attempt number: 2
18:25:05.942 -> room,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23
18:25:06.010 -> pt camera,16,16,14,14,16,20,22,23,21,18,16,21,24,23,22,18,16,14,18,20,20,20,18,16
18:25:06.899 -> 1 rows in result.
18:25:16.902 -> Attempt number: 3
18:25:17.037 -> room,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23
18:25:17.072 -> pt camera,16,16,14,14,16,20,22,23,21,18,16,21,24,23,22,18,16,14,18,20,20,20,18,16
18:25:17.972 -> 1 rows in result.
18:25:27.949 -> Attempt number: 4
18:25:28.096 -> room,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23
18:25:30.529 ->
18:25:30.529 -> Soft WDT reset
18:25:30.529 ->
18:25:30.529 -> >>>stack>>>
18:25:30.529 ->
18:25:30.529 -> ctx: cont
18:25:30.529 -> sp: 3ffffd60 end: 3fffffc0 offset: 01b0
18:25:30.562 -> 3fffff10: 00000019 00000004 3ffee540 402031d3
18:25:30.629 -> 3fffff20: 1c000052 00000005 00000019 402024b6
18:25:30.663 -> 3fffff30: 00000019 00000000 3ffefb44 40202be9
18:25:30.731 -> 3fffff40: 00000019 00000000 3ffefb44 40202ce6
18:25:30.764 -> 3fffff50: 00000000 3ffee670 3ffe8731 00000000
18:25:30.832 -> 3fffff60: 00000019 3ffee670 3ffefb44 40202d30
18:25:30.866 -> 3fffff70: 3ffee540 00000001 3ffefb44 40202de1
18:25:30.935 -> 3fffff80: 3ffee540 00000000 3ffefb44 3ffee6e8
18:25:30.970 -> 3fffff90: 3ffee540 3ffee40c 3ffefb44 4020118a
18:25:31.038 -> 3fffffa0: 3fffdad0 00000000 3ffee6a8 40204124
18:25:31.073 -> 3fffffb0: feefeffe feefeffe 3ffe84f0 40100ccd
18:25:31.140 -> <<<stack<<<
18:25:31.140 -> ⸮⸮܆⸮⸮D⸮⸮.......
18:25:34.753 -> WiFi connected
18:25:34.753 -> IP address:
18:25:34.786 -> 192.168.128.5
18:25:34.786 ->
18:25:34.786 -> Waiting for DB
18:25:36.866 -> Connected to server version 5.5.5-10.3.17-MariaDB-0+deb10u1
18:25:36.920 -> Attempt number: 1
18:25:36.966 -> room,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23
18:25:37.067 -> pt camera,16,16,14,14,16,20,22,23,21,18,16,21,24,23,22,18,16,14,18,20,20,20,18,16
18:25:37.901 -> 1 rows in result.
18:25:47.933 -> Attempt number: 2
18:25:48.134 -> room,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23
18:25:48.187 -> pt camera,16,16,14,14,16,20,22,23,21,18,16,21,24,23,22,18,16,14,18,20,20,20,18,16
18:25:49.073 -> 1 rows in result.
18:25:59.074 -> Attempt number: 3
18:25:59.211 -> room,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23
18:25:59.279 -> pt camera,16,16,14,14,16,20,22,23,21,18,16,21,24,23,22,18,16,14,18,20,20,20,18,16
18:26:00.135 -> 1 rows in result.
18:26:10.138 -> Attempt number: 4
18:26:10.286 -> room,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23
18:26:12.852 ->
18:26:12.852 -> Soft WDT reset
18:26:12.852 ->
18:26:12.852 -> >>>stack>>>
18:26:12.852 ->
18:26:12.852 -> ctx: cont
18:26:12.899 -> sp: 3ffffd70 end: 3fffffc0 offset: 01b0
18:26:12.899 -> 3fffff20: 1c000052 00000005 00000019 402024b6
18:26:12.999 -> 3fffff30: 00000019 00000000 3ffefb44 40202be9
18:26:12.999 -> 3fffff40: 00000019 00000000 3ffefb44 40202ce6
18:26:13.099 -> 3fffff50: 00000000 3ffee670 3ffe8731 00000000
18:26:13.099 -> 3fffff60: 00000019 3ffee670 3ffefb44 40202d30
18:26:13.200 -> 3fffff70: 3ffee540 00000001 3ffefb44 40202de1
18:26:13.200 -> 3fffff80: 3ffee540 00000000 3ffefb44 3ffee6e8
18:26:13.300 -> 3fffff90: 3ffee540 3ffee40c 3ffefb44 4020118a
18:26:13.300 -> 3fffffa0: 3fffdad0 00000000 3ffee6a8 40204124
18:26:13.400 -> 3fffffb0: feefeffe feefeffe 3ffe84f0 40100ccd
18:26:13.400 -> <<<stack<<<
18:26:13.454 -> H!⸮ԅ⸮⸮⸮)(?........
18:26:17.532 -> WiFi connected
18:26:17.532 -> IP address:
18:26:17.579 -> 192.168.128.5
18:26:17.579 ->
18:26:17.579 -> Waiting for DB
18:26:19.665 -> Connected to server version 5.5.5-10.3.17-MariaDB-0+deb10u1
18:26:19.718 -> Attempt number: 1
18:26:19.765 -> room,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23
18:26:19.818 -> pt camera,16,16,14,14,16,20,22,23,21,18,16,21,24,23,22,18,16,14,18,20,20,20,18,16
18:26:20.689 -> 1 rows in result.
18:26:30.702 -> Attempt number: 2
18:26:30.939 -> room,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23
18:26:31.007 -> pt camera,16,16,14,14,16,20,22,23,21,18,16,21,24,23,22,18,16,14,18,20,20,20,18,16
18:26:31.862 -> 1 rows in result.
18:26:41.872 -> Attempt number: 3
18:26:42.019 -> room,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23
18:26:42.073 -> pt camera,16,16,14,14,16,20,22,23,21,18,16,21,24,23,22,18,16,14,18,20,20,20,18,16
18:26:42.931 -> 1 rows in result.
18:26:52.947 -> Attempt number: 4
18:26:53.047 -> room,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23
18:26:55.162 ->
18:26:55.162 -> Soft WDT reset
18:26:55.162 ->
18:26:55.162 -> >>>stack>>>
18:26:55.162 ->
18:26:55.162 -> ctx: cont
18:26:55.162 -> sp: 3ffffd70 end: 3fffffc0 offset: 01b0
18:26:55.209 -> 3fffff20: 1c000052 00000005 00000019 402024b6
18:26:55.263 -> 3fffff30: 00000019 00000000 3ffefb44 40202be9
18:26:55.310 -> 3fffff40: 00000019 00000000 3ffefb44 40202ce6
18:26:55.363 -> 3fffff50: 00000000 3ffee670 3ffe8731 00000000
18:26:55.410 -> 3fffff60: 00000019 3ffee670 3ffefb44 40202d30
18:26:55.463 -> 3fffff70: 3ffee540 00000001 3ffefb44 40202de1
18:26:55.510 -> 3fffff80: 3ffee540 00000000 3ffefb44 3ffee6e8
18:26:55.580 -> 3fffff90: 3ffee540 3ffee40c 3ffefb44 4020118a
18:26:55.614 -> 3fffffa0: 3fffdad0 00000000 3ffee6a8 40204124
18:26:55.683 -> 3fffffb0: feefeffe feefeffe 3ffe84f0 40100ccd
18:26:55.718 -> <<<stack<<<
18:26:55.718 -> H!⸮⸮q9D⸮b?........
18:26:59.826 -> WiFi connected
18:26:59.826 -> IP address:
18:26:59.880 -> 192.168.128.5

I cannot understand where I'm doing wrong any help is very much appreciated.
THANKS.
User avatar
By finexil
#85024 Hello everybody,
after trying to solve the problem I changed the query in the following format:
SELECT t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t19, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23 FROM temperature.TermostatSetup where room='pt camera';

and the issue is no longer present, so it seems to be something related to the SELECT * FROM that brings to the issue I was having.

I tried this final solution after the implementation of a loop for any single field that was working without any problem.

As I said I'm a newbie so I'm not capable of finding the correction for the issue.