Anonymous
Сбой кода ESP32 — получает данные от ADI с помощью HTTPClient.h, анализирует их с помощью ArduinoJson, отображает на P10
Сообщение
Anonymous » 09 ноя 2025, 06:57
Я немного застрял, так как написал код для ESP32, который должен делать две вещи:
Извлекать некоторый JSON из источника HTTP и анализировать его с помощью ArduinoJSON - это работает изолированно;
Отображать значения на ЖК-экране P10 с помощью библиотеки DMD32 - это работает изолированно.
Однако, когда я соединяю их вместе, происходит сбой ESP32. Вот ошибка последовательного монитора:
Код: Выделить всё
Start an alarm.
assert failed: xQueueSemaphoreTake queue.c:1554 (!( ( xTaskGetSchedulerState() == ( ( BaseType_t ) 0 ) ) && ( xTicksToWait != 0 ) ))
Rebooting...
ets Jul 29 2019 12:21:46
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1324
ho 0 tail 12 room 4
load:0x40078000,len:13508
load:0x40080400,len:3604
entry 0x400805f0
Судя по комментированию кода, кажется, что это происходит, когда я запускаю timerAlarmEnable(timer); в строке 67 кода. Код ниже:
Код: Выделить всё
#include //--> DMD32 by Qudor-Engineer (KHUDHUR ALFARHAN) : https://github.com/Qudor-Engineer/DMD32
#include "fonts/SystemFont5x7.h"
#include "fonts/Arial_black_16.h"
//----------------------------------------
// Fire up the DMD library as dmd.
#define DISPLAYS_ACROSS 2
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
// Timer setup.
// create a hardware timer of ESP32.
hw_timer_t * timer = NULL;
//________________________________________________________________________________IRAM_ATTR triggerScan()
// Interrupt handler for Timer1 (TimerOne) driven DMD refresh scanning,
// this gets called at the period set in Timer1.initialize();
void IRAM_ATTR triggerScan() {
dmd.scanDisplayBySPI();
}
#include
#include
#include
const char* ssid = "JacqHousey2";
const char* password = "XXXX";
void setup() {
Serial.begin(115200);
delay(4000);
Serial.println();
delay(500);
Serial.println();
Serial.println("return the clock speed of the CPU.");
// return the clock speed of the CPU.
uint8_t cpuClock = ESP.getCpuFreqMHz();
delay(500);
Serial.println();
Serial.println("Timer Begin");
// Use 1st timer of 4.
// devide cpu clock speed on its speed value by MHz to get 1us for each signal of the timer.
timer = timerBegin(0, cpuClock, true);
delay(500);
Serial.println();
Serial.println("Attach triggerScan function to our timer.");
// Attach triggerScan function to our timer.
timerAttachInterrupt(timer, &triggerScan, true);
delay(500);
Serial.println();
Serial.println("Set alarm to call triggerScan function.");
// Set alarm to call triggerScan function.
// Repeat the alarm (third parameter).
timerAlarmWrite(timer, 300, true);
delay(500);
// THIS SECTION HERE CAUSES THE CRASH
Serial.println();
Serial.println("Start an alarm.");
// Start an alarm.
timerAlarmEnable(timer);
delay(500);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi..");
}
Serial.println("Connected to the WiFi network");
}
void loop() {
if ((WiFi.status() == WL_CONNECTED)) { //Check the current connection status
WiFiClient client; // or WiFiClientSecure for HTTPS
HTTPClient http;
// Send request
http.useHTTP10(true);
http.begin(client, "http://bankethical.au/getlatestnames.php");
http.GET();
// Parse response
DynamicJsonDocument doc(2048);
deserializeJson(doc, http.getStream());
// Read values
//Serial.println(doc["Donation"].as());
// Work out how many new donations there are
int numdonors = doc.size();
JsonArray root_0 = doc[0];
const char* root_0_0 = root_0[0]; // "11"
const char* root_0_1 = root_0[1]; // "2025-10-18 23:53:39.561412"
const char* root_0_2 = root_0[2]; // "NEW"
const char* root_0_3 = root_0[3]; // "USD"
const char* root_0_4 = root_0[4]; // "100"
const char* root_0_5 = root_0[5]; // "100"
const char* root_0_6 = root_0[6]; // "John"
const char* root_0_7 = root_0[7]; // "Doe"
const char* root_0_8 = root_0[8]; // "johndoeemail@hotmail.com"
const char* root_0_9 = root_0[9]; // "387.61"
JsonArray root_1 = doc[1];
const char* root_1_0 = root_1[0]; // "12"
const char* root_1_1 = root_1[1]; // "2025-10-18 23:56:27.002691"
const char* root_1_2 = root_1[2]; // "NEW"
const char* root_1_3 = root_1[3]; // "USD"
const char* root_1_4 = root_1[4]; // "100"
const char* root_1_5 = root_1[5]; // "100"
const char* root_1_6 = root_1[6]; // "John"
const char* root_1_7 = root_1[7]; // "Doe"
const char* root_1_8 = root_1[8]; // "johndoeemail@hotmail.com"
const char* root_1_9 = root_1[9]; // "487.61"
JsonArray root_2 = doc[2];
const char* root_2_0 = root_2[0]; // "13"
const char* root_2_1 = root_2[1]; // "2025-10-18 23:57:25.438331"
const char* root_2_2 = root_2[2]; // "NEW"
const char* root_2_3 = root_2[3]; // "USD"
const char* root_2_4 = root_2[4]; // "100"
const char* root_2_5 = root_2[5]; // "50"
const char* root_2_6 = root_2[6]; // "John"
const char* root_2_7 = root_2[7]; // "Doe"
const char* root_2_8 = root_2[8]; // "johndoeemail@hotmail.com"
const char* root_2_9 = root_2[9]; // "537.61"
JsonArray root_3 = doc[3];
const char* root_3_0 = root_3[0]; // "14"
const char* root_3_1 = root_3[1]; // "2025-10-19 00:02:48.588411"
const char* root_3_2 = root_3[2]; // "NEW"
const char* root_3_3 = root_3[3]; // "USD"
const char* root_3_4 = root_3[4]; // "100"
const char* root_3_5 = root_3[5]; // "50"
const char* root_3_6 = root_3[6]; // "John"
const char* root_3_7 = root_3[7]; // "Doe"
const char* root_3_8 = root_3[8]; // "johndoeemail@hotmail.com"
const char* root_3_9 = root_3[9]; // "587.61"
JsonArray root_4 = doc[4];
const char* root_4_0 = root_4[0]; // "15"
const char* root_4_1 = root_4[1]; // "2025-10-19 00:03:11.233962"
const char* root_4_2 = root_4[2]; // "NEW"
const char* root_4_3 = root_4[3]; // "USD"
const char* root_4_4 = root_4[4]; // "100"
const char* root_4_5 = root_4[5]; // "50"
const char* root_4_6 = root_4[6]; // "John"
const char* root_4_7 = root_4[7]; // "Doe"
const char* root_4_8 = root_4[8]; // "johndoeemail@hotmail.com"
const char* root_4_9 = root_4[9]; // "637.61"
Serial.println(root_0_6);
//SCREEN STUFF HERE
//----------------------------------------Demo with "Arial_Black_16" font.
dmd.selectFont(Arial_Black_16);
//.................Running Text.
String txt_1 = "Wow Amanda!!! 200 pounds!!! ";
char char_array_txt_1[txt_1.length() + 1];
txt_1.toCharArray(char_array_txt_1, txt_1.length() + 1);
//dmd.clearScreen(true);
delay(1000);
dmd.drawMarquee(char_array_txt_1,txt_1.length(),(32*DISPLAYS_ACROSS)-1,0);
long start_1=millis();
long timer_1=start_1;
boolean ret=false;
while(!ret){
if ((timer_1+30) < millis()) {
ret=dmd.stepMarquee(-1,0);
timer_1=millis();
}
}
//.................
//.................Display Text.
dmd.clearScreen(true);
delay(1000);
dmd.drawString(0,0,"Thanks", 6, GRAPHICS_NORMAL); //--> dmd.drawString(x, y, Text, Number of characters in text, GRAPHICS_NORMAL);
delay(3000);
//.................
//----------------------------------------
//----------------------------------------Demo with "SystemFont5x7" font.
// If you use the font "SystemFont5x7", then 1 panel P10 (32x16) can display text in 2 rows.
dmd.selectFont(SystemFont5x7);
//.................The first row displays text and the second row displays running text.
int randNumber = random(4);
// if (randNumber = 0) {
String txt_2 = "You've helped a family when they needed it most.";
// }
// else if (randNumber = 1) {
// String txt_2 = "You've helped us help a child.";
// }
// else if (randNumber = 2) {
// String txt_2 = "You've put a plane in the air.";
// }
// else {
// String txt_2 = "You've changed a life today.";
// }
char char_array_txt_2[txt_2.length() + 1];
txt_2.toCharArray(char_array_txt_2, txt_2.length() + 1);
int scrl_long = (txt_2.length()*6) + (32*DISPLAYS_ACROSS);
dmd.clearScreen(true);
delay(1000);
// Displays text in the first row.
dmd.drawString(4,0,"Amanda:", 7, GRAPHICS_NORMAL);
long start_2=millis();
long timer_2=start_2;
int i = 32*DISPLAYS_ACROSS;
while(true){
if ((timer_2+30) < millis()) {
// Displays running text on the second row.
dmd.drawString(i, 9, char_array_txt_2, txt_2.length(), GRAPHICS_NORMAL);
if (i > ~scrl_long) {
i--;
} else {
break;
}
timer_2=millis();
}
}
//.................
//.................Display Text.
dmd.clearScreen(true);
delay(1000);
dmd.drawString(0,0,"Lias Wings", 10, GRAPHICS_NORMAL);
dmd.drawString(0,9,"thanks you", 10, GRAPHICS_NORMAL);
delay(3000);
//.................
//.................Display Text.
dmd.clearScreen(true);
delay(1000);
dmd.drawString(0,0,"Now raised", 10, GRAPHICS_NORMAL);
dmd.drawString(0,9,"110,089", 7, GRAPHICS_NORMAL);
delay(3000);
//.................
//.................Displays Text and Numbers.
int T = 29;
int H = 73;
char char_array_T[String(T).length() + 1];
char char_array_H[String(H).length() + 1];
String(T).toCharArray(char_array_T, String(T).length() + 1);
String(H).toCharArray(char_array_H, String(H).length() + 1);
dmd.clearScreen(true);
delay(1000);
dmd.drawString(0, 0, "T:", 2, GRAPHICS_NORMAL);
dmd.drawString(11, 0, char_array_T, String(T).length(), GRAPHICS_NORMAL);
dmd.drawCircle(24, 1, 1, GRAPHICS_NORMAL);
dmd.drawString(27, 0, "C", 1, GRAPHICS_NORMAL);
dmd.drawString(0, 9, "H:", 2, GRAPHICS_NORMAL);
dmd.drawString(11, 9, char_array_H, String(H).length(), GRAPHICS_NORMAL);
dmd.drawString(27, 9, "%", 1, GRAPHICS_NORMAL);
delay(5000);
dmd.clearScreen(true);
delay(5000);
//.................
//----------------------------------------
// Disconnect
http.end();
}
delay(10000);
}
Я не знаю, есть ли конфликт в коде или между двумя библиотеками. Может ли кто-нибудь помочь мне диагностировать, учитывая показанную ошибку? Спасибо!
Подробнее здесь:
https://stackoverflow.com/questions/798 ... it-with-ar
1762660666
Anonymous
Я немного застрял, так как написал код для ESP32, который должен делать две вещи: [list] [*]Извлекать некоторый JSON из источника HTTP и анализировать его с помощью ArduinoJSON - это работает изолированно; [*]Отображать значения на ЖК-экране P10 с помощью библиотеки DMD32 - это работает изолированно. [/list] Однако, когда я соединяю их вместе, происходит сбой ESP32. Вот ошибка последовательного монитора: [code]Start an alarm. assert failed: xQueueSemaphoreTake queue.c:1554 (!( ( xTaskGetSchedulerState() == ( ( BaseType_t ) 0 ) ) && ( xTicksToWait != 0 ) )) Rebooting... ets Jul 29 2019 12:21:46 rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0030,len:1324 ho 0 tail 12 room 4 load:0x40078000,len:13508 load:0x40080400,len:3604 entry 0x400805f0 [/code] Судя по комментированию кода, кажется, что это происходит, когда я запускаю timerAlarmEnable(timer); в строке 67 кода. Код ниже: [code]#include //--> DMD32 by Qudor-Engineer (KHUDHUR ALFARHAN) : https://github.com/Qudor-Engineer/DMD32 #include "fonts/SystemFont5x7.h" #include "fonts/Arial_black_16.h" //---------------------------------------- // Fire up the DMD library as dmd. #define DISPLAYS_ACROSS 2 #define DISPLAYS_DOWN 1 DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN); // Timer setup. // create a hardware timer of ESP32. hw_timer_t * timer = NULL; //________________________________________________________________________________IRAM_ATTR triggerScan() // Interrupt handler for Timer1 (TimerOne) driven DMD refresh scanning, // this gets called at the period set in Timer1.initialize(); void IRAM_ATTR triggerScan() { dmd.scanDisplayBySPI(); } #include #include #include const char* ssid = "JacqHousey2"; const char* password = "XXXX"; void setup() { Serial.begin(115200); delay(4000); Serial.println(); delay(500); Serial.println(); Serial.println("return the clock speed of the CPU."); // return the clock speed of the CPU. uint8_t cpuClock = ESP.getCpuFreqMHz(); delay(500); Serial.println(); Serial.println("Timer Begin"); // Use 1st timer of 4. // devide cpu clock speed on its speed value by MHz to get 1us for each signal of the timer. timer = timerBegin(0, cpuClock, true); delay(500); Serial.println(); Serial.println("Attach triggerScan function to our timer."); // Attach triggerScan function to our timer. timerAttachInterrupt(timer, &triggerScan, true); delay(500); Serial.println(); Serial.println("Set alarm to call triggerScan function."); // Set alarm to call triggerScan function. // Repeat the alarm (third parameter). timerAlarmWrite(timer, 300, true); delay(500); // THIS SECTION HERE CAUSES THE CRASH Serial.println(); Serial.println("Start an alarm."); // Start an alarm. timerAlarmEnable(timer); delay(500); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting to WiFi.."); } Serial.println("Connected to the WiFi network"); } void loop() { if ((WiFi.status() == WL_CONNECTED)) { //Check the current connection status WiFiClient client; // or WiFiClientSecure for HTTPS HTTPClient http; // Send request http.useHTTP10(true); http.begin(client, "http://bankethical.au/getlatestnames.php"); http.GET(); // Parse response DynamicJsonDocument doc(2048); deserializeJson(doc, http.getStream()); // Read values //Serial.println(doc["Donation"].as()); // Work out how many new donations there are int numdonors = doc.size(); JsonArray root_0 = doc[0]; const char* root_0_0 = root_0[0]; // "11" const char* root_0_1 = root_0[1]; // "2025-10-18 23:53:39.561412" const char* root_0_2 = root_0[2]; // "NEW" const char* root_0_3 = root_0[3]; // "USD" const char* root_0_4 = root_0[4]; // "100" const char* root_0_5 = root_0[5]; // "100" const char* root_0_6 = root_0[6]; // "John" const char* root_0_7 = root_0[7]; // "Doe" const char* root_0_8 = root_0[8]; // "johndoeemail@hotmail.com" const char* root_0_9 = root_0[9]; // "387.61" JsonArray root_1 = doc[1]; const char* root_1_0 = root_1[0]; // "12" const char* root_1_1 = root_1[1]; // "2025-10-18 23:56:27.002691" const char* root_1_2 = root_1[2]; // "NEW" const char* root_1_3 = root_1[3]; // "USD" const char* root_1_4 = root_1[4]; // "100" const char* root_1_5 = root_1[5]; // "100" const char* root_1_6 = root_1[6]; // "John" const char* root_1_7 = root_1[7]; // "Doe" const char* root_1_8 = root_1[8]; // "johndoeemail@hotmail.com" const char* root_1_9 = root_1[9]; // "487.61" JsonArray root_2 = doc[2]; const char* root_2_0 = root_2[0]; // "13" const char* root_2_1 = root_2[1]; // "2025-10-18 23:57:25.438331" const char* root_2_2 = root_2[2]; // "NEW" const char* root_2_3 = root_2[3]; // "USD" const char* root_2_4 = root_2[4]; // "100" const char* root_2_5 = root_2[5]; // "50" const char* root_2_6 = root_2[6]; // "John" const char* root_2_7 = root_2[7]; // "Doe" const char* root_2_8 = root_2[8]; // "johndoeemail@hotmail.com" const char* root_2_9 = root_2[9]; // "537.61" JsonArray root_3 = doc[3]; const char* root_3_0 = root_3[0]; // "14" const char* root_3_1 = root_3[1]; // "2025-10-19 00:02:48.588411" const char* root_3_2 = root_3[2]; // "NEW" const char* root_3_3 = root_3[3]; // "USD" const char* root_3_4 = root_3[4]; // "100" const char* root_3_5 = root_3[5]; // "50" const char* root_3_6 = root_3[6]; // "John" const char* root_3_7 = root_3[7]; // "Doe" const char* root_3_8 = root_3[8]; // "johndoeemail@hotmail.com" const char* root_3_9 = root_3[9]; // "587.61" JsonArray root_4 = doc[4]; const char* root_4_0 = root_4[0]; // "15" const char* root_4_1 = root_4[1]; // "2025-10-19 00:03:11.233962" const char* root_4_2 = root_4[2]; // "NEW" const char* root_4_3 = root_4[3]; // "USD" const char* root_4_4 = root_4[4]; // "100" const char* root_4_5 = root_4[5]; // "50" const char* root_4_6 = root_4[6]; // "John" const char* root_4_7 = root_4[7]; // "Doe" const char* root_4_8 = root_4[8]; // "johndoeemail@hotmail.com" const char* root_4_9 = root_4[9]; // "637.61" Serial.println(root_0_6); //SCREEN STUFF HERE //----------------------------------------Demo with "Arial_Black_16" font. dmd.selectFont(Arial_Black_16); //.................Running Text. String txt_1 = "Wow Amanda!!! 200 pounds!!! "; char char_array_txt_1[txt_1.length() + 1]; txt_1.toCharArray(char_array_txt_1, txt_1.length() + 1); //dmd.clearScreen(true); delay(1000); dmd.drawMarquee(char_array_txt_1,txt_1.length(),(32*DISPLAYS_ACROSS)-1,0); long start_1=millis(); long timer_1=start_1; boolean ret=false; while(!ret){ if ((timer_1+30) < millis()) { ret=dmd.stepMarquee(-1,0); timer_1=millis(); } } //................. //.................Display Text. dmd.clearScreen(true); delay(1000); dmd.drawString(0,0,"Thanks", 6, GRAPHICS_NORMAL); //--> dmd.drawString(x, y, Text, Number of characters in text, GRAPHICS_NORMAL); delay(3000); //................. //---------------------------------------- //----------------------------------------Demo with "SystemFont5x7" font. // If you use the font "SystemFont5x7", then 1 panel P10 (32x16) can display text in 2 rows. dmd.selectFont(SystemFont5x7); //.................The first row displays text and the second row displays running text. int randNumber = random(4); // if (randNumber = 0) { String txt_2 = "You've helped a family when they needed it most."; // } // else if (randNumber = 1) { // String txt_2 = "You've helped us help a child."; // } // else if (randNumber = 2) { // String txt_2 = "You've put a plane in the air."; // } // else { // String txt_2 = "You've changed a life today."; // } char char_array_txt_2[txt_2.length() + 1]; txt_2.toCharArray(char_array_txt_2, txt_2.length() + 1); int scrl_long = (txt_2.length()*6) + (32*DISPLAYS_ACROSS); dmd.clearScreen(true); delay(1000); // Displays text in the first row. dmd.drawString(4,0,"Amanda:", 7, GRAPHICS_NORMAL); long start_2=millis(); long timer_2=start_2; int i = 32*DISPLAYS_ACROSS; while(true){ if ((timer_2+30) < millis()) { // Displays running text on the second row. dmd.drawString(i, 9, char_array_txt_2, txt_2.length(), GRAPHICS_NORMAL); if (i > ~scrl_long) { i--; } else { break; } timer_2=millis(); } } //................. //.................Display Text. dmd.clearScreen(true); delay(1000); dmd.drawString(0,0,"Lias Wings", 10, GRAPHICS_NORMAL); dmd.drawString(0,9,"thanks you", 10, GRAPHICS_NORMAL); delay(3000); //................. //.................Display Text. dmd.clearScreen(true); delay(1000); dmd.drawString(0,0,"Now raised", 10, GRAPHICS_NORMAL); dmd.drawString(0,9,"110,089", 7, GRAPHICS_NORMAL); delay(3000); //................. //.................Displays Text and Numbers. int T = 29; int H = 73; char char_array_T[String(T).length() + 1]; char char_array_H[String(H).length() + 1]; String(T).toCharArray(char_array_T, String(T).length() + 1); String(H).toCharArray(char_array_H, String(H).length() + 1); dmd.clearScreen(true); delay(1000); dmd.drawString(0, 0, "T:", 2, GRAPHICS_NORMAL); dmd.drawString(11, 0, char_array_T, String(T).length(), GRAPHICS_NORMAL); dmd.drawCircle(24, 1, 1, GRAPHICS_NORMAL); dmd.drawString(27, 0, "C", 1, GRAPHICS_NORMAL); dmd.drawString(0, 9, "H:", 2, GRAPHICS_NORMAL); dmd.drawString(11, 9, char_array_H, String(H).length(), GRAPHICS_NORMAL); dmd.drawString(27, 9, "%", 1, GRAPHICS_NORMAL); delay(5000); dmd.clearScreen(true); delay(5000); //................. //---------------------------------------- // Disconnect http.end(); } delay(10000); } [/code] Я не знаю, есть ли конфликт в коде или между двумя библиотеками. Может ли кто-нибудь помочь мне диагностировать, учитывая показанную ошибку? Спасибо! Подробнее здесь: [url]https://stackoverflow.com/questions/79814584/esp32-code-crashes-gets-data-from-an-adi-using-httpclient-h-parses-it-with-ar[/url]