Skip to content


Simple RF Wireless Link

RFLinkModuleNeed a simple, one-way, wireless data transmission for your microcontroller projects? This article will show you how to interface and properly use a $14 RF Wireless Module from SparkFun.

This article was submitted by Brent Reamer as part of the “Hobby parts for articles” program. Write something of interest to electronic hobbyist and receive parts for your next project.

RF Wireless Link Interface and Usage
SparkFun Part #: WRL-00872

Information on Device:

  • Receiver runs @ 5v
  • Transmitter runs @ 3v up to 12v (higher voltage higher range)
  • 2800bps (bits per second) data transmission rate
  • 150m Range
  • 434Mhz Frequency
  • Can easily be interfaced with any uC with U(S)ART capabilities.

A Basic setup (software):

For this article I will be using this device with an Atmel AVR 8-bit Microcontroller, more specifically the atmega32 for the transmitter, and the PC’s serial port for receiver (RS232). Now all of you AVR Freaks out there know the atmega32 has an on-board USART, which is perfect for running this device!

First, lets talk about how U(S)ART must be setup to get this transmitter sending. For a clean USART you need an external clock source, the internal clock source on an AVR is not stable enough for clean sending. So with my ATMega I will be using a 3.6864 MHz external crystal. I went with this number for one reason, magic number (X.XXXXMhz) crystals are extremely USART friendly, were talking a 0% error rate, for USART you need at most a 2% error rate. Here are the USART settings I am using:

  • 2800 Baud-rate (that’s 2800bps, which is perfect, that’s why it so easy to interface)
  • 8 Data bits
  • 1 Stop bits
  • Handshaking none

This is also the same for the settings I’m using in my terminal application. I use br@ys but HyperTerminal should work fine.

That’s all it takes, once you got your USART ready and tested it with your PC and a level converter (I use a MAX232). Your good to go, lets setup the hardware.

A Basic setup (Hardware):

shem transI will be sending data from my ATMega to my PC, so lets go over how to setup your UC as the transmitter. I will only be using 5v for this demonstration, but the setup is the same. Here is a simple schematic of the device and where the pins should be connected in comparison to my ATMega:

That’s all it takes, nothing special here at all. Now lets work on the PC side, this takes a level converter IC, I used a Maxim MAX232. Its really the same thing, just setup the receiver with the correct pins, setup the MAX232, and connect the PCs serial to max to receiver. I’m not going to go into setting up the MAX232, there is plenty of information on doing online, just do some searching.

shem reci

Now time to start the testing. I set the ATMega to just count from 1 to 255 and send that number out ever few milliseconds. You may need to adjust your device if the data from the ATMega has errors. All the SparkFun modules I have bought, seemed to be pre-adjusted, but who knows, you may need to adjust yours. I will talk about this in the next section.

Usage:

Now that you have your device all setup, the first thing I’m sure you will notice is the ‘junk’ you get when your transmitter is not receiving. RF is everywhere there is no stopping it, so no matter what you do junk will always be received, but when you transmit you over power that junk so you should get clean signals, depending on your distance and voltage.

So what do you do? How can you use this device when you are always getting junk? What if I wanted my PC to send data, or a microcontroller to microcontroller when there is junk always being sent?

With this device it is all about your receiver knowing what is junk and what is not, I do this by sending packets, I will explain below. Another thing to worry about with this device is almost every time, the first char sent will be junk when received (example sent “hello” you get “$ello”) this is easily fixed by sending a couple of NOP’s (0x00) before all transmissions. One last thing you can bet your life that some of your transmissions will be ‘gargled’ this can easily be fixed by using a checksum. I used CRC8, I will not go into the checksum, because this is a extremely common one, do some searching and you will find it. You will also need to send the same transmission at least I would say 3 times, so if the first one is gargled (crc does not match) just have your source skip that one and read the next until it gets a good one.

Here is the simple packet I use:

NUL NUL SOH SOT DATA …… DATA EM CRC ETB
0x00 0x00 0x01 0x02 0xXX …… 0xXX 0x19 0xXX 0x17

I use at least 2 NUL’s to protect against the first char being gargled. Then comes SOH which is ‘Start of Header’, after that a SOT; ‘Start of Text’. The data can be as long as you want it to be, then stops with a EM which is ‘End of Medium’. Checksum is next and finished with a ETB is ‘End of Transmission’.

I like this packet because it’s very simple to use with your source, just have your source wait until it receives a SOH and SOT command, then start collecting data. Does this until EM is reached; collect the checksum, compare and your done.

I included source code for two projects I made a while ago. The source code uses the RF link modules with the packet described above (No checksum though, never got around to adding it). This is test code but it includes the basics you will need to know.

  • Setting up USART for the wireless device
  • which
    Simple transmissions
  • Simple receives
  • Out-Of-Range LED (when the devices are to far from each over to communicate a LED will turn on)
  • Both use a RTC crystal to control the out-of-range functions
  • Made with winAVR GCC in C

Get the source code here.

If anyone has any questions, please email me at uchobby@ph0rkeh.com

Posted in Microcontroller, Parts, Projects.


31 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. NGinuity says

    Neat use of the RFID frequency :-)

  2. David says

    Very neat and a useful page, but the misspellings of “which” were extremely distracting.

  3. dfowler says

    David,

    Sorry about that. I have corrected witch to which.

  4. Brent says

    Yeah sorry for the spelling :P I would also like anyone who wants more information, please don’t hesitate to email me. brent .at. ph0rkeh.com I will happily anwser any questions you have, to the best of my knowledge.

  5. Mr Meval says

    Grammar Nazi’s are such worthless creatures.

  6. Mrs X says

    hihihi. u’re right Mr Meval

  7. Bastiaan says

    Lo, i’m going to try to do software serial over one of these 433mhz radios once I have my arduino.
    U(S)ART will be busy doing USB comm, so its the only option i have. Hope it’ll work :)

  8. madi says

    Hi, i have one question? If i use this RF module (http://www.escol.com.my/Sensors.html), can or not i use the same source code?

  9. dfowler says

    Bastiaan,

    I hope you will submit an article about your project. I’m sure everyone would like to know more.

    Madi,
    I can not answer this quesiton. I hope Brent pipes in here.

  10. Dale says

    Pretty nifty. But what happens if my data stream contains an “EM” byte (0x19)? The very next byte of data will likely not be the expected CRC, and an error will be flagged. Is it possible to transmit a 0x19 in the data stream at all ?

  11. Ronesh says

    sir/madam can u please send as a circuit diagram on how to light up a bulb from one building to another building without the use of wirers i mean that a wireless circuit diagram

  12. dfowler says

    Ronesh,

    We have no such diagram. If you are talking about sending power wirelessly you could do some Google search on wireless power transfer. If you just need to send a radio signal between to buildings to signal a light to come on, try implementing the circuts Brent describes here.

  13. mle_ii says

    Trying to figure out how to listen to my Polar M52 Heart Rate Monitor on my computer. I’m guessing that it is using RF to go from the monitor to the watch. Will this particular RF reciever work or will it only work with a specific transmitter?

    Thanks,
    Mike

  14. dfowler says

    mle_ii,

    It’s not likely that this receiver would work for that. Do you know the frequency and modulation type output by the monitor? If the signal is strong enough you might make a very simple receiver. Assuming the modulation is really just the heart pulses in AM or FM it could be easy to detect and process. If it’s a digital stream, it could be much harder.

    The first step is learning what frequency and modulation type for the transmitted signal. You might be able to pick up the signal with a loop of wire and an oscope or spectrum analyser. Maybe a google search on the monitor model number will get the answers.

  15. gwolanin says

    Can a video signal from a security camera be sent over this? That would be great if it could. No audio just video. It would be a constant signal.

  16. dfowler says

    gwolanin,

    Not likely to handle video directly. If you had a processor that could capture the video then send it as a serial data stream then sure this could work. It might be too slow for real time however.

  17. Jordan says

    Would this design be suitable to use for a RF tracking system to track cattle for example? Has anybody got any links that could point me in the right direction?

  18. dfowler says

    Jordan,

    You would need significant range to track cattle. I doubt that these modules would be adaquate. Look at some of the 450MHz or 900MHz radio modem modules for this application.

    Are you planning a big instalation or just a home project to track cattle? I ask becase I have some simular interest. I have, at my day job, been involved with animal tracking systems in the past.

    David

  19. cujack says

    Hi everyone,

    I need help on the RF Link project. I’m using the RF link device that similar to this article except its baud rate is 4800. I use AVR Atmega16 MCU on the STK-500 board to communicate with the PC. Basically, I had a code that everytime I pressed SW0 button, it will send the text. Let’s say “hello world” to the hyperterminal. Now here’s the problem. Instead of hooking up the pin PB1 to TX spare directly, I would like to put RF link between these two pins. I tested the RF device (exactly the same model you had in the article) on the breadboard. I put 9V to transmitter VCC and 5V to receiver. I jump PB1 to the data for transmitter and then jump digital data out from receiver to the TX pin on the STK-500. The result doesn’t come out as I hope. Nothing happen on the hyper terminal. I tried set the baud rate to 4800 on the STK-500 and hyperterminal, but nothing happen either. I tried to measure the voltage that come out from the data out on the receiver, it shows the voltage somewhere around 500 mV. So I wonder if it is necessary to amplified the output to 5V before it connect to the TX pin on the STK-500 board? I mean is it normal to have the data output come out from the receiver less than 5V? Please help me.

    Thank you,

    cujack

  20. ken of philippines says

    Can you send me a schematic circuit diagram and the list of spareparts needed to make my electric guitar wireless or cord less? please help ma’am, sir.. Thanks a lot..

  21. dfowler says

    Ken,

    We don’t have a schematic or a design for using these modules as a wireless guitar unit. You would need to study the specifications and design the device you need.

    I deleted the comment with you email address to help reduce your spam. If someone comes up with something for you they can comment here and if you acknowledge I will send them your address.

  22. dfowler says

    cujack,

    I am not sure what you are trying to do. It sounds like you are trying to send out and receive from the same uC. One thing that might be a problem is that the received signal level could be so large that it’s causing problems for the receiver. Try getting some distance between the modules or maybe change the antenna on the transmitter to a load resistor.

    David

  23. Ryan says

    Hello,

    Would it be possible to use several pairs of these receivers/transmitters in the same location? I am unsure if they will conflict with each other, or if they are broadcasting on different enough frequencies to avoid conflict. I am looking into creating a base station with 3-5 of the receivers, and then having 3-5 of the transmitters at different locations as “sensors”. I wasn’t sure if this would be possible with this component.

    Thanks.

  24. dfowler says

    Ryan,

    Might consider ZigBee or some network made with these modules. I would expect them to have trouble unless widely seperated in frequency and then you might not have enough frequencies for 5 units.

  25. Ryan says

    David,
    Do you think it would be possible to have only one receiver and then multiple transmitters? If each transmitter sent a code at the beginning of the transmission, this would allow the receiver to identify the origin of the transmission. I looked at the ZigBee products some and they all seem more expensive than this option.
    Thanks.

  26. Florin says

    @Ryan i dont think the RF module knows to recognize identification codes

  27. Jimmy says

    I was looking for an easy way to make a link from one building to another. This would hook an internet gateway to a PC running echolinkserver on a radio voice repeater. The repeater is in a building with no Internet and the building is over 200 years old. But it’s the high point in the county so we have our voice repeater there. Now to get our echolink pc up and running we need to get a wifi or something to hook it rf wise to a building down the road that has a network. Ok, I hope I did explain that well enough. Of coarse being Ham Radio Opps we are very worried about costs!!! So would you have any ideas for us on this project.

    I loved your web page here BTW and the use of the MAX chip brings back memories of packet radio years ago.

    Thanks! Jimmy:)

  28. sameen says

    i m using AVR ATtiny2313..i want it to connect wid TRF6901…but the problem is i ve a built in hardware for this purpose…with Tx(pin#33),Rx(pin#34)connected to pin numbers 11 and 14 of AVR respectively…the problem is…i want data from AVR transmitted to TRF and recieve it bak to AVR…how can pin 14 and 11 serve the purpose of UART….pleaseeeeee guide me….

  29. sameen says

    i m using AVR ATtiny2313 (for RFID tags and readers)..i want it to connect wid TRF6901…but the problem is i ve a built in hardware for this purpose…with Tx(pin#33),Rx(pin#34)of TRF connected to pin numbers 11 and 14 of AVR respectively…the problem is…i want data from AVR transmitted to TRF and recieve it bak to AVR…how can pin 14 and 11 serve the purpose of UART….pleaseeeeee guide me….

  30. teen boy bondage says

    wjic tzjdm gpfvj zutc

  31. Marc says

    This is a good starting point for my project.

    Basically I want to gut several different classic console gamepads and enable use of these wirelessly. Of course I’ve stumbled upon http://www.ppl-pilot.com, which I assume uses the exact same wireless modules as here. The problem is it uses uC’s i don’t have access too, and is overcomplicated for my needs.

    Basically I’m looking looking to have an atmega8/32 (or similar), using hooked up to the buttons inside each controller… Then creating a ‘packet’ of some description, which in turn is sent over the wireless link to another (atmega8?/32?) hooked up to usb.

    Sound plausable? To be honest I want to teach myself everything… But if anyone has any useful links, please share them here…

    Thanks.