Skip to content

Instantly share code, notes, and snippets.

@yarogniew
Last active November 3, 2019 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yarogniew/1aa546df884c3953c0203af62e77709d to your computer and use it in GitHub Desktop.
Save yarogniew/1aa546df884c3953c0203af62e77709d to your computer and use it in GitHub Desktop.
// 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