Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Check in nRF24 works
// ESP32 odbiornik
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
const byte DEBUG = false;
char msg[6];
//RF24 radio(7, 8); // atmega328
//RF24 radio(12, 14, 26, 25, 27); // ESP32
RF24 radio(2, 4); // nodeMCU ESP8266
const uint64_t pip = 0xE8E8F0F0E1LL;
uint32_t t = 0;
uint32_t t_start = 0;
void setup(void) {
Serial.begin(115200);
radio.begin();
radio.setChannel(2);
radio.setPayloadSize(7);
radio.setDataRate(RF24_250KBPS);
radio.setPALevel(RF24_PA_HIGH);
radio.openReadingPipe(1, pip);
radio.startListening();
t_start = millis();
}
void loop(void) {
if (radio.available()) {
radio.read(msg, 6);
Serial.println(msg);
delay(10);
if(DEBUG){Serial.println(t);}
t_start = millis();
}
else {
t = millis() - t_start;
if(DEBUG){Serial.println(t);
delay(1000);}
}
if (t > 5000) {
Serial.println("ERROR!");
delay(1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.