Problema con matriz led MAX7219 y NodeMCU

Hola! Tengo un problema para usar una matriz led 8x32 basada en MAX7219, con una placa NodeMCu (LOLIN wemos V3) el programa carga correctamente, pero en la matriz led no aparece absolutamente nada. Aclaro que la matriz es alimentada con una fuente de 5Vdc.
Aqui va el codigo:

#include <ESP8266WiFi.h>
#include <Wire.h>
#include <RTClib.h>
#include <MD_Parola.h>
#include <MD_MAX72xx.h>

// Configuración de hardware del MAX7219
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CS_PIN D8

// Configuración WiFi
const char* ssid = "TuSSID";
const char* password = "TuContraseña";

// Instancias
WiFiServer server(80);
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
RTC_DS3231 rtc;

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

  // Inicia la matriz LED
  P.begin();
  P.setIntensity(5);
  P.displayClear();

  // Configura Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print(".");
  }
  Serial.println("\nWi-Fi conectado.");
  Serial.println("IP: " + WiFi.localIP().toString());
  server.begin();

  // Inicia el RTC
  if (!rtc.begin()) {
    Serial.println("No se encontró el RTC.");
    while (1);
  }
  if (rtc.lostPower()) {
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // Configura hora inicial
  }
}

void loop() {
  WiFiClient client = server.available();
  if (client) {
    Serial.println("Cliente conectado");
    String request = client.readStringUntil('\r');
    client.flush();

    // Procesar datos recibidos
    if (request.indexOf("/submit") != -1) {
      String message = getParameter(request, "message");
      String addDateTime = getParameter(request, "addDateTime");

      // Muestra el texto en la matriz LED
      if (addDateTime == "true") {
        DateTime now = rtc.now();
        message += " - " + String(now.day()) + "/" + String(now.month()) + "/" + String(now.year());
        message += " " + String(now.hour()) + ":" + String(now.minute());
      }
      P.displayText(message.c_str(), PA_CENTER, 100, 1000, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
    }

    // Enviar la página HTML
    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/html");
    client.println();
    client.println(generateHTML());
    client.stop();
  }

  if (P.displayAnimate()) {
    P.displayReset();
  }
}

// Genera la página HTML
String generateHTML() {
  return R"rawliteral(
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Matriz LED Control</title>
  <style>
    body { font-family: Arial, sans-serif; text-align: center; margin-top: 50px; }
    input, button { font-size: 1.2em; margin: 10px; }
    .switch { position: relative; display: inline-block; width: 60px; height: 34px; }
    .switch input { display: none; }
    .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 34px; }
    .slider:before { position: absolute; content: ""; height: 26px; width: 26px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; }
    input:checked + .slider { background-color: #2196F3; }
    input:checked + .slider:before { transform: translateX(26px); }
  </style>
</head>
<body>
  <h1>Control de Matriz LED</h1>
  <form id="controlForm">
    <input type="text" id="message" placeholder="Escribe tu mensaje" required>
    <br>
    <label class="switch">
      <input type="checkbox" id="addDateTime">
      <span class="slider"></span>
    </label>
    <label for="addDateTime">Incluir Fecha y Hora</label>
    <br>
    <button type="button" onclick="submitForm()">SUBIR</button>
  </form>

  <script>
    function submitForm() {
      const message = document.getElementById('message').value;
      const addDateTime = document.getElementById('addDateTime').checked;
      fetch(`/submit?message=${encodeURIComponent(message)}&addDateTime=${addDateTime}`)
        .then(response => {
          if (response.ok) alert("Datos enviados correctamente.");
          else alert("Error al enviar los datos.");
        });
    }
  </script>
</body>
</html>
)rawliteral";
}

// Obtiene parámetros de la solicitud
String getParameter(String request, String param) {
  int startIndex = request.indexOf(param + "=");
  if (startIndex == -1) return "";
  int endIndex = request.indexOf("&", startIndex);
  if (endIndex == -1) endIndex = request.indexOf(" ", startIndex);
  return request.substring(startIndex + param.length() + 1, endIndex);
}

El rtc funciona correctamente, por lo que no se encierra en el bucle:

// Inicia el RTC
  if (!rtc.begin()) {
    Serial.println("No se encontró el RTC.");
    while (1);
     }

Esta es la conexión de la matriz led:

Y esta es la conexión del rtc DS3231:

Creo que te falta incluir la librería SPI.

Ya está solucionado el problema!!!, incorporé un convertidor de niveles logicos 5v-3.3v a las lineas CS,DIN,CLK entre la NodeMCU y la matriz led MAX7219.
Con Esto se soluciono el problema y todo anda perfectamente.

Que raro que no funcione con 3.3V en teoría el nivel lógico alto esta garantizado con ese valor. Luego lo pruebo. Veo muchos esquemas con ESP8266 y MAX7219 sin adaptador de niveles. Algo mas ocurre ahi, pero ya lo resolviste.

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