Basic RF Communications

In this tutorial you will develop some code on the RFu-328 that will send some text over the radio to another radio that is connected to a Raspberry Pi. This is the basic premise for the Internet Of Things (IOT) where a light weight low powered sensor is able to transmit data which is consumed by The Cloud. The small footprint of the RFu-328 and its ability to interface with any sensor (either digital or analogue) makes it the perfect choice for an IOT sensor. The RFu-328 has exactly the same processing capability as the Arduino UNO and is programmed using the same code (sketches uploaded using the Arduino IDE). 

You will need:


All the construction work is explained in the tutorials listed below. 

 - We have assumed you know how to connect your Arduino development environment and can download sketches (code) from the Arduino IDE to the RFu-328. If not then follow the getting started section and also read the Blink tutorial.


The RFu-328 will be sensing messages to the Raspberry Pi so lets set up the Raspberry Pi so we can see the messages coming across the airwaves. Log in to your Raspberry Pi using the root user and navigate to the /usr/bin directory:

cd /usr/bin

Now load a terminal emulator called Miniterm. This emulator will display anything that comes from the serial port and it will send anything that is typed in to the serial port. 

python /dev/ttyAMA0

You should see a screen like this:

Now open up your Arduino IDE environment and create a new sketch (click File, New). Copy and paste the code below and save. 

Notice the two lines of code that enable the RF module on the RFu-328:

pinMode(8, OUTPUT);    // initialize pin 8 to control the radio
digitalWrite(8, HIGH); // enable the radio

Setting Pin 8 to HIGH enables the radio and setting it to LOW will disable the radio. 

The main loop builds an RF_Message variable with some text, "Count=", and concatenates a numeric counter:

RF_Message = "Count="+String(Counter);

Then we send the contents of RF_Message to the internal serial port that connects the ATMega processor to the radio module. The RFu-328 has two integrated chips, the ATMega processor (which is an Arduino UNO chip) and a radio module (which is a CISECO SRF chiup). The ATMega chip and the radio module are connected to each other via a serial port so anything that is sent to the serial port automatically gets transmitted over the airwaves. Conversely anything that is received over the airwaves is sent to the serial port (i.e. received by the ATMega processor). 


Upload the sketch to the RFu-328. Once complete and if you are using an FTDI cable then you must unplug it completely from the developer board so that the ATMega processor can communicate with the radio module properly. Power up the developer board, but not using the FTDI cable. 

Now go back to your Raspberry Pi and check if there are any messages being displayed. You should see something like this:

You can now modify the code to send anything you want. Try write some Arduino code to interface to a sensor, like a Potentiometer (POT), or a light sensor, or anything else you have and transmit the readings to your Raspberry Pi.