TX2H is pin compatible with the lower power TXL2 and the higher power TX2EH, and therefore compatible longer or shorter range transmitter modules can be used without having to change the hardware or the software of a station. The module is powered from the +5V supply and is connected to UART output (TX) of the microcontroller. A helical, loop, or a whip antenna can be used with the module. The length of the whip antenna should be 16.4cm total from the RF pin. The pin configuration of TX2H is shown in Table 1. The gas detection stations can be powered from +5V mains adapters, usually used to charge mobile phones.
TX2H pin | Name | Function |
1 | RF gnd | RF ground |
2 | RF out | 50 ohm RF output to antenna |
3 | VCC | + 5V DC supply input |
4 | GND | DC supply ground |
5 | TXD | Transmit data input |
Monitoring Station
Shown below is the circuit diagram of the monitoring station. In this design a PIC18F45K22 microcontroller is used with an LCD display and a buzzer. The microcontroller is clocked using 8MHz crystal. Although a microcontroller is used in this design, in large systems it may be preferable to use a PC instead.
A compatible RX2A UHF receiver module is used at the monitoring station. This module has a receive sensitivity of -108dBm and operates with power supply from 2.7V to 16V. The typical current consumption is 11.6mA. The use of the module requires the connection of an external antenna. The received data pin is connected to the UART input (RX) of the microcontroller. Below table gives the pin configuration of the RX2A.
TX2H pin | Name | Function |
1 | RF in | 50 ohm input from the antenna |
2 | RF gnd | RF ground |
3 | RSSI | Received signal strength |
4 | GND | DC supply ground |
5 | VCC | DC power supply |
6 | AF out | Analog output from the FM demodulator |
7 | RXD | Received data input |


Software
The software of the system has been developed using the mikroC Pro for PIC language, compiler, and the IDE developed by mikroElektronika (www.mikroe.com). mikroC is a standard C compatible language developed specifically for the PIC microcontrollers and has a rich library of functions including RS232, SPI, I2C, LCD, GLCD, TFT, SD card, PWM and many more.
Detection Station Software
The software listing of a detection station is given below. At the beginning of the program the threshold is set to 2500mV so that the system is activated when the LPG concentration level is approximately above 800ppm. Then PORTB is configured as digital input and RA1 is configured as analog input. PORTB internal pull-ups are enabled and the UART is initialized to operate at 9600 baud. The remainder of the program executes in an endless loop. Inside this loop, the sensor output is read and converted into millivolts. If the sensor output is greater than 2.5V then the station ID is read and the message ID=nn/ is sent to the monitoring station. Here nn is the station ID and character “/” is the terminator of data. The program repeats after one minute delay.
/************************************************************************
GAS MONITOR STATION
===================
This is the software for the gas detector station. The system is built using the following components:
PIC18F2550 microcontroller (with 8MHz crystal, and 2x22pF capacitors)
MQ-6 LPG gas sensor chip
10K potentiometer
4-way switch
Radiometrix TX2H RF transmitter module
A gas detector station detects the presence of LPG gas and sends a message to the gas monitoring station together with the station ID to alert that gas has been detected.
Author: Dogan Ibrahim
Date: July 2016
Program: Detector.c
************************************************************************/
void main()
{
unsigned int ADC;
unsigned char ID, Msg[10]= “ID=”;
unsigned char Txt[4];
float mV;
float threshold = 2500.0; // Threshold (in mV)
ADCON1 = 0x0D; // RA1 analog, PORTB digital
TRISA = 2; // RA1 is input
TRISB = 0x0F; // RB0-RB3 are inputs
INTCON2.RBPU = 0; // Enable PORTB pull-ups
UART1_Init(9600); // Initialize UART
while(1) // Do Forever
{
ADC = ADC_Read(1); // Read LPG Sensor
mV = ADC*5000.0 / 1024.0; // Analog sensor voltage
if(mV > Threshold) // If > 2.5V
{
ID = PORTB; // Read PORTB data
ID = ID & 0x0F; // Extract low nibble
if(ID > 9) // If ID > 9
{
Txt[0] = ID / 10;
Txt[1] = ID – 10*Txt[0] + ‘0’; // Convert to string
Txt[0] = Txt[0] + ‘0’; // Convert to string
}
else // If ID <= 9
{
Txt[0] = ‘0’;
Txt[1] = ID + ‘0’; // Convert to string
}
Txt[2] = ‘/’; // Insert terminator
Txt[3] = 0x0; // Insert NULL
strcat(Msg, Txt); // Combine ID= with ID number
UART1_Write_Text(Msg); // Send Msg to UART
Delay_Ms(60000); // Wait 1 minute and repeat
}
}
}