Max7219 multiple display not showing properly

Hello all,

I had a project to display time and temperature by using multiple module Max7219 32 x 8 (4 in 1), DHT22 as the temperature sensor and ESP32 as the microcontroller. My plan was too used 3 max7219, 1st would be showing time and 2nd & 3rd temperature and humidity.

Now i found a problem, the 2nd & 3rd led not showing the text as i wanted. Even the third not showing anything. Even i try a simple animation just to see if its worked the connection or not.

I've read some information that some say more than 1 max7219 cannot be connected using jumper cable. but i find it odd that they got the slot for extension.
Below is the schematic diagram (just imagine there are 3 max7219 4in1)

And below is the coding

// REQUIRES the following Arduino libraries:
// - ThingSpeak library: https://github.com/mathworks/thingspeak-arduino
// - MD_Parola Library: https://github.com/MajicDesigns/MD_Parola
// - MD_MAX72XX library can be found at https://github.com/MajicDesigns/MD_MAX72XX
// Find All "Great Projects" Videos : https://www.youtube.com/channel/UCCC8DuqicBtP3A_aC53HYDQ/videos

// Header file includes
#include <WiFi.h>
#include <time.h>
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include <SimpleDHT.h>
#include "secrets.h"
#include "Font_Data.h"
int pinDHT11 = 14;
SimpleDHT11 dht11(pinDHT11);

// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 12

#define CLK_PIN   18  // or SCK
#define DATA_PIN  19  // or MOSI
#define CS_PIN    5  // or SS

// SPI hardware interface
//MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// SOFTWARE SPI
MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

#define SPEED_TIME  60
#define PAUSE_TIME  0
#define MAX_MESG  75

char ssid[] = SECRET_SSID;   // your network SSID (name) 
char pass[] = SECRET_PASS;   // your network password
WiFiClient  client;


char Message[MAX_MESG+1] = { "Happy Happy Happy" };
char WeatherTh[MAX_MESG+1] = "";
int timezone = 1;
int dst = 0;
uint16_t  h, m, s;
uint8_t dow;
int  day;
uint8_t month;
String  year;
// Global variables
char szTime[9];    // mm:ss\0
char szsecond[4];    // ss
char szMesg[MAX_MESG+1] = "";

uint8_t degC[] = { 6, 3, 3, 56, 68, 68, 68 }; // Deg C

char *mon2str(uint8_t mon, char *psz, uint8_t len)
// Get a label from PROGMEM into a char array
{
  static const char str[][10] PROGMEM =
  {
    "January", "February", "March", "April", "May", "June",
    "July", "August", "September", "October", "November", "December"
  };

  *psz = '\0';
  mon--;
  if (mon < 12)
  {
    strncpy_P(psz, str[mon], len);
    psz[len] = '\0';
  }

  return(psz);
}

char *dow2str(uint8_t code, char *psz, uint8_t len)
{
  static const char str[][10] PROGMEM =
  {
    "Sunday", "Monday", "Tuesday", "Wednesday",
    "Thursday", "Friday", "Saturday"
  };

  *psz = '\0';
  code--;
  if (code < 7)
  {
    strncpy_P(psz, str[code], len);
    psz[len] = '\0';
  }

  return(psz);
}
void getsec(char *psz)
// Code for reading clock date
{
  sprintf(psz, "%02d", s);
}
void getTime(char *psz, bool f = true)
// Code for reading clock time
{
  time_t now = time(nullptr);
  struct tm* p_tm = localtime(&now);
      h = p_tm->tm_hour;
      m = p_tm->tm_min;
      s = p_tm->tm_sec;
  sprintf(psz, "%02d%c%02d", h, (f ? ':' : ' '), m);
}

void getDate(char *psz)
// Code for reading clock date
{
  char  szBuf[10];
  time_t now = time(nullptr);
  struct tm* p_tm = localtime(&now);
      dow = p_tm->tm_wday+1;
      day = p_tm->tm_mday;
      month = p_tm->tm_mon + 1;
  sprintf(psz, "%d %s %04d", day, mon2str(month, szBuf, sizeof(szBuf)-1), (p_tm->tm_year + 1900));
}
void getTemperatur(char *psz)
// Code for reading clock date
{
  // read without samples.
  byte temperature = 0;
  byte humidity = 0;
  int err = SimpleDHTErrSuccess;
  if ((err = dht11.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    delay(100);
    return;
  }
        strcpy(szMesg, "Temperature : ");
          dtostrf((int)temperature, 3, 1, WeatherTh);
          strcat(szMesg, WeatherTh);
          strcat(szMesg, " $");
}
void getHumidit(char *psz)
// Code for reading clock date
{
  // read without samples.
  byte temperature = 0;
  byte humidity = 0;
  int err = SimpleDHTErrSuccess;
  if ((err = dht11.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    delay(100);
    return;
  }
        strcpy(szMesg, "Humidity : ");
          dtostrf((int)humidity, 3, 1, WeatherTh);
          strcat(szMesg, WeatherTh);
          strcat(szMesg, " % RH");
}

void setup(void)
{
  Serial.begin(115200);  // Initialize serial
  WiFi.mode(WIFI_STA); 
  getTimentp();
  delay(2000);  
  P.begin(3);
  P.setInvert(false);
  P.setZone(0, 0, 7);
  P.setZone(1, 8, 8);
  P.setZone(2, 9, 11);
  P.setFont(1, numeric7Seg);
  P.setFont(2, numeric7Se);
  P.displayZoneText(0, szMesg, PA_CENTER, SPEED_TIME, 0, PA_PRINT, PA_SCROLL_LEFT);
  P.displayZoneText(1, szsecond, PA_LEFT, SPEED_TIME, 0, PA_PRINT, PA_NO_EFFECT);
  P.displayZoneText(2, szTime, PA_CENTER, SPEED_TIME, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);
 
  P.addChar('$', degC);
}

void loop(void)
{
  static uint32_t lastTime = 0; // millis() memory
  static uint8_t  display = 0;  // current display mode
  static bool flasher = false;  // seconds passing flasher

  P.displayAnimate();
  // Finally, adjust the time string if we have to
  if (millis() - lastTime >= 1000)
  {
    lastTime = millis();
    getsec(szsecond);
    getTime(szTime, flasher);
    flasher = !flasher;

    P.displayReset(1);
    P.displayReset(2);
  }

  if (P.getZoneStatus(0))
  {
    switch (display)
    {

      case 0: // Temperature deg C
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        display++;
        getTemperatur(szMesg);
    Serial.println(szMesg);
        break;

      case 1:  // Relative Humidity
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        getHumidit(szMesg);
    Serial.println(szMesg);
        display++;
        break;
        
      case 2: // day of week
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        display++;
        dow2str(dow, szMesg, MAX_MESG);
    Serial.println(szMesg);
        break;

      case 3: // Date
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        getDate(szMesg);
    Serial.println(szMesg);
        display++;
        break;

      default: // Message
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        strcpy(szMesg, Message);
    Serial.println(szMesg);
        display = 0;
        break;
    }

    P.displayReset(0);
  }

}

void getTimentp()
{
  if(WiFi.status() != WL_CONNECTED){
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(SECRET_SSID);
      WiFi.begin(ssid, pass); // Connect to WPA/WPA2 network.
    while(WiFi.status() != WL_CONNECTED){
      Serial.print(".");
      delay(200);     
    } 
  }
    Serial.println("Connected");
  configTime(timezone * 3600, dst, "pool.ntp.org","time.nist.gov");
  while(!time(nullptr)){
        Serial.print(".");
        delay(100);
  }
        Serial.print("Time Update");
      delay(2000);     
}

Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE

How you are powering those displays? Your ESP32 can't provide enough current to drive them directly.

I have tried 2 different ways. Using laptop usb and adapter 20 & 25 w
The result is always the same. The first led running normal, but the 2nd & 3rd not

You need two things

  1. Level shifters to convert the ESP32 3.3V signals to 5V for the MAX.
  2. Separate and more direct 5V power feeds, star not daisy chain topology
1 Like

I understand MAX 72xx is very particular about power, and requires more than you would expect for a device designed to save power. Check here
If your ESP isn't up to the job, it wouldn't surprise me, and no amount of level shifting will save you. If your ESP only accepts 3.3v power, you will probably be better off stepping down off the power provided expressly for the 7221s.

1 Like

Okay thank you guys for the answers. I'll try to fix it :+1:

Hi, @falram
Welcome to the forum

Sorry but did you write this code in stages?

Have you got code that JUST tests the displays?
If not, then for the moment FORGET your code and write some simple code to JUST control your displays.
You need to establish you can communicate with them first.

First the top display on its own.
Then the next display on its own.
Then the last display on its own.

Just display simple characters.

Once you have got each of the codes working, combine them ONE at a time, each time getting the combination working before adding the next

The code JUST the sensor and get it working.

Looking at your code with all the WiFi and stuff, when did you find the displays didn't work properly?

Thanks... Tom.. :smiley: :+1: :coffee: :australia:

Thank you for the explanation. I found the problem didn't work properly when i combined all 3 of the MAX. I was testing one by one, and then try 2 MAX still okay. After add the third, it went blank nothing came out even i try a simple code just for simple animation

Sounds very much like inadequate power!

1 Like

The 20W adapter they mentioned should have been sufficient, though... maybe the wiring?

@falram, you didn't give us a real update with diagram, images etc. just word salad.

HI,
Thanks for the relpy.

Was that with all the WiFi and DHT in the code as well?

Tom.. :smiley: :+1: :coffee: :australia:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.