Skip to content

Instantly share code, notes, and snippets.

@yarogniew yarogniew/ESP32_odbiornik_v4.ino Secret
Last active Nov 3, 2019

Embed
What would you like to do?
// 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
You can’t perform that action at this time.