Why my receiver side is not showing the data continuously? why it's showing only once?
//Transmitter
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8);
const byte rxAddr[6] = "00001";
void setup()
{
Serial.begin(9600);
radio.begin();
radio.setRetries(15, 15);
radio.openWritingPipe(rxAddr);
radio.stopListening();
}
void loop()
{
const char text[] = "Hello World";
radio.write(&text, sizeof(text));
Serial.println(text);
delay(1000);
}
//receiver
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8);
const byte rxAddr[6] = "00001";
void setup()
{
while (!Serial);
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, rxAddr);
radio.startListening();
}
void loop()
{
if (radio.available())
{
char text[32] = {0};
radio.read(&text, sizeof(text));
Serial.println(text);
}
}
why the square wave is not showing continuously in the receiver side?
//Transmitter
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
int output_state = 0;
unsigned long start;
RF24 radio(7,8);
const byte rxAddr[6] = "00001";
void setup() {
Serial.begin (9600);
start = millis();
radio.begin ();
radio.setRetries (15, 15);
radio.openWritingPipe (rxAddr);
radio.stopListening();
}
void loop() {
if((millis() - start) >=1000) {
output_state = ! output_state;
start = millis();
}
radio.write(&output_state, sizeof(output_state));
Serial.println(output_state);
//delay (1000);
}
//Receiver
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
int output_state = 0;
RF24 radio(7,8);
const byte rxAddr[6] = "00001";
void setup() {
while (!Serial);
Serial.begin (9600);
radio.begin();
radio.openReadingPipe(0, rxAddr);
radio.startListening();
}
void loop() {
radio.read(&output_state, sizeof(output_state));
Serial.println(output_state);
delay(1000);
}
Robin2
November 23, 2016, 10:04am
4
I wonder if you are using the ManiacBug version of the RF24 library? IIRC that does not like long intervals between messages. I recommend the newer TMRh20 version of the RF24 library
...R
Simple nRF24L01+ Tutorial