Thursday, May 22, 2014

Xbee Alternative XRF Wireless RF Radio Module And Arduino

http://blog.oscarliang.net/xbee-alternative-xrf-wireless-rf-radio-arduino/

Xbee Alternative XRF Wireless RF Radio Module And Arduino

remote-XRF-to-Arduino-connections 8
In this post I will show you how to connect the XRF with Arduino, and will show you a example application with two Arduinos talking to each other using the XRF wireless module.

Bought The XRF Wireless RF Radio Modules

As part of the DIY Custom Remote Control, I will be using wireless modules for remote communication. There isn’t much choice, either Radio Transceiver or Xbee. Both are great but quite expensive. Later on I stumble on an cheaper Xbee Alternative calledXRF Wireless RF Radio Module, that claims it has the same pin configuration as the Xbee, the way it’s used is also the same, and the range can reach up to 1 Km (although some feedbacks said it’s more like 300m but it’s still great). More importantly, it’s only half of the price of a Xbee module.

I think the main difference is that this module transmits data at lower frequency (868 and 915 MHz) than the Xbee (2.4G Hz), and that partly explains why the transmit distance is longer.

Problems Right Away

remote-XRF-to-Arduino-connections 9
I bought the break out boards (XBBO) with wireless modules too, and I only found out that the ones I bought are called “Passive XBBO” which doesn’t accept 5V power supply but only 3.3V (not 5V signal as well because of that). Only “Active XBBO” would accept 5V and convert the voltage for you. I didn’t notice that when purchasing (should have been more careful and read the description), So, it didn’t work when I just simply connect everything. My first thought was the TX/RX data line voltage on the Arduino is too large (5V) for the XRF (3.3V).
I tried so hard searching on Google, there isn’t much information about this, even not much about the XRF module working with Arduino. So I decided to take the risk by following tutorials about the Xbee, since they are similar devices, and it did work!

A Not-So-Perfect Solution

I found this image about Xbee and arduino:
remote-XRF-to-Arduino-connections1
I noticed the potential divider on it and I thought, that this might be it! Because on the break out board, we have already have the capacitor, so we can ignore that (it still works without it anyway).
I don’t have any 15K resistors, so I am using a 4.7K in series with a 10K resistor. (Ignore the LEDs and the blue resistors, I was too lazy to remove them from the last project).
remote-XRF-to-Arduino-connections2
IMAG0711
Okay, it’s great that it works finally. But it’s kind of annoying having to setup the potential divider every time. So I made a small strip board with the potential divider soldered on, and it also has a female to female connection, so it’s easier to work with as well with the Arduino.
remote-XRF-to-Arduino-connections 6
Here is the new result:
remote-XRF-to-Arduino-connections 4
remote-XRF-to-Arduino-connections 7
remote-XRF-to-Arduino-connections 5
Although it’s cheap and easy enough to work around it, but I still would suggest to get a proper break out board with voltage conversion and additional functionality like power and data transmission indication.

Two XRF and Arduino Test Application

To verify they are working, I made this test application. There are two Arduino involved, both will be using the XRF modules to send and receive data. Arduino1 will be sending data – 0, 1, 2, 3, 4…. 8, 9, with an interval of one second. Arduino2 will receive these data, when received data is 1, the LED on pin13 (built-in LED) will light up for one second and then goes off, otherwise nothing will happen.
So in theory if everything is working, we should see the LED on Arduino2 light up every 10 seconds.

Code For the Sender – Arduino1

1int num = 0;
2 
3void setup(){
4    // start serial port at 9600 bps:
5    Serial.begin(9600);
6    pinMode(13, OUTPUT);
7 
8}
9 
10void loop(){
11    if (num++ >= 9)
12        num = 0;
13    delay(1000);
14 
15    Serial.write(num);
16}

Code For the Receiver- Arduino2

1int num;
2 
3void setup()
4{
5    // start serial port at 9600 bps:
6    Serial.begin(9600);
7    pinMode(13, OUTPUT);
8 
9}
10 
11void loop(){
12    if (Serial.available() > 0) {
13 
14        // get incoming byte:
15        num = Serial.read();
16 
17        if(num == 1){
18            digitalWrite(13, HIGH);   // set the LED on
19            delay(1000);              // wait for a second
20            digitalWrite(13, LOW);    // set the LED off
21        }
22 
23    }
24}
If you want to discuss or share your ideas, you can post something in our forum here.