A Wireless Weather Alerting System

by Yongqiang Wang and Jammie R. Proctor for ECE 4180 Final Project @ Gatech

Introduction

In this final project for ECE 4180 @ Gatech, we built a wireless severe weather alerting system. The main purpose for this system is to monitor various weather conditions and alert the user of the device if there is any severe weather present that the user needs to be aware of.

This system has two different subsystems, the transmitter and receiver for the indoor location and outdoor location respectively. The sensors in the transmitter include: temperature and humidity sensor, air pressure sensor, wind direction sensor, wind speed sensor and rain gauge, sunlight intensity sensor, an Xbee kit for wireless communication and an mBed microcontroller for data collecting and processing.

The receiver has a Nokia LCD display, Pizeoelectric speaker, an Xbee kit for wireless communication, a weather band receiver and an mBed microcontroller for data receiving and processing.

Concept

The basic idea behind this project is similar to that of an alarm clock. However, instead of alerting the user at a certain time, the user is alerted during certain weather conditions.

Operation

The sensors mounted on the transmitter will collect the following weather information: temperature, humidity, air pressure, wind speed, wind direction, rain precipitation and sunlight intensity. The Xbee Module of the outside subsystem will then transmit all of the information to the Xbee of the receiver in the form of a character string.

From the receiver the string of characters will then be parsed and converted by the indoor mBed microcontroller and each item will be displayed on a Nokia LCD display. If the weather condition becomes severe, the indoor subsytem will sound an alarm in addition to activating a weather band receiver. This receiver automatically tunes into the local weather broadcast radio station which updates the user on the present environmental conditions and any precautionary steps that need to be executed with regards to those conditions.

This wireless weather alerting system could save lives especially in areas where there is no tornado warning systems and during the night when outside conditions are not clear and the user may be sleeping.

Code

Code for Outdoor

#include "mbed.h"
#include "SCP1000.h"
#include "SHTx/sht15.hpp"
#include "WeatherMeters.h"
 
Serial Xbee1(p13, p14);
DigitalOut rst1(p16);

SCP1000 scp1000(p5,p6,p7,p17);

SHTx::SHT15 sensor(p28, p27);

AnalogIn ain(p20);
DigitalOut busy(LED1);

Serial pc(USBTX, USBRX);

WeatherMeters station(p8, p15, p10, Weather_auto);

float w_speed = 0.0;
float w_direction = 0.0;
float w_raingauge = 0.0;

char a = 'T';
char data[15];
 
void xbeesend(float x)
{
    sprintf(data, "%5.1f", x);
        
    int i = 0;
    while (data[i] != NULL)
    {
        Xbee1.putc(data[i]);
        i++;
    }

    Xbee1.putc (' ');
}
 
int main() {

    rst1 = 0;   //Set reset pin to 0
    wait_ms(1);
    rst1 = 1;   //Set reset pin to 1
    wait_ms(1);
   
    while(1) {               
              
        w_speed = station.get_windspeed();
        w_direction = station.get_windvane();
        w_raingauge = station.get_raingauge();
        
        pc.printf("Wind speed: %4.1f m/s\r\n", w_speed);
        Xbee1.putc ('S');
        xbeesend (w_speed);
        
        pc.printf("Wind direction: %4.0f\r\n", w_direction);
        xbeesend (w_direction);
        
        pc.printf("Rain Gauge: %4.1f\r\n\n", w_raingauge);
        xbeesend (w_raingauge);
     
        
        busy = true;
        sensor.update();
        busy = false;     
        
        sensor.setOTPReload(false);
        sensor.setResolution(true);
 
        sensor.setScale(false);
        pc.printf("Temperature [ %3.1f C ]\r\n", sensor.getTemperature());

        xbeesend (sensor.getTemperature());
        
        pc.printf("Humdity     [ %3.1f %% ]\r\n\n", sensor.getHumidity());
        xbeesend (sensor.getHumidity());
       
        pc.printf("The pressure is %d Pa \r\n\n", scp1000.readPressure());
        xbeesend (scp1000.readPressure());
        
        pc.printf("Sun light intensity is %3.1f %%\r\n\n", ain * 100 );
        xbeesend (ain * 100);
        
        Xbee1.putc ('@');

        wait(5);
    }
}


Import libraryWeatherMeters

Weather Alert System

Code for Indoor

// - Weather Warning Alert System Receiver
// - Jammie Proctor

#include "mbed.h"
#include "NokiaLCD.h"

Serial Xbee1(p13, p14);                                 // TX, RX
I2C radio(p28, p27);                                    // sda, scl
NokiaLCD lcd(p5, p7, p8, p9, NokiaLCD::LCD6610);        // mosi, sclk, cs, rst, type LCD6610, PCF8833
DigitalOut Weather_rst(p29);                            // Weather band radio reset
DigitalOut rst1(p26);                                   // Xbee reset
DigitalOut beep(p21);                                   // Piezo speaker
DigitalOut MyRx(LED1);                                  // Data receive

//====================================== Global Variables =============================================
const int write_addr=0x22;                          
int wb_pwr_up[3]={0x01, 0x13, 0x05};                    // Weather band power-up command
int wb_station[4]={0x50, 0x00, 0xFD, 0xFC};             // Set weather band station to 162.55MHz
int reg_station=0xFDFC, i=0, Response, ack=0, pwr_down=0x11, tune=0x31;
int count,j;
int* p_pwr_down = &pwr_down;
int* p_tune = &tune;
float f = 162.5500;
float wndspd=0, wnddir=0,rngg=0,temp=0,humdty=0,press=0,sunint=0;
char c;
char t[100],                                            // Debug String ==> S1.2 34.5 6.7 89.0 12.8 34.5 67890.1@
ws[10], wd[10], rg[10], tp[10], hd[10], ps[10], sn[10]; 
bool alert=0;

//=============================== Support Functions for WB Radio ======================================
void SendCommand(int* array, int length) {              /* Send Command to Si4707 */
    radio.start();
    ack=radio.write(write_addr);
    for(i=0; i<length; i++) ack=radio.write(array[i]);
    Response=radio.read(ack);
    radio.stop();
    wait(.2);
}
    
void Reset(void) {                                      /* Reset weather band radio */
    Weather_rst=0;
    wait(.2);
    Weather_rst=1;
    wait(.2);
}

void WB_Restart(void) {                                 /* Reinitialize Weather band receiver */                          
    SendCommand(p_tune, 1);                             // Disable carrier
    wait(.2);
    SendCommand(p_pwr_down, 1);                         // Power down sequence
    wait(.2); 
    Reset();
    SendCommand(wb_pwr_up, 3);                          // Launch Weather band radio
    wait(.5);
    SendCommand(wb_station, 4);                         // Play current weather band station
}
 
// =========================================== Main Program ===========================================
int main() {
    beep=0;
    MyRx=0;
    rst1 = 0;   
    wait_ms(200);
    rst1 = 1;                                           // Reset Xbee
    radio.frequency(100000);                            // I^2C frequency setting 100kHz
    lcd.cls();                                          // Clear LCD 
    lcd.background(0x0000FF);                           // Set LCD background to blue  
    while(1) {
        if(alert) {
            beep=1; 
            wait(1);
            beep=0; 
            wait(1);
            beep=1; 
            wait(1);
            beep=0; 
            wait(1);
            beep=1; 
            wait(1);
            beep=0; 
            wait(1);
            beep=1; 
            wait(1);
            beep=0; 
            wait(1);
            Reset();                                            
            WB_Restart();                               // Start WB radio
            while(1);                                   // Reset mBed to break loop
            alert=0;
            lcd.cls();
            lcd.background(0x0000FF);
            SendCommand(p_tune, 1);                     
            wait(.2);
            SendCommand(p_pwr_down, 1);                 // Stop WB radio
            wait(.2); 
        }
        if(Xbee1.readable()) {                          // Data available to receive
           c=Xbee1.getc();
           if(c=='A') alert=1;                          // Send 'A' on serial port to sound speaker
           if(c=='S'){                                  // Beginning of data array
                int i=0;                                
                while((c=Xbee1.getc())!='@')            // Loop until terminator reached
                    t[i++]=c;
                t[i]='\0';
                count=0;
                j=0;  
                MyRx=1;
                wait_ms(200);
                MyRx=0;                
                for(int i=0; i<sizeof(t); i++) {        // Parse data array
                    if(t[i]=='\0') break;
                    if(t[i]==' ') continue;
                    if((t[i]!=' ')&&(t[i-1]==' ')) {
                        j=0;
                        count++;
                    }
                    switch(count) {                     // Space count of data array
                        case 1:                         // Build wind speed subarray
                            ws[j++]=t[i];
                            break;
                        case 2:                         // Build wind direction subarray
                            wd[j++]=t[i];               
                            break;
                        case 3:                         // Build rain gauge subarray
                            rg[j++]=t[i];
                            break;
                        case 4:                         // Build temperature subarray
                            tp[j++]=t[i];
                            break;
                        case 5:                         // Build humidity subarray
                            hd[j++]=t[i];
                            break;
                        case 6:                         // Build pressure subarray
                            ps[j++]=t[i];
                            break;
                        case 7:                         // Build sunlight intensity subarray
                            sn[j++]=t[i];
                            break;
                        default:;
                    }
                }
                wndspd=atof(ws);
                wnddir=atof(wd);
                rngg=atof(rg);
                temp=atof(tp);
                humdty=atof(hd);
                press=atof(ps);
                sunint=atof(sn);
                lcd.cls();
                //------------------- Define alerts (Thresholds can be adjusted by designer) -------------------
                if((temp>40)||(temp<0)) {
                    alert=1;
                    lcd.locate(0,10);
                    lcd.printf("Temperature!!!");
                    lcd.background(0xFF0000);
                }
                else if (wndspd>4){
                    alert=1;
                    lcd.locate(0,10);
                    lcd.printf("Wind!!!");
                    lcd.background(0xFF0000);
                }
                else if (humdty>95){
                    alert=1;
                    lcd.locate(0,10);
                    lcd.printf("Humidity!!!");
                    lcd.background(0xFF0000);
                }
                else if (sunint<10){
                    alert=1;
                    lcd.locate(0,10);
                    lcd.printf("Cloudy!!!");
                    lcd.background(0xFF0000);
                }
                else if ((3*rngg)>25){
                    alert=1;
                    lcd.locate(0,10);
                    lcd.printf("Flood!!!");
                    lcd.background(0xFF0000);
                }
                else lcd.background(0x0000FF);
                lcd.locate(0,1);
                lcd.printf("WndSPd: %3.1fm/s",wndspd);
                lcd.locate(0,2);
                lcd.printf("WndDir: %3.1fdg",wnddir);
                lcd.locate(0,3);
                lcd.printf("Rain: %3.1fmm/hr",3*rngg);
                lcd.locate(0,4);
                lcd.printf("TEMP: %3.1fC",temp); 
                lcd.locate(0,5);
                lcd.printf("Humidity: %3.1f%%",humdty); 
                lcd.locate(0,6);
                lcd.printf("Press: %5.1fPa",press); 
                lcd.locate(0,7);
                lcd.printf("Sun: %3.1f%%",sunint);
                wait(1); 
           }
           MyRx=1;
           wait_ms(200);
           MyRx=0;     
        }
    } 
}

Import programReceiver

Weather Band Receiver

Wiring and Bill of Materials

Transmitter:

Temperature and Humidity Sensor

SHT15mBed
GNDGND
V3.3Vcc
Datap28
Sckp27

Air Pressure Sensor

SCP1000mBed
Csbp8
Misop6
Mosip5
Sckp7

Xbee Wireless Connection

XbeemBed
GNDGND
VddVout
Doutp14
Dinp13
Resetp16

RainGauge

RainGaugemBed
p3p10
GNDGND

WindStation

WindStationmBed
p2GND
p3GND
p4p8
p5p15

Receiver:

Nokia LCD

LCD6610mBed
GNDGND
3.3V3.3V
Vbatt5V
Resetp9
DIOp5
SCKp7
CSp8

Weather Band Receiver

Si4707mBed
GNDGND
3.3V3.3V
RSTp29
SENGND
SCLKp27
SDIOp28

Xbee Wireless Connection

XbeemBed
GNDGND
VddVout
Doutp14
Dinp13
Resetp26

RainGauge

Piezo SpeakermBed
Black WireGND
Red Wirep21

Future Works

For further extension of this project, we will: a) use WiFly wireless communication kits to post weather information in the website, such as Weather underground b) use mulitple Xbee receiver to display the weather information

Image

Weather Station Sensors Setup Photo /media/uploads/yongqiangwang/photo_5.jpg

Weather Information Display Subsystem /media/uploads/yongqiangwang/photo_6.jpg

Screen Shot When Weather Alert Occurs /media/uploads/yongqiangwang/photo_2.jpg

Video


Please log in to post comments.