MQTT enabled led sign

i’m using this:
3x FC16 display (search aliexpress for ‘4 in one dot matrix max7219’)
Wemos D1 Mini
MD_Parola arduino lib (https://github.com/MajicDesigns/MD_Parola)
MAX7219 arduino lib (https://github.com/MajicDesigns/MD_MAX72XX)
esp8266 ntpclient (https://github.com/gmag11/NtpClient)
homie-esp8266 (https://github.com/marvinroger/homie-esp8266)
homie-eps8266 is excellent because you can setup the esp8266 via a web configpage, no more wifi credentials in your source code!

i’m using this sketch at the moment. Can use some serious help with this as the esp watchdog is giving me headaches when scrolling long lines of text. I tried to resolve this by adding a lot of ‘ESP.wdtFeed();’ all over the place…had to disable serial to make it usable…

#include <Homie.h>
#include <SPI.h>
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <TimeLib.h>
#include <NtpClientLib.h>

////////////////////////////////////////////////////////////////////////
//PAROLA
////////////////////////////////////////////////////////////////////////
#define  MAX_DEVICES 12
#define CLK_PIN   14
#define DATA_PIN  13
#define CS_PIN    15
MD_Parola P = MD_Parola(DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
//MD_Parola P = MD_Parola(CS_PIN, MAX_DEVICES);

HomieNode textNode("text", "sign");

bool textOnHandler(const HomieRange& range, const String& value) {
  String text = "   +++++ " + value + " +++++   ";
  int value_len = text.length() + 1 ;
  char txtbuffer[value_len] ;
  text.toCharArray(txtbuffer, value_len );
  ESP.wdtFeed();
  textNode.setProperty("on").send(value);
  P.displayText(txtbuffer , PA_CENTER, 20, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT );
  ESP.wdtFeed();
  while (!P.displayAnimate()) {
    delay(500);
    ESP.wdtFeed();
  }
  ESP.wdtFeed();
  Homie.getLogger() << "text is " << value << endl;
  ESP.wdtFeed();
  return true;
}

void setup() {
  ESP.wdtDisable();
  ESP.wdtEnable(WDTO_8S);
  P.begin();
  //Serial.begin(115200);
  Serial << endl << endl;
  Homie_setFirmware("awesome-sign", "1.0.0");
  textNode.advertise("on").settable(textOnHandler);
  Homie.setup();
  P.displayText("Initialising ...", PA_CENTER, 1, 2000, PA_PRINT, PA_PRINT );
  while (!P.displayAnimate());
  NTP.onNTPSyncEvent([](NTPSyncEvent_t error) {
    if (error) {
      Serial.print("Time Sync error: ");
      if (error == noResponse)
        Serial.println("NTP server not reachable");
      else if (error == invalidAddress)
        Serial.println("Invalid NTP server address");
    }
    else {
      Serial.print("Got NTP time: ");
      Serial.println(NTP.getTimeDateString(NTP.getLastNTPSync()));
    }
  });
  NTP.begin("pool.ntp.org", 1, true);
  NTP.setInterval(1800);
}

void loop() {
  Homie.loop();
  char charBuf[100];
  sprintf(charBuf, "%02u : %02u", hour(), minute());
  P.displayText(charBuf, PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT );
  while (!P.displayAnimate())
  ESP.wdtFeed();
  }
2 Likes