-
-
Save yarogniew/d261915f9954026f8101585910e031c1 to your computer and use it in GitHub Desktop.
Check in nRF24 works
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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