#include <RF24_config.h>
|
#include <nRF24L01.h>
|
#include <RF24.h>
|
#include <printf.h>
|
|
RF24 radio(22, 21); // CE, CSN
|
//RF24 radio(15,4); // CE, CSN
|
|
const byte address[6] = {'L','O','G','G', 'R'};
|
|
char val[4];
|
|
struct PayloadStruct
|
{
|
uint8_t nodeID;
|
uint16_t payloadID;
|
float ax;
|
float ay;
|
float az;
|
float wx;
|
float wy;
|
float wz;
|
};
|
|
PayloadStruct payload;
|
void setup() {
|
// put your setup code here, to run once:
|
|
Serial.begin(115200);
|
radio.begin();
|
radio.openReadingPipe(0, address);
|
radio.setPALevel(RF24_PA_MIN);
|
radio.setDataRate( RF24_1MBPS );
|
radio.startListening();
|
|
}
|
|
void loop() {
|
// put your main code here, to run repeatedly:
|
|
delay(5);
|
//radio.startListening();
|
if ( radio.available()) {
|
while (radio.available()) {
|
Serial.print(millis());
|
radio.read(&payload, sizeof(payload));
|
/* Serial.print("Received payload ID = ");
|
Serial.print((int)payload.payloadID);
|
Serial.print(" ax=");
|
Serial.println(payload.ax);
|
*/
|
|
Serial.print(",");
|
Serial.print(payload.nodeID);
|
Serial.print(",");
|
Serial.print(payload.payloadID);
|
Serial.print(",");
|
Serial.print(payload.ax);
|
Serial.print(",");
|
Serial.print(payload.ay);
|
Serial.print(",");
|
Serial.print(payload.az);
|
Serial.print(",");
|
Serial.print(payload.wx);
|
Serial.print(",");
|
Serial.print(payload.wy);
|
Serial.print(",");
|
Serial.println(payload.wz);
|
|
}
|
}
|
|
}
|