Skip links
Radiofrequency on new developments

Radiofrequency, gamble on new developments over IoT.

By Pablo Acosta on Friday, September 27, 2019

Radiofrequency is one of the most common technologies used nowadays, from a simple relay to medical solutions. In these times it is not expensive if your requirements need it, but when you are involved in bigger solutions, higher specs are important, like the speed of transmission, the distance of transmission, modulation of the signal, frequency of work (EU, USA).

All these characteristics are a huge knowledge background just to be a hobbyist, but believe me, there are a lot of people out there who really know about this stuff without being an Engineer. The main theme here is not to be technical, and I will explain it as clearly as possible.

Picking the Best Module.

For your requirements or ideas, you will find a lot of products in the market. We are going to concentrate on the XBee module, more exactly the XBee 802.15.4 API2. This module is the big brother of the ZigBee. Very popular module with hobbyists and students. This module has a cover distance of around 1Km in the real test fields.

Radiofrequency on new developments

This module comes with some IO pins and also ADC entrances, so, with an MCU (Microcontroller) you can monitor any signals with its ADC and interact with any transducer connected to the module. For example:


So, what kind of RF (Radio Frequency) can be used in real life?


Enable/disable a relay.

Enable/disable an alarm.

Enable/disable lights.



Monitor gas station capacity.

Monitor the level voltage of a line.

Monitor temperature from a sensor.


These are basic examples of this RF. The best part of IoT (Internet of Things) and with my experience is how to get data; without it, we can’t do anything. So with a simple MCU like PSOC from Cypress which is one of the most gifted microcontrollers with the famous PIC from Microchip, we can develop a quick prototype interface with our hardware.

For this example, we used:

PSoC 4 Architecture TRM 

PSoC 4200 Family 


Three serial outputs were configured, two SCB blocks with UART and the last as an I2C with a serial component, these are serial protocols well used over the industry.

Radiofrequency on new developments

The previous image is a semiautomatic configuration for this block, and we said “semiautomatic” because this kit allows us to develop a quick block diagram which will be translated as a Verilog (Hardware Description Language). We need to define two pins as a minimum, one pin for input (RX), and one pin for output (TX). This component must be named XBEE_UART to work correctly with the following custom library.

The full “Top Design” will be this and it is showing us a full 3 serial connection for this device, four analog inputs, two timers which depend on 1MHz clock, and three manual inputs.

For my purposes this design allows me to communicate with an I2C memory, PLC Modbus communication, and out XBee RF module. The following image is a schematic representation and PCB of what is expected for this idea. This is a complete and functional design and can be an easier design different from these images. The following are an illustrative representation:

Radiofrequency on new developments
Radiofrequency on new developments

This code was written in C and it is a simple example of what is intended. It is also easy to use:

The structure of a XBee Package is a little complex as we can see in this snippet of code from xbee.h:

ypedef struct xbee_pck


//Regular Package Normalization

uint16 length;

uint8 apiid;

uint8 frameid;

uint8 macmsb[4];

uint8 maclsb[4];

uint8 netaddr[2];

uint8 options;

uint8 *rfdata;

uint8 *rfdata2escape;

uint8 rflength;

uint8 checksum;

uint8 checksumcalc;

//RX additional parameters

uint8 rssi;

//AT Response

uint8 command[2];

uint8 status;

uint8 commdata[100];

//TX parameters

uint8 destination_address[8];


struct xbee_pck *pck;

    } xbee_pck;

Like every protocol, this is defined as well constructed peer to peer module. We have a MAC address, a package length, signal intensity, RSSI name, destination, and the data. Other kinds of stuff as AT response are for complex usage as OTAP (On the Air Programming) for module configuration. It implements a standard linked queue to manage a sequence for every package received.

So here we can see the stripped part of the RF and what are the main parts to identify in a real-time process. Yes, I said “Real-Time”.

In order to work with the code, we must follow some steps:

Step 0 – Include the header library

#include “xbee.h”

 Step 1 – Must call the initialization


 Step 2 – Verify if there is a new package


If there is a new package, then it is saved in the queue XBeeRX. Just check that the queue is not empty.

if (XBeeRX){ … }

There are three kinds of packages which depend on an API id:

0x80 – 64 Bit Address.

0x89 – TX Response.

0x97 – AT Command Response.

 Step 3 – If you need to send a package

You must first create the structure.

xbe_pck* mypck = get_xbee_pck();

Add the data needed for a good package. We will not discuss this, we will just be pointing on what is needed, which is:





And finally you must send it… 


This technology with a simple code and a correct HW can help us to develop quick and easy, even with security, this RF module can be configured with an AES-256 so the data is encrypted from peer to peer.

We can test safe in our own environments like home and work. For example, with one module as a server and a second module as a listener, we can turn off and on the lights of our work and home in a safe environment and nobody can trace our raw packet if we use AES.

As for me, I have tested them on irrigation and in more aggressive environments like greenhouses and farms. We can start water pumps, turn on/off lights, emergency stops, sensors, pH, and Ce on irrigation line, the pressure of water, etc. So, we do not need to be experts on HW in order to “create” something for us. There are a lot of modules for hobbyist which actually do the hard work, like signal processing, power stage, ADC/DAC modules, and many other toys if you don’t have the knowledge in electronics to design all this stuff.

The radiofrequency works on every aspect of our life, like Radio, TV, WiFi, Bluetooth, RFID, NFC, GPS, GPRS, 4G, infrared, etc. We must not be afraid just to hear “hardware implementation”, the main part is about the device reading and package managing.

What can we do to maximize the opportunity of these technologies? That depends on us. In our design, manufacture, programming skills, and the main point… the release of the prototype. It can guarantee us the correct behavior of what we call “field test” but for me my backyard.


AI and radio frequency communications: Trends and innovations happening now. (2019, August 18). Retrieved September 27, 2019, from

XBee® Zigbee® Mesh Kit. (2019, August 19). Retrieved October 11, 2019, from

Programmable System-on-Chip (PSoC®). (2017, July 10). Retrieved October 11, 2019, from

Author: Pablo Acosta

This website uses cookies to improve your web experience.