this post will be a long oneI'll spare you the why and how until i can invest more time in a more through writeup. For now, the technical question:
Why can't i get *data* from my radio? I can clearly see that *something* is being picked up, but i can't get data.I've spent the past few hours trying to get my TurningPoint Clicker working with a 24L01+ radio as inspired by this post here:
http://hackaday.com/2010/07/05/reverse-engineering-an-rf-clicker/Now, using RF24 library and the scanner example, i have put together a a very botched bit of code
/*
Copyright (C) 2012 J. Coliz <maniacbug@ymail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
*/
/**
* Example Nordic FOB Receiver
*
* This is an example of how to use the RF24 class to receive signals from the
* Sparkfun Nordic FOB. Thanks to Kirk Mower for providing test hardware.
*
* See blog post at http://maniacbug.wordpress.com/2012/01/08/nordic-fob/
*/
#include <SPI.h>
#include <RF24.h>
#include "nRF24L01.h"
#include "printf.h"
//
// Hardware configuration
//
// Set up nRF24L01 radio on SPI bus plus pins 9 & 10
RF24 radio(9,10);
struct payload_t
{
uint8_t b1;
uint8_t b2;
uint8_t b3;
uint8_t b4;
};
//
// Setup
//
void setup(void)
{
//
// Print preamble
//
Serial.begin(57600);
printf_begin();
printf("\r\nRF24/examples/nordic_fob/\r\n");
//
// Setup and configure rf radio according to the built-in parameters
// of the FOB.
//
radio.begin();
radio.setAutoAck(false);
radio.setChannel(10);
radio.setPayloadSize(4);
radio.setCRCLength(RF24_CRC_16);
radio.openReadingPipe(6,0xF0F0F0F0AALL);
radio.openReadingPipe(5,0xF0F0F0F0BBLL);
radio.openReadingPipe(4,0xF0F0F0F0CCLL);
radio.openReadingPipe(3,0xF0F0F0F0DDLL);
radio.openReadingPipe(2,0xF0F0F0F0EELL);
radio.openReadingPipe(1,0xF0F0F0F0FFLL);
radio.openReadingPipe(0,0xF0F0F0F011LL);
//
// Start listening
//
radio.startListening();
//
// Dump the configuration of the rf unit for debugging
//
Serial.println("DETAILS");
radio.printDetails();
}
//
// Loop
//
int tmp = 0;
void loop(void)
{
//
// Receive each packet, dump it out
//
if ( radio.testCarrier() ){
Serial.print(tmp);
Serial.print(" : ");
Serial.println("Carrier!");
tmp++;
// if there is data ready
if ( radio.available() )
{
Serial.println("Payload Available");
// Get the packet from the radio
payload_t payload;
radio.read( &payload, sizeof(payload) );
// Print the ID of this message. Note that the message
// is sent 'big-endian', so we have to flip it.
//printf("#%05u Buttons ",flip_endian(payload.id));
Serial.println("payload len:");
Serial.println(sizeof(payload));
//printf("\r\n");
}
}
}
// vim:cin:ai:sts=2 sw=2 ft=cpp
that generates this output:
RF24/examples/nordic_fob/
DETAILS
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xf0f0f0f011 0xf0f0f0f0ff
RX_ADDR_P2-5 = 0xee 0xdd 0xcc 0xbb
TX_ADDR = 0xe7e7e7e7e7
RX_PW_P0-6 = 0x07 0x07 0x07 0x07 0x07 0x07
EN_AA = 0x00
EN_RXADDR = 0x3f
RF_CH = 0x0a
RF_SETUP= 0x07
CONFIG = 0x07
DYNPD/FEATURE = 0x00 0x00
Data Rate= 1MBPS
Model = nRF24L01+
CRC Length = Disabled
PA Power = PA_HIGH
0 : Carrier!
1 : Carrier!
2 : Carrier!
3 : Carrier!
4 : Carrier!
5 : Carrier!
6 : Carrier!
7 : Carrier!
8 : Carrier!
9 : Carrier!
10 : Carrier!
11 : Carrier!
12 : Carrier!
13 : Carrier!
14 : Carrier!
15 : Carrier!
-- < SNIP >--
700 : Carrier!
701 : Carrier!
702 : Carrier!
703 : Carrier!
Now, it took a while, but i know that my clicker is on channel 10.
Notice how i can check for a carrier signal when the radio is on channel 10, and i get ~ 700 'samples'. This is how i know that the radio is on the correct channel and that it does see something.
so.
HOW DO I GET THE PACKET PAYLOAD?If you look at the blog post i linked to at the beginning, you can see that the author does a few things to get his radio working:
- disable shockburst
- set 4 byte packet length
- set a 16 bit checksum
and looking at the status registers EG:
EN_AA = 0x00
EN_RXADDR = 0x3f
RF_CH = 0x0a
RF_SETUP= 0x07
CONFIG = 0x07
i know that i have this radio set up properly (at least i **think** i do).
It's late, and i am tired / have other thing to get to, so i think this is a decent place to wrap this up.
I'll get back to you asap with replies
THANKS FOR YOUR TIME / READING THIS FAR!