RFM12B with MSP430 Tutorial

Here is a quick tutorial of basic communication between two RFM12B’s driven with MSP430 Launchpads.

Last couple of days (10 days) I have been occupied with two FRM12B modules, trying to get them to communicate. I need them to make some kind of wireless temperature sensors. I had some simple weather station from Lidl, but it stopped working, so I said I will make one myself. This is the part for tranferring measuremensts from cold outside, into our warm home. I had short connection on receiver board and it took me a few days to realize that, so it took me much more than it should. Learn from my mistakes! I have an adapter board that fits on MSP-EXP430G2 Launchpad board. I also made small board to fit RFM12B on it. This is how everything fits together:RFM12B MSP430 Adapter Board

As you can see, the board was not properly drawn first time.

There are 5 connection between RFM12B and MSP430, plus two for power. They are connected as follows:

I use Code Composer Studio, which is FREE, because there is version 7.x out. You can get it here. You will need to register, to be able to download software. This is link to FREE license and it’s installation instructions. I will not explain how to install it, since you must be smart enough to do it if you are programming microcontrollers.

We need to start by creating new project (Project -> New CCS Project…):

Now we need to select our microcontroller (I selected MSP430G2231 since this is the one in my launchpad):

We also need to name our project. I named this one RFM12B_TX_002. RFM12 is obvious, TX is because this is the transmiter part of our project and 002, because I already have 001 and this is how I sequnentially name all my software projects. And this is what it looks after we click finish:

I used different information sources for this. Some pdf’s from internet, some code found on random sites, some code I already used on ATMEGA8 for RFM12B, some info from forums, which didn’t help a lot, since no one else had shortcut on circuit, like I did. 🙁 But finally it worked and here is code I use to do it.

This is code for main.c:

In case you try to change something, don’t forget you need to use FIFOReset();, otherwise you will get less that half the data through! Don’t ask me how I know!

We also need one other file, where the magic happens. We need to make new header file (Right click on project name -> New -> Header File):

Give it some name and click Finish (I marked wrong here, the filename should be marked):

Here is our new file opened and ready:

If you name it different you need to change include at the beginning of main.c accordingly:

Here is the code for out new file:

Now all we need to do is to connect RFM12B module to microcontroller, upload our code and start it. At start, green LED should be on for about a second and after that both red and green LED should blink every two seconds, showing us when it is transmitting.

For receiver we need to create new project as before. This time I will name it RFM12B_RX_002. We also need to create new header file, I will name it rfm12b_slemi_rx. I add rx and tx at the end of files, so that I know which is which, if I have both open at the same time, when writing or editing code.

Here is our main.c code:

And here is code for rfm12b_slemi_rx.h:

After running it, it should blink at the same rate as transmitter. I hope it works in first try for you!

This is just bare project, just to get started. If we need some transmission checking, we should at least add checksum, or even better two way transmission, so that we can check back if data was sent ok, or we need to retransmit. But this is for another tutorial…

Thank you for reading!




Leave a Reply

Your email address will not be published. Required fields are marked *