Project

General

Profile

Raspberry Pi with RFM12B

Added by Stephen99 about 6 years ago

From old forum: [[[http://forum.jeelabs.net/node/1229]]]

I had some reasonable success with the RFM12B on my Raspberry Pi over the break. It seems to be able to receive data pretty reliably at the standard 49.2kbps.

The real breakthrough was changing from using the spi-dev driver to using a direct link to the chip via a great bcm2835 library. I think the only downside is the need to run things as root at the moment.

The test program attached displays the first 20 packets received by the module and shows the calculated crc (0 = success). The whole packet is displayed (i.e. includes the initial 3 byte header and final 2 byte crc checksum).

I have done nothing to increase the priority of the thread it runs on and, of course, it runs with interrupts enabled so you do get occasional corruptions but vast majority of packets (? Over 90%) are received fine and the remainder could be fixed with standard ack process. I tested a whole batch of 66byte packets and they were fine too (so should be ok even with large packets).

To try out the code you just need to set the #define for the IRQ pin (I use 22 because it is up by the SPI pins on a rev 1 board so a 6x2 headers picks up all the pins needed) and the SPI chip select (I used CE1)

Only other restriction for this test code is that it uses the default group 212. You should be able to change that by editing
rf12_xfer(0xCED4); // SYNC=2DD4ï¼.

To something like
rf12_xfer(0xCE00 | group); // SYNC=2DD4ï¼.
And changing
static uint8_t group = 212; // network group
to the group you want (But I didn’t test that).

To compile the code, you will need the bcm2835 library from [[[http://www.open.com.au/mikem/bcm2835/index.html]]]
Instructions on how to compile that are on the site along with link to latest version (is very simple)

You can build the code with something like :
gcc -o rfm12btest -l rt rfm12btest.c -l bcm2835

The current code just polls the interrupt pin rather than looking for interrupts (just for proof of concept).
Next job is to enable interrupt watching (I hope latency will not be too high) and to add sending routines and make into library that looks like Jeelib routines.

Thanks

Stephen


Replies (37)

RE: Raspberry Pi with RFM12B - Added by codedmind about 6 years ago

GadgetUK wrote:
> The RFM12B won’t show up in an i2c list, as it’s an SPI device not i2c.

Damm i understand that it will show because on ltickett reports three items on i2c list

So how can i see if the rfm12b is connect the right way?

RE: Raspberry Pi with RFM12B - Added by ltickett about 6 years ago

I bought the fully populated board- so it’s possible that’s another device showing up?

I have the resistor soldered between g21/g27 and the RFM12B

I have made some progress with the software too (I think). I will be working on it more today and update later

RE: Raspberry Pi with RFM12B - Added by codedmind about 6 years ago

ltickett wrote:
> I bought the fully populated board- so it’s possible that’s another device showing up?
>
> I have the resistor soldered between g21/g27 and the RFM12B
>
> I have made some progress with the software too (I think). I will be working on it more today and update later

After gadgetUK post i will assume it yes :)

Will wait for your update :)

Thanks

RE: Raspberry Pi with RFM12B - Added by codedmind about 6 years ago

ltickett in your next update would be great if you can put a pic from your eve and connections :)

RE: Raspberry Pi with RFM12B - Added by ltickett about 6 years ago

Maybe i hadn’t cracked it as I had thought- it’s really bugging me now!

I’ve tried A LOT with several different bits of code (and tried modifying the code in numerous ways to ensure the correct pins are being referred to etc). I’m starting to think i may as well just interface with the RFM12B directly rather than adding the EVE as a layer of complexity :/

Anyway here are some links (most probably already posted) which i’ve been working from:

http://tools.jeelabs.org/rfm12b
http://www.open.com.au/mikem/bcm2835/index.html
http://www.susa.net/wordpress/2012/08/raspberry-pi-reading-wh1081-weather-sensors-using-an-rfm01-and-rfm12b/
http://blog.strobotics.com.au/2009/07/27/rfm12-tutorial-part-3a/
http://elinux.org/RPi\_Low-level\_peripherals\#GPIO\_Driving\_Example\_.28C.29\_2
http://amcc.me.uk/2013/01/eve-alpha-collects-weather-data/

RE: Raspberry Pi with RFM12B - Added by ltickett about 6 years ago

ok just as i said that i made some progress with the http://www.susa.net/wordpress/2012/08/raspberry-pi-reading-wh1081-weather-sensors-using-an-rfm01-and-rfm12b/ code modified according to http://amcc.me.uk/2013/01/eve-alpha-collects-weather-data/ (i have made a lot of other modifications too which i will blog about tomorrow). here’s a photo of my board:

RE: Raspberry Pi with RFM12B - Added by codedmind about 6 years ago

Great ltickett,

When you can post the code i will try change it to 433 and see if my module works

RE: Raspberry Pi with RFM12B - Added by ltickett about 6 years ago

A bit of an update of what i’ve done: http://tickett.wordpress.com/2013/03/01/eve-alpha-raspberry-pi-rfm12b-jeenode-868mhz/

Still playing (as well as numerous other bloody projects i’m trying to complete)

RE: Raspberry Pi with RFM12B - Added by codedmind about 6 years ago

Ok now i reply your changes less the last ones, where you change the control to match 868 mhz.

Before i run sudo ./wh1080_rf i keep push a remote garage opener but at the end i have RSSI Duty 0.00 so no interference for me :/

RE: Raspberry Pi with RFM12B - Added by ltickett about 6 years ago

i tweaked the loop a bit:

do {
                float duty = sample_rssi(fd, 250, 100);
        if (duty > 1)
        {       
                printf("RSSI Duty %0.2f\r\n", duty);
        }
                fflush(stdout);
                usleep(2500);
        } while(argc > 1);

if you run with sudo ./wh1080_rf 1

it’ll continue to monitor and printout if it hears anything

RE: Raspberry Pi with RFM12B - Added by ltickett about 6 years ago

Something’s definitely not quite right with mine- i’ve added another bit of debugging code in:

if(rssi != oldrssi) {
                        printf("time: %d \r\n", rssitime);
                        printf("state: %d \r\n", rssi);

But i only ever see it go high at the begginning, it never transitions after this. Hmmmm

RE: Raspberry Pi with RFM12B - Added by codedmind about 6 years ago

I still get only 0

(26-37/37)