#include #include // Set up nRF24L01 radio on SPI bus plus pins 7 (CE) & 8 (CSN) // Make sure pin 10 is in output mode or SPI will go into slave mode. RF24 radio(9,6); const uint8_t pipe[5] = {0x55,0x42,0x9C,0x8F,0xC9}; // Radio pipe addresses for the 2 nodes to communicate. const uint8_t pipe2[5] = {0xAE,0xA6,0x60,0xA8,0x98}; // Radio pipe addresses for the 2 nodes to communicate. uint8_t lgt; int i; byte msg[32]; byte data; void setupRadio() { radio.begin(); radio.powerDown(); // Open the pipe for reading, in position #1 (we can have up to 5 pipes open for reading) radio.setDataRate(RF24_1MBPS); radio.setAutoAck(false); radio.setRetries(0,0); // Retry 15 times with 4000us delay between retries. radio.setAddressWidth(5); radio.setPayloadSize(32); //radio.enableDynamicPayloads(); radio.setChannel(60); radio.disableCRC(); //radio.setDataRate(RF24_250KBPS); Serial.println("Reading..."); radio.openReadingPipe(1,pipe); radio.openReadingPipe(0,pipe2); radio.startListening(); } void setup() { Serial.begin(115200); // Other MPU related setup stuff... setupRadio(); data = radio.getCRCLength(); Serial.println(data); data = radio.getPALevel(); Serial.println(data); } void readRadioData() { // Fetch the payload. radio.read(&msg,32); Serial.print("guard: "); for(i=0;i<2;i++) { Serial.print(msg[i],HEX); Serial.print(" "); } Serial.print("PCF - Payload Length: "); lgt = (msg[2]&0xFC)>>2; Serial.print(lgt,DEC); Serial.print(" PID: "); Serial.print((msg[2]&0x3),DEC); Serial.print(" NO_ACK: "); Serial.print((msg[3]&0x80)>>7,BIN); Serial.print(" Payload: "); for(i=3;i>7))&0xFF,HEX); //Serial.print(((msg[i]<<1))&0xFF,HEX); //Serial.print(msg[i],HEX); Serial.print(" "); } Serial.print(" CRC: "); for(i=lgt+3;i>7)&0xFF,HEX); //Serial.print(msg[i],HEX); Serial.print(" "); } Serial.println(" "); } void loop() { // check if data has been sent from the computer: if (radio.available()) { readRadioData(); } }