Archive for August, 2009

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.


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.


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.

Comments (107)

High Speed Photography with an Air Canon

SAFETY: This is a dangerous device and if you don’t understand why then don’t try building a similar one. I basically built a high powered air gun that can fire a steel ball bearing at high velocity. To make things more risky, it doesn’t have the safety features of modern guns. If you want a gun to shoot stuff, buy a riffle (it’s easier to aim, safer, and more accurate). I am using this as a photography tool since it has a lower projectile velocity than a riffle. When loading this I would always make sure that the last thing I did was pressurize the system, and then I’d go behind a protective cement wall before firing the gun remotely. The maximum pressure I used was 100 PSI. I am not an expert on this subject so you must do your own calculations to verify any similar device is safe. I am not responsible in any way if you decide to build a similar device based on this rough description.

1/2″ x 36″ Threaded Steel Pipe (Sch 80) $16.05
1/2″ to 3/4″ Threaded Steel Adapter $4.98
3/4″ to 1″ Threaded Steel Adapter $6.75
1″ Ball Valve $23.12
1″ x 18″ Threaded Steel Pipe $6.55
1″ Threaded Steel Cap $4.02
1/8″ Brass Air Tank Valve $2.50
Total $63.97

After I ordered these parts, the assembly took less than half an hour. The only assembly required besides screwing together the pipes (don’t forget pipe sealant from your local hardware store) was to drill and tap (1/8″ NPT Tap) a hole in the 1″ Threaded Steel Cap for the air valve. I also had to get some steel ball bearing to shoot. The best size ball bearing for the barrel above is 17/32″.

Below are a few photos I took with this device. To capture the images I used a Camera Axe with the microphone attachment. (Click here for the full test shoot gallery.)

Comments off