I want to integrate the DMD2 and MQTT client in my project. I met a problem that the DMD2 can't normally driver the P10 LED matrix, I saw that throw exceptions in the Serial Monitor.
Here is the Code.
/*
SimpleMQTTClient.ino
The purpose of this exemple is to illustrate a simple handling of MQTT and Wifi connection.
Once it connects successfully to a Wifi network and a MQTT broker, it subscribe to a topic and send a message to it.
It will also send a message delayed 5 seconds later.
*/
#include "EspMQTTClient.h"
#include <SPI.h>
#include <DMD2.h>
#include <fonts/Arial14.h>
// Set Width to the number of displays wide you have
const int WIDTH = 1;
// You can change to a smaller font (two lines) by commenting this line,
// and uncommenting the line after it:
const uint8_t *FONT = Arial14;
char str[1024] = "hello,world. ";
bool changed = false;
SPIDMD dmd(WIDTH,1); // DMD controls the entire display
DMD_TextBox box(dmd); // "box" provides a text box to automatically write to/scroll the display
EspMQTTClient client(
"Tenda_EA3EA0",
"DeYuan8888",
"192.168.1.8", // MQTT Broker server ip
"admin", // Can be omitted if not needed
"123456", // Can be omitted if not needed
"TestClient", // Client name that uniquely identify your device
1883 // The MQTT port, default to 1883. this line can be omitted
);
void setup()
{
Serial.begin(115200);
// Optionnal functionnalities of EspMQTTClient :
client.enableDebuggingMessages(); // Enable debugging messages sent to serial output
client.enableHTTPWebUpdater(); // Enable the web updater. User and password default to values of MQTTUsername and MQTTPassword. These can be overrited with enableHTTPWebUpdater("user", "password").
client.enableLastWillMessage("TestClient/lastwill", "I am going offline"); // You can activate the retain flag by setting the third parameter to true
dmd.setBrightness(255);
dmd.selectFont(FONT);
dmd.begin();
}
// This function is called once everything is connected (Wifi and MQTT)
// WARNING : YOU MUST IMPLEMENT IT IF YOU USE EspMQTTClient
void onConnectionEstablished()
{
// Subscribe to "mytopic/test" and display received message to Serial
client.subscribe("mytopic/test", [](const String & payload) {
Serial.println(payload);
strcpy(str, payload.c_str());
changed=true;
});
// Publish a message to "mytopic/test"
client.publish("mytopic/test", "This is a message"); // You can activate the retain flag by setting the third parameter to true
// Execute delayed instructions
client.executeDelayed(5 * 1000, []() {
client.publish("mytopic/test", "This is a message sent 5 seconds later");
});
}
void loop()
{
client.loop();
Serial.println(str);
const char* next = str;
changed = false;
while(*next && !changed) {
Serial.print(*next);
box.print(*next);
delay(100);
next++;
}
}
Exception 0: Illegal instruction
PC: 0x4020d0a8: scan_running_dmds() at D:\Documents\Arduino\libraries\DMD2\DMD2_Timer.cpp line 214
EXCVADDR: 0x00000000
Decoding stack results
0x40100364: ets_post(uint8, ETSSignal, ETSParam) at D:\marryton007\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\core_esp8266_main.cpp line 160
0x40100b2c: umm_free_core(void*) at D:\marryton007\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\umm_malloc\umm_malloc.cpp line 316
0x401003b5: __wrap_spi_flash_read(uint32_t, uint32_t*, size_t) at D:\marryton007\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\core_esp8266_phy.cpp line 309
0x40206826: ESP8266WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool) at D:\marryton007\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 189
0x4020677b: ESP8266WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool) at D:\marryton007\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 157
0x40100900: uart_isr(void*) at D:\marryton007\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\uart.cpp line 383
0x40100c54: umm_malloc_core(size_t) at D:\marryton007\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\umm_malloc\umm_malloc.cpp line 424
0x40100b00: umm_free_core(void*) at D:\marryton007\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\umm_malloc\umm_malloc.cpp line 303
0x40100dec: malloc(size_t) at D:\marryton007\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\umm_malloc\umm_malloc.cpp line 511
0x40206600: ESP8266WiFiSTAClass::hostname(char const*) at D:\marryton007\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 586
0x40206645: ESP8266WiFiSTAClass::hostname(char const*) at D:\marryton007\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 596
0x40201b0f: EspMQTTClient::connectToWifi() at D:\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp line 407
0x4020504f: EspMQTTClient::loop() at D:\Documents\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp line 260
0x40100e35: realloc(void*, size_t) at D:\marryton007\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\umm_malloc\umm_malloc.cpp line 545
0x4020ca1c: BaseDMD::beginNoTimer() at D:\Documents\Arduino\libraries\DMD2\DMD2.cpp line 200
0x40100549: timer0_attachInterrupt(timercallback) at D:\marryton007\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\core_esp8266_timer.cpp line 100
0x40201207: loop() at D:\Documents\Arduino\led_mqtt/led_mqtt.ino line 72
0x402102d0: loop_wrapper() at D:\marryton007\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\core_esp8266_main.cpp line 180
Hardware: Wemos D1 R1 + P10 LED matrix Software: Arduino 1.8.10 + DMD2 0.0.3 + EspMQttClient
I want to integrate the DMD2 and MQTT client in my project. I met a problem that the DMD2 can't normally driver the P10 LED matrix, I saw that throw exceptions in the Serial Monitor.
Here is the Code.
Exception decode by the EspExceptionDecoder
Any help is thankful.