-
-
Save yarogniew/1aa546df884c3953c0203af62e77709d to your computer and use it in GitHub Desktop.
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
// Odbiornik ESP32 | |
#include <SPI.h> | |
//#include "nRF24L01.h" | |
#include "RF24.h" | |
const byte DEBUG = false; | |
float buff[3]; | |
RF24 radio(12, 14, 26, 25, 27); | |
byte addresses[][6] = {"1Node","2Node"}; // 1Node - odbiornik, 2Node - nadajnik | |
byte msg = 1; | |
uint32_t t = 0; | |
uint32_t t_start = 0; | |
void setup(void) { | |
Serial.begin(115200); | |
radio.begin(); | |
radio.setChannel(2); | |
radio.setPayloadSize(16); | |
radio.setDataRate(RF24_250KBPS); | |
radio.setPALevel(RF24_PA_HIGH); | |
radio.openReadingPipe(1, addresses[1]); | |
radio.openWritingPipe(addresses[0]); | |
} | |
void loop(void) { | |
radio.stopListening(); | |
Serial.println("send request"); | |
radio.write(&msg, sizeof(msg)); | |
radio.startListening(); | |
if (radio.available()) { | |
radio.read(buff, sizeof(buff)); | |
delay(10); | |
printbuffer(); | |
} else { | |
Serial.println("ERROR"); | |
} | |
delay(10000); | |
} | |
void printbuffer(){ | |
Serial.println(buff[0]); | |
Serial.println(buff[1]); | |
Serial.println(buff[2]); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment