Cheap Arduino Wireless Communications

I was looking for a way to handle wireless communications between two Arduino boards. Other options like Xbee or Bluetooth were going to cost $50 to over $100. Then I found a cheap RF transmitter and receiver at Sparkfun. The total cost is only $9!

Here are a few limitations to RF solution:

  • Communications is only one way. If you wanted two way communications you’d need to buy two receivers and two transmitters which would raise the cost to $18. This is still cheaper than other solutions I found.
  • The variable gain on the receiver causes it to pick up lots of background noise. I had to do some processing with the Arduino to filter out this noise. More details about this below in the code section.
  • Bandwidth maxes out at 2400 bps, but there is a version with 4800 bps. A large portion of this bandwidth is used for network protocol I wrote that handles error detection.
  • Range is limited to a max of 500 feet.

The advantages are that it is cheap and it is pretty easy to use.

Below are some images showing how I hooked up the receiver and transmitter to two different Arduino boards. When wiring the receiver/transmitter you only need is to give them power/ground and then a pin for the TX (serial transmit) or RX (serial receive) pin. I also wired a button to the Arduino doing the transmitting, and used the LED on pin 13 that is built into my Arduino boards on the receiver so I could test this setup. The test app just flashes a button on the receiving board when a button is pressed on the transmitting board.

Here’s a picture of the my actual bread boarded circuit.

Code

Since the receiver is constantly picking up random noise I add a few extra bytes to every data packet. I add two bytes to signify the start of a data packet. Then I send the a byte address. This address allows multiple devices to work in the same area without interfering with each other. Next is the data (in my example code it’s an unsigned int (2 bytes). Lastly I send a checksum which is a simple xor of all the data bytes to make sure the data got received without being corrupted.

I broke the Arduino code into two files. If you’ve never used two files before with Arduino all you need to to is keep both files in the same directory and the Arduino IDE merges them for you. Here is the full code for the main application, and here is the full code that does the network error catching.

Increasing the Range

I did all of my initial testing without any of these improvement and everything worked fine with these devices inside the same room.

  • Add an antenna. All you need is a 23 cm piece of wire. I did this and it made it so I could reliably transmit data from one corner of my house to the other (3 floor town house).
  • Increase the voltage for the transmitter. The transmitter can use 2-12 volts. With 5 volts I got pleanty of range for my use case, but increase this if you need more range.
  • Reduce the baud rate. My test app runs at 1200 bps out of the max 2400 bps. You could drop this even further to something like 300 bps and that should help reduce transfer errors and hopefully increase range.

Thanks

I got a lot of help from the transmitter/receiver data sheets, and from this article.

I’ll mention an even cheaper idea I had while doing this. If you will always have line of sight between your devices you could setup something very similar to this with an IR LED and IR transistor. It would work like a TV remote. It won’t work for me because I want this to go through walls, but if line of sight is fine for you then you could use this code and an IR LED/transistor would probably cost under $3.

107 Comments

  1. Jorge Solis said,

    April 9, 2013 @ 12:03 am

    I am doing a school project using a LED matrix and i have the Matrix code, but i was wondering how can i put it on the first Arduino and use the transmiter to send the code to the receiver ( the LED will be plugged to the second Arduino) . Any help will be useful. 🙂

  2. Jayakarthigeyan P said,

    April 16, 2013 @ 10:21 am

    Is possible to receive data from two transmitters by a single receiver at the same time…? I tried doing it… can I give a unique id for two transmitters… I just want two arduino’s used as tramitters and one arduino as receiver… totally 3 Arduino’s working together…

  3. Mauricio said,

    May 1, 2013 @ 4:13 am

    Fakes, counterfeits, generic pills are all the same content they’ve grown to love, plus a lot more customization available now! But not all its effects may be quite so worried about its future. Child support is always a bad idea, look no further than the April issue of BJU International. I actually handed out a number of alternatives to filter the stream. Prescriptions are necessary at several outlets while others do not charge separately for this service while others do not insist on them.

  4. Chong Han said,

    May 24, 2013 @ 3:46 am

    Hi~ is it possible i use it to do messaging application?
    sending a string of message to other to receive using cheap RF module

  5. yulia retno said,

    June 7, 2013 @ 12:12 pm

    hello, tengs for the tutorial , it helped me so much,
    but I want to ask,,
    when I supply my board with battery, it doesn’t want received, but If I connect supply with usb cable, it’s works,,
    can you explain me why ?
    tengkiu anyway
    plisss, answer my question T__T

  6. tafsir alquran said,

    August 18, 2013 @ 3:29 am

    What’s up Dear, are you truly visiting this site regularly, if so then you will definitely obtain fastidious know-how.

  7. Usman Saleem said,

    October 18, 2013 @ 4:54 am

    What are the different frequencies generated by the transmitter on pressing A B C D ?

RSS feed for comments on this post