Hi to all,
yes, title say all.
Basically I talk PI and Arduino via NRF.
Arduino acts a LED on or off, receiving instruction from a PI (it's heater control).
All works as a charme. And I use the ACK to send the PIN state to the PI. PI asks for the PIN state every 3 seconds.
The issue: if LED is on by several hour (1,5h /2h), suddenly ACK (digitalRead) will be forever 0. But Led is ON. I can test because in Serial print I read "read of pin is 0".
If I shutdown the led (via NRF command) or shutup nothing change.
Do you have some idea? In future project will be powered on battery, maybe with the sleep function I will bypass the problem, but I want to understand because this happen.
Thank you
This is the Arduino sketch:
#include <printf.h>
#include <SPI.h>
#include "RF24.h"
/* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8 */
RF24 radio(7,8);
// address of this 'duino
const byte heater[6] = {'H','E','A','T','E','R'};
const byte pipe = 1;
const int pin = 6;
void setup(){
pinMode(pin,OUTPUT);
digitalWrite(pin,LOW);
unsigned short ack_start = digitalRead(pin);
Serial.begin(115200);
printf_begin();
// Setup and configure radio
radio.begin();
radio.enableAckPayload(); // Allow optional ack payloads
radio.enableDynamicPayloads(); // Ack payloads are dynamic payloads
radio.openReadingPipe(1, heater);
radio.startListening(); // Start listening
radio.writeAckPayload(pipe,&ack_start,1); // Pre-load an ack-paylod into the FIFO buffer for pipe 1
radio.printDetails();
}
void loop() {
if (radio.available()) {
char text[32] = {0};
radio.read(text, radio.getDynamicPayloadSize());
/*if (!strcmp((char*)text, "get")) {
// do nothing here.
}*/
if (!strcmp((char*)text, "1")) {
digitalWrite(pin,HIGH);
}
if (!strcmp((char*)text, "0")) {
digitalWrite(pin,LOW);
}
unsigned short pin_state = digitalRead(pin);
Serial.println("Read of pin is ");
Serial.println(pin_state);
radio.writeAckPayload(pipe,&pin_state,sizeof(pin_state));
}
}