Project

General

Profile

Raspberry Pi with RFM12B

Added by Stephen99 over 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 Stephen99 over 6 years ago

Meant to say:

I just connected the RFM module straight to the Pi. I.e. no resistors etc. (The IRQ line uses an internal pullup)

I use the 3.3v and GND pins next to the SPI pins so, again, can just use a 6x2 header.

RE: Raspberry Pi with RFM22B - Added by ltickett over 6 years ago

Great thanks- could you clarify exactly which header pins and which RFM pins need to be connected? I’m considering having a play with some bare metal coding if I get a few minutes spare.

L

RE: Raspberry Pi with RFM12B - Added by Stephen99 over 6 years ago

Sure.
(editing because forum sw stipped out my tabs…)

Looking at the pi with the SD card at the bottom the pins you want are at the top. First pin top left and top six on the right :

Top left pin
CE1 > SEL
First six from top right
GND
> GND
SCLK > SCK
MISO
> SDO
MOSI > SDI
3.3V
> VCC
GP22 -> IRQ

(This is for a rev1 board. Some of the GPIOs have been renumbered for rev2)

You can use CE0 (second down on left) rather than CE1 if you want and can use any other GPIO than 22 (#defined in code).

Thanks

Stephen

RE: Raspberry Pi with RFM22B - Added by aanten over 6 years ago

hello,

interesting project - i’m looking using an RFM22b to communicate with FS20/FHT protocol.

could you confirm that you are using RFM22b (and not RFM12) ?

many thanks,

andy

RE: Raspberry Pi with RFM12B - Added by Stephen99 over 6 years ago

Hi Andy,

Oops. Typo. As you say, should be RFM12B.

Thanks

Stephen

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

Anyone can use this in a raspberry pi with an alpha eve board with rfm12b radio?

Thank you

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

I have one but haven’t tried doing anything with it yet.

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

I try but without any result!

I see that exist a driver for the srf radio, that transform it as a serial port under /dev/ it would be great that exist to rfm12b too.

To rfm12b i only find some code examples for arduino and nothing for raspberry.

I want establish communication with 433mhz devices and think a good start point would be a spectrum analyzer but can’t start anything, i don’t have the hardware and software knowledge to develop drivers for this :/

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

Yep… the last post is mine.

In that example they can’t do nothing relevant with eve/rpi, only with rfm12b and arduino

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

I can’t remember if i ordered the eve with 868 or 433… either way, I will try and play with it over the weekend, see if I can get it reading data

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

i will wait for great news :)

Thanks

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

I have also an EveBoard didn’t try anything yet but happy to help!

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

Been quite busy, but got as far as:

-soldering the jumper wire, resistor and antenna
-installing a clean latest raspbian image on the pi
enabling the i2c modules etc and testing the pi can see the eve alpha
@ 0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: — — — — — — — — 48 — — 4b — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — 68 — — — — — — —
70: — — — — — — — — @
I can see the next bit is going to be tricky, as normally we have atmega doing the decoding of rfm12b data
having a google around i couldn’t seem to find a generic linux/python/c driver for this (the few i did find like http://www.susa.net/wordpress/2012/08/raspberry-pi-reading-wh1081-weather-sensors-using-an-rfm01-and-rfm12b/ are a bit too specific, mine is 868Mhz for example)

Will try and find a little more time to play- keep me posted.

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

Great job!

At least you can view something :)
I solder the jumper and the resistor, after i try two jumper and no resitors but never can see the rfm enable i only see the clock and the temperature sensor.

This is what i have
pi@raspberrypi ~ \$ i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: — — — — — — — — UU — — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — UU — — — — — — —
70: — — — — — — — —

I will re solder it again and start from zero again

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

like the second/third image (with a resistor- although it is suggested that it shouldn’t matter).

is your eve alpha board definitely powered? and are all your joints definitely good?

didn’t get any further with finding a C library for rfm12b 868

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

I don’t power the alpha board… i read that if we don’t have any usb shouldn’t be needed…

Now my i2cdetect gives me the following
pi@raspberrypi ~ \$ i2cdetect y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: - — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: — — — — — — — — 48 — — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — 68 — — — — — — —
70: — — — — — — — —

Do you power the alpha board too?

If i soldered only the first jumper wire should be ok?

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

Damm

Solder again only one wire jumper SS RFM12 to CE1

But the i2cdetec only show 48 and 68 never show 4b :/

Don’t know what i’m doing wrong

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

Yes- i’m powering my EVE from the Pi (no external psu).

Do you have a multimeter so you can test the rfm12b pins?

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

Right now my eve look like this

Only one wire jumper soldered, and i2cdetect only show temp and rtc modules

Where should i put the multimeter to debug?

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

After put multimeter on GND and on rfm12b 8 places (likes where the resistor goes) none of them have power (3V) Is this normal? Have power not the 3V but less

The wire jumper have 3v power in the two joints, so i guess it is good

Thanks

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

Do you have a USB logic debugger?
That will help to debug the comms.

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

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

(1-25/37)