Monday, June 5, 2023

Designing Wireless Gas Detection and Monitoring Systems

- Advertisement -

Monitoring Station Software

The software listing of the monitoring station is given below. At the beginning of the program the interface between the LCD and the microcontroller is defined and PORTB and PORTC are configured as digital ports. Then the UART is initialized to 9600 baud and the LCD is initialized. The program then enters an endless loop where inside this loop the program waits until data is received from a detection station, terminated with the “/” character. After receiving valid data the station ID of the station is displayed and the buzzer is activated. The program repeats after one minute delay.



- Advertisement -


This is the software for the gas monitoring station. The system is built using the following components:

PIC18F45K22 microcontroller (with 8MHz crystal, and 2x22pF capacitors)

2×16 character LCD

Buzzer (with BC846 transistor switch)

Radiometrix TX2A RF receiver module

The gas monitoring station receives messages from the detection stations when gas leakage has been

detected and it displays a message on the LCD giving the station ID and also activating the buzzer.

Author:    Dogan Ibrahim

Date:        July 2016

Program: Monitoring.c



// LCD pinout settings

sbit LCD_RS at RB4_bit;

sbit LCD_EN at RB5_bit;

sbit LCD_D7 at RB3_bit;

sbit LCD_D6 at RB2_bit;

sbit LCD_D5 at RB1_bit;

sbit LCD_D4 at RB0_bit;

// LCD pin direction

sbit LCD_RS_Direction at TRISB4_bit;

sbit LCD_EN_Direction at TRISB5_bit;

sbit LCD_D7_Direction at TRISB3_bit;

sbit LCD_D6_Direction at TRISB2_bit;

sbit LCD_D5_Direction at TRISB1_bit;

sbit LCD_D4_Direction at TRISB0_bit;

void main()


     unsigned char Txt[10];

     unsigned char ID;

     ANSELB = 0;                                                                                  // PORTB is digital

     ANSELC = 0;                                                                                 // PORTC is digital

     TRISB = 0;

     LCD_Init();                                                                                        // Initialize LCD

     UART1_Init(9600);                                                                           // Initialize UART


     while(1)                                                                                               // Do Forever


         Lcd_Cmd(_LCD_CLEAR);                                                                    // Clear LCD

         BUZZER = 0;                                                                             // Stop the buzzer

         if(UART1_Data_Ready() == 1)                                                    // If data received


              UART1_Read_Text(Txt, “/”, 255);                             // Read until the terminator

              if(Txt[0] == ‘I’ && Txt[1] == ‘D’ && Txt[2] == ‘=’)                       // IF ID found


                  Lcd_Out(1,1,”Gas Leakage:”);                                          // Display message

                  Lcd_Out(2,1,Txt);                                                          // Display station ID

                  BUZZER = 1;                                                                     // Activate buzzer

                  Delay_Ms(60000);                                                               // Wait 1 minute





Software listing of the monitoring station

Displaying an alarm condition from station 03
Displaying an alarm condition from station 03



What's New @

Truly Innovative Tech

MOst Popular Videos

Electronics Components

Tech Contests