Problem using rf24 NRF24L01 transceiver with LED matrix MD_MAX72xx together

here is my project and my problem. I have 2 transceivers NRF24L01, each one is connected to an arduino Mega 2560. I have a good communication between them and I had no problem transferring data wireless until I decided to attach to the one which is receiver a LED Matrix 7219 which has 4 x 8x8 LED.

I also tested the display first before integration and I can display anything without any problem using MD_Parola scripts. The problem appear after integration. I want my data received, temperature in my case to be displayed. The temperature is received and displayed but just one time and first time. If I reset the Mega2560 again new temperature is received and displayed.

To investigate more I followed messages transfer and I see on serial very clear that 2nd and all next messages are not transmitted. During communication I just unplugged the all cables connected to my Matrix7219 and I observed that all next messages with new temperature are sent and received without any problem. Then I tried to give a different plus power supply but the behavior is the same. What could be?

Here below is my code of receiver having the two devices not well integrated together.

#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include <VirtualWire.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>

// Define hardware type, size, and output pins:
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CLK_PIN   6
#define DATA_PIN  7
#define CS_PIN    8
float OutsideTemp = 0;
bool newmessage = false;

//Global message buffers shared by Serial and Scrolling functions
#define BUF_SIZE 75
char curMessage[BUF_SIZE] = { "" };

RF24 radio(9, 10); // CE, CSN
const uint64_t pipe[2] = {0xE6E8F4F4E1BB, 0xE6E8F4F4E1DD}; //send to LV, receive from LV
// Setup for software SPI:
// #define DATAPIN 2
// #define CLK_PIN 4
MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
//const byte address[6] = "00001";
//We could use up to 32 channels
void setup(){
  Serial.begin(9600); //Set the speed to 9600 bauds if you want.
  radio.begin();
  radio.openReadingPipe(1, pipe[1]);
  printf_begin();
  radio.setDataRate(RF24_250KBPS);
  radio.setPALevel(RF24_PA_MAX);
  radio.setChannel(120); //if needed
  radio.startListening(); //start radio in receiver mode
   // Intialize the object:
  myDisplay.begin();
  // Set the intensity (brightness) of the display (0-15):
  myDisplay.setIntensity(0);
  // Clear the display:
  myDisplay.displayClear();
}

void loop(){
    //radio.startListening();
    if (radio.available()){
        Serial.println("Radio receive is available"); 
        radio.read(&OutsideTemp,sizeof(OutsideTemp));  
        Serial.print("TEMPERATURE: "); Serial.println(OutsideTemp);
        newmessage = true;
        delay(2000);
    }
    else {
      //Serial.println("Check your radio");
      Serial.print("NEWtemp: "); Serial.println(OutsideTemp);
    }  
    if (newmessage){
        char mydata[20];
        String mybuffer = "";
        mybuffer = (String)OutsideTemp;
        mybuffer.toCharArray(mydata, 20);
        strcpy(curMessage, mydata);
        if (myDisplay.displayAnimate()) {
          Serial.println("The DISPLAY should start");
          myDisplay.displayText(curMessage, PA_CENTER, 20, 100, PA_PRINT);
          while(!myDisplay.displayAnimate());
          myDisplay.displayReset();
          newmessage = false;
        } 
      delay(100);
    }
}

I think you have the logic wrong in this section of code:

 if (newmessage){
        char mydata[20];
        String mybuffer = "";
        mybuffer = (String)OutsideTemp;
        mybuffer.toCharArray(mydata, 20);
        strcpy(curMessage, mydata);
        if (myDisplay.displayAnimate()) {
          Serial.println("The DISPLAY should start");
          myDisplay.displayText(curMessage, PA_CENTER, 20, 100, PA_PRINT);
          while(!myDisplay.displayAnimate());
          myDisplay.displayReset();
          newmessage = false;
        }
      delay(100);

You should first check if displayAnimate() returns true. When it does, if there is a new message then load it into the buffer. This is how the logic works in the example programs.

Also, get rid of the delay, it does not serve any purpose and is likely to screw things up.

How could be the logic wrong? First I wait for message to be received, after the message is received display and wait for display to finish then wait next message to be received. Following this on serial works great and the serial messages are: "new value" very fast many lines waiting for message, when message comes it is a delay, get the value and then display the value then printing fast the new value in many lines. Next message comes never even if I'm in waiting loop.

So the logic sequence is very well but it stuck in receiving the second message. For the moment I solved a little bit of this problem by introducing a soft board restart every 10 minutes, this works but I don't like this solution.

The problem stuck is not observed that the new value is not displayed, but it is observed that even it is in waiting loop for the message the message is not received. And on the other side of the transmitter it is observed that sending is done unsuccessfully.

I think that the problem is somewhere in SPI, data clocking CS for the two modules, but I can't see very well where is the problem.

Where does the power for the LED-Matrix come from?
You wrote it is working for about tenminutes and then you do a reset.

If you supply the LED-Matrix from the Arduino-Mega driectly this is likely to pull too much current
or if you feed in 12V that too much power has to be disspitated by the voltage regulator.

Also these nRF24-tranceivers like to have a 100µF capacitor connected as close as possible to the Vcc and GND of the nRF24-board.

best regards Stefan

ok, we go deeper in the problem. The power for both modules is from arduino Mega2560. But because NRF24 needs 3.3V and a stability I added the dedicated module adapter to NRF24 which get 5V from Mega2560 and give needed power to NRF24. That device is also very good for changing NRF24 module very easy, so I think that the capacitor you are talking about is not necessary anymore as soon as I gave this dedicated adapter.

Something else strange is that I tried to give power supply for Matrix from another Mega2560 board and the results were strange, the display of data was incorrect, unclear, unreadable, something like missed synchro. What synchro as soon as I just give supply from another source.

Let see more about SPI hardware or software used and investigate in this way. I don't think that nobody did this project to display a message on this Matrix got from radio RF24.

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