I have a simple communication between two Arduinos.
Transmitter sends data, receiver receives it and controls a relay, simple. This proccess stops after some hours of working perfectly.
Resetting the transmitter or the receiver solves the problem temporarily, but that’s not a true solution.
Both Arduinos are powered the same way: through a 220V transformers (USB cable) with output 5V and 2.4A. I suppose that’s ok as the project works for hours.
Would it be a memory leak? I will post transmitter’s and receiver’s code.
Transmitter’s code:
#include <SPI.h>
#include <RF24.h>
RF24 radio(7,8);
const byte address = "00001";
void setup() {
pinMode(2, INPUT_PULLUP);
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_LOW);
radio.stopListening();
}
void loop() {
const char text[] = "porta";
radio.write(&text, sizeof(text));
delay(20000);
}
Receiver’s code:
#include <SPI.h>
#include <RF24.h>
RF24 radio(7,8);
const byte address = "00001";
void setup() {
pinMode(4, OUTPUT); //relay
digitalWrite(4, LOW); //relay
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_LOW);
radio.startListening();
}
void loop() {
if(radio.available()) {
char text[32] = "";
radio.read(&text, sizeof(text));
Serial.println(text);
digitalWrite(4, LOW);
delay(100);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(4, LOW);
delay(100);
digitalWrite(4, HIGH);
delay(1000);
}
}