Problem RF24 TX RX

Good evening, I have a problem that has occurred to me.
I created a radio remote control using two RF2401, where TX transmits a value (A0) to RX. Everything worked fine, after a while using the stops to receive TX value by printing “Value 0”
For the first time I had solved the game by an arduino NANO chinese to UNO but now even ONE gives me the same problem.

The absurd thing is that it worked properly for 2 days until it stopped completely.
I do not know if this is a hardware or software issue, can anyone help me?

TX:

#include <SPI.h>                      //the communication interface with the modem
#include "RF24.h"                     //the library which helps us to control the radio modem

int msg;

RF24 radio(9,10);                     //9 and 10 are a digital pin numbers to which signals CE and CSN are connected.
                                      
const uint64_t pipe = 0xE8E8F0F0E1LL; //the address of the modem, that will receive data from Arduino.


void setup(void){
  radio.begin();                      //it activates the modem.
  radio.openWritingPipe(pipe);  //sets the address of the receiver to which the program will send data.
Serial.begin(9600);

}

void loop(void){

  msg =  map (analogRead(A0), 478,1023,1500,2300);
  Serial.print(msg);
  Serial.print("\n");;
  delay(1);
  
  //radio.write(&msg, );
  radio.write(&msg, sizeof(msg));
}

RX:

#include <Servo.h>    //the library which helps us to control the servo motor
#include <SPI.h>      //the communication interface with the modem
#include "RF24.h"     //the library which helps us to control the radio modem

Servo ESC;        //define the servo name

RF24 radio(9, 10);     /*This object represents a modem connected to the Arduino.
                      Arguments 9 and 10 are a digital pin numbers to which signals
                      CE and CSN are connected.*/

const uint64_t pipe = 0xE8E8F0F0E1LL; //the address of the modem,that will receive data from the Arduino.

int msgRX;
//int avvio = 1500;

void setup() {
  ESC.attach(3);//3 is a digital pin to which servo signal connected.
  //ESC.write(avvio);
  //delay(7000);
  radio.begin();                    //it activates the modem.
  radio.openReadingPipe(1, pipe);   //determines the address of our modem which receive data.
  radio.startListening();//enable receiving data via modem
 
  Serial.begin(9600);
}


void loop() {

  ESC.write(msgRX);
  radio.read(&msgRX, sizeof(msgRX));

  Serial.print("Mapped Input Value:");
  Serial.print(msgRX);                      //Serial print the mapped input value
  Serial.print("\n");;
  delay(1);

}

Try switching pins for the RF24. The servo library uses pin 9 and 10 so maybe it's messing with the signal. I use pin 7 and 8 for mine and it always works

Servo doesn't use those pins at all. It uses the timer that would control pwm for those pins. But it doesn't affect the pins at all.

I tried but it does not work. How can a sketch run for two days and then no longer work? I tried with other RF24 modules but i have problem, i tried with Arduino Nano and one for RX but now i only get value = 0. : '(

federik87: but now i only get value = 0.

I don't follow. There's nothing in either sketch called value.

Serial.print("Mapped Input Value:");

Before the problem in serial printing I received the value of (A0) example "1500 or 2000" on TX now only 0

That line prints a constant string. Are you talking about where you print msgRX right after that?

Working for a few days and then stopping typically points to either a memory leak or a power issue.

The strange thing is that the sketch first stopped working on Nano, then thinking it was a problem with the Chinese card I used Arduino ONE, it ran smoothly, but now even one does not work anymore

By ONE do you mean UNO?

yes, :) sorry

OK, so we're still at the point where you probably have either a memory leak or a power issue. If it were a memory leak I would expect the nano and the UNO to behave the same since they use the same processor.

For power I tried with both a 9v and usb battery. So what do you suggest me if it's a memory problem?

federik87: For power I tried with both a 9v and usb battery. So what do you suggest me if it's a memory problem?

You mean one of those square looking 9V batteries? Well there's your problem. They can't supply much current and that battery probably runs down really fast.

I don't know what a USB battery is. Can you explain?

Google freemem. There's a function someone wrote for finding the amount of free memory on the Arduino while it is running. If you print the result from that and see that it is steadily going down then you have a memory leak in the code.

Ok, I see what I can find about this ... thank you and soon I'll make some tests and let you know

If it was a memory problem as soon as it loads a new blank design, it gets free, right? But I can not read the values sent by TX anyway. So it's as if the memory was immediately full

federik87:
If it was a memory problem as soon as it loads a new blank design, it gets free, right? But I can not read the values sent by TX anyway. So it’s as if the memory was immediately full

So we’re not talking about something that runs for 2 days and then stops, we’re talking about something that doesn’t run at all. Do I have it right now? Starting to sound more and more like a hardware thing.

As a thing that worked, and now it does not work anymore on two different cards I tried to change module RF24 but same thing, I uploaded a simple sketch as Blink and it works ... I have no idea what it could be

Are we still talking about something using a PP3 9V battery?

Yes, both the transmitter and the receiver were connected to a 9v battery, the receiver is then connected to an ESC for rc-car to control a brushless motor at pin 3 and gnd