Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In global part of main “.ino” file:
- #include
- #include
- #include “nRF24L01.h”
- #include “printf.h”
- // Setup Radio parameters / data storage
- RF24 radio(8,7); //CE, CSN
- uint8_t frame[27];
- uint8_t packetType = 0;
- uint32_t uid = 0;
- In Setup:
- radio.begin();
- radio.setChannel(25);
- radio.setPayloadSize(27);
- radio.setAutoAck(false);
- radio.setDataRate(RF24_250KBPS);
- radio.setCRCLength(RF24_CRC_DISABLED); // was 8
- radio.openReadingPipe(1,0xC2BD0DLL);
- radio.startListening();
- radio.printDetails();
- In Loop:
- if ( radio.available() )
- {
- // Get the packet from the radio
- radio.read( &frame, sizeof(frame) );
- parseFrame();
- if (1)
- {
- printf(“PacketType: %X, UID: %08lX\n”, packetType, uid);
- printf(“\r\n”);
- }
- }
- Functions to add after Loop:
- void parseFrame(void)
- {
- uid = frame[1];
- uid <<= 8;
- uid |= frame[2];
- uid <<= 8;
- uid |= frame[3];
- uid <<= 8;
- uid |= frame[4];
- packetType = frame[0];
- }
- void printFrame(void)
- {
- int i;
- printf("Frame: ");
- for(i = 0 ; i < 27 ; i++)
- {
- printf(" ");
- printf("%02X", frame[i]); // prints value as string in hexadecimal
- }
- printf("\r\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement