0% found this document useful (0 votes)
134 views

Weather Monitoring System Project

This document describes a weather monitoring system comprised of remote sensing units that collect temperature, humidity, and other weather data every 15 minutes. The units send the data via SMS to a central station that stores the information in a database and archives older data. The general architecture includes remote units that can store data locally if communication fails and send it later. Hardware and software requirements are specified for the remote units and central system.

Uploaded by

mohed_kamal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
134 views

Weather Monitoring System Project

This document describes a weather monitoring system comprised of remote sensing units that collect temperature, humidity, and other weather data every 15 minutes. The units send the data via SMS to a central station that stores the information in a database and archives older data. The general architecture includes remote units that can store data locally if communication fails and send it later. Hardware and software requirements are specified for the remote units and central system.

Uploaded by

mohed_kamal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

NEELAIN UNIVERSITY

Directed Project
Weather Monitoring System
Mohamed Kamal Eldin Ali

Supervised By: Dr Sharif Babikir

Version3

P a g e 0 | 16
System specification:
SYS1: The System shall be able to monitor weather characteristics covering:
1. Temperature (implemented)
2. Humidity(implemented)
3. Wind direction (Future Work)
4. Wind speed (Future Work)
5. Rain level (Future Work)
6. Air pressure (Future Work)

SYS2: The System shall be comprised of a central station that collects the weather
information from remote sensing units.

SYS3: The remote sensing units shall send the weather information every 15 minutes.

SYS4: The communication media shall be mobile telecom channels through 2G/3G SMS
sending.

SYS5: The central station shall store the weather information in a database and archive data
older than 5 years to tape or any suitable archiving solution.

SYS6: The remote sensing units shall store the weather information in case of
communication link failure locally and send it to the central station as soon as the
communication link is up.

SYS7: the remote sensing unit shall provide monitoring for the underlying Hardware and
Software health status.

SYS8: The general architecture of the System is shown below:


Figure1 General Architecture of the system
Hardware Requirements:
HRD1: The Central System that collects the data shall be a desktop or server and has a
standby server to be switched to in case of failure of active server.

HRD2: The remote sensing units shall be built around a low cost microcontroller to minimize
the cost of each unit.

HRD3: The remote sensing units shall be housed in a well-ventilated enclosure and shall
have more cooling mechanisms in place as needed (Heat sinks and Fans).

HRD4: The remote sensing unit shall have two versions in respect to power, one with AC
supply and other with solar panel and battery in remote areas where AC is not available.

HRD5: The remote sensing unit shall have multiple versions in respect to communication;
either GSM based, Ethernet based or directly connected to a PC using serial or USB.

HRD6: Temperature reading accuracy shall be to 0.5 degrees centigrade.

HRD7: Temperature measurement range shall be from 0 to80 degrees.

HRD8: Humidity measurement range shall be from 0 to 100 RH (Relative Humidity).

Software Requirements:
SW1: The central System which collects the weather information will be accepting messages
from the remote sensing units and files each unit’s messages into a separate table for which
each distinctive unit has its own table in a database.

SW2: Each remote sensing unit shall send messages containing the weather information and
shall have a unique header ID per unit.
SW3: The server shall accept the messages in FIFO like fashion and classifies the messages
based on the message header (MsgID).

SW4: The message format shall be in the format:


StartOfMessag MsgID Temperature Humidity Wind Speed EndOfMessage
e

SW5: The central station shall receive messages from a varying number of remote sensing
units and shall write the message as a record in a flat file database and loaded to a
database (MySQL) to be further processed for reporting purposes using SQL(Structured
Query Language).

Hardware Design:

Circuit Diagram:
CTS P1
RTS
1
DCD
6
TXD RX DSR
2
RXD
7
RXD TX RTS
3
TXD
8
9600,n,8,1 4
CTS
DTR
9
RI
http://coopermaa2nd.blogspot.com/

Barebone Arduino (UNO/Duemilanove) ERROR


COMPIM
IOL U1 IOH
8 0 RX 2 14 8 1
PD0/RXD/PCINT16 PB0/ICP1/CLKO/PCINT0
7 1 TX 3 15 PWM1A 9 2
PD1/TXD/PCINT17 PB1/OC1A/PCINT1
6 2 4 16 PWM1B 10 3
PD2/INT0/PCINT18 PB2/SS/OC1B/PCINT2
5 3 PWM2B 5 17 PWM2A 11 4
4 4 6
PD3/INT1/OC2B/PCINT19 PB3/MOSI/OC2A/PCINT3
18 12 5 RV1
PD4/T0/XCK/PCINT20 PB4/MISO/PCINT4
3 5 PWM0B 11 19 13 6
PD5/T1/OC0B/PCINT21 PB5/SCK/PCINT5
2 6 PWM0A 12 9 7
PD6/AIN0/OC0A/PCINT22 PB6/TOSC1/XTAL1/PCINT6
1 7 13 10 8

40%
PD7/AIN1/PCINT23 PB7/TOSC2/XTAL2/PCINT7 A0
6 21 23 A0 1
AREF PC0/ADC0/PCINT8
5 20 24 A1 2

POWER
AVCC PC1/ADC1/PCINT9
4 25 A2 3 10k
3
PC2/ADC2/PCINT10
26 A3 4 AD
PC3/ADC3/PCINT11
2 27 A4 5
PC4/ADC4/SDA/PCINT12
U4(VCC) 1 28 A5 6
PC5/ADC5/SCL/PCINT13
1
PC6/RESET/PCINT14
ATMEGA328P

R2 13

2
220k
U4
8

4 3 R1 R2
VCC

R Q
50
7
DC L 10k
R3
5
CV R1 120k
6.8M
LED-RED
1 U2
GND

2 6
TR TH

C2 C1 41.0
1

100nF 555 100nF

2
VOUT

U1
95.0 R4 3 LM35
4.7M
%HR
HCH-1000

Main Hardware Components for the remote sensing unit:

HRDES1: Arduino UNO development board which is built around a low power and
affordable microcontroller ATMEGA 328P.

HRDES2: Temperature sensor LM35(linearly proportional analog output to the current


temperature).

HRDES3: Humidity Sensor HCH-1000 (Based on a variable capacitor concept)

HRDES4: Timer 555 acting as an Astable multi-vibrator which the humidity sensor is acting
as a capacitor in its circuit and is affecting the frequency output of the Timer 555 which is
input to the uC and then frequency calculation is done and hence RH is calculated.

HRDES5: RS232 Serial connector which connects the TX/RX pins on the microcontroller to
the PC.
Software Design
Remote Sensing Unit Sequence diagram and DFD
Server side Sequence diagram and DFD
Server Technologies used
The server side is built upon open source technology stack LAMP (Linux,Apache,MySQL,PHP)
Running in a virtual machine and interfaced to proteus simulation using ELTIMA virtual com
which enables application to communicate through a virtual serial port internally across the
Operating system.

Linux is the operating system of choice because of its open source nature in addition to stability
and performance, Linux is run in a virtual machine so it can be interfaced to proteus simulation
and read from its serial port the microcontroller weather data and writes it to a flat file using
standard UNIX read() system call.

MySQL database: Gets loaded data using a sql loader script and inserts into a per region table
dependent on the MSGID field value coming from different units.

Apache: A web server which users connect to across the LAN or internet to get current data or
retrieve reports.

PHP: is a CGI (Common Gateway Interface) language which provides the dynamic part of the
web experience and effectively connects the MySQL database and retrieves the Weather info
and displays it in HTML format which is accessible through the HTTP protocol.

Results
The result of this project is that it is possible to deploy microcontroller units across the
country and acquiring weather information in a central location and storing the data on a
Database that is interfaced using web access and possible reports can be generated for any
processing requirements.

Given a Lab environment this can be realized in hardware and then tested in the field of
operation.

Appendix

Microcontroller code to read temperature and humidity:


int analogPin = 2;

int readValue = 0;

float temperature = 0;

float temperatureF = 0;

const int pin = 7; // Analog input pin

unsigned long duration;


const int sensor_offset = 1889; //the offset to give correct RH value

void setup() {

Serial.begin(9600);

pinMode(pin, INPUT);

void loop() {

readValue = analogRead(analogPin);

//Serial.println(readValue);

temperature = (readValue * 0.00049);

temperature = temperature * 100;

temperatureF = (temperature * 1.8) + 32;

Serial.print("Temperature: ");

Serial.print(temperature);

Serial.print("C ");

Serial.print(temperatureF);

Serial.println("F");

delay(1000);

duration = 0;

byte j = 0; // for start counter enter digits

for (j = 0; j < 16 ; j +=1)

duration += pulseIn(pin, HIGH);

} //pulse width has some jitter so get average to smooth

duration /=16;

long humid =( duration - sensor_offset)/10.23; //max is 1023 and to %

Serial.print("sensor = " );

Serial.print(duration); // print the adc value to the serial monitor:

Serial.print("\t humidity = ");

Serial.print(humid); // print the humidity

Serial.println(" %");

delay(1000); // wait 1 second before next sample

}
Server Code (Linux code to read from serial):
#include<unistd.h>

#include<fcntl.h>

#include<stdio.h>

#include<termios.h>

int main ()

speed_t baud = B9600; /* baud rate */

struct termios settings;

int serialfd;

int datafile;

char buffer[28];

int readbuffer;

int writebuffer;
datafile=open("/root/directed_project/temperature_data.txt",O_WRONLY|O_CREAT|O_APPEND);

serialfd=open("/dev/ttyS1",O_RDONLY);

tcgetattr(serialfd, &settings);

cfsetospeed(&settings, baud); /* baud rate */

settings.c_cflag &= ~PARENB; /* no parity */

settings.c_cflag &= ~CSTOPB; /* 1 stop bit */

settings.c_cflag &= ~CSIZE;

settings.c_cflag |= CS8 | CLOCAL; /* 8 bits */

settings.c_lflag = ICANON; /* canonical mode */

settings.c_oflag &= ~OPOST; /* raw output */

tcsetattr(serialfd, TCSANOW, &settings); /* apply the settings */

if(serialfd==-1)

perror("Error opening serial port \n");

else

while(1)

readbuffer=read(serialfd,buffer,sizeof(buffer));

if (readbuffer<0)

perror("error reading data\n");

else

writebuffer=write(datafile,buffer,sizeof(buffer));

if (writebuffer<0)

perror("Error writing to file");

return 0;

Loader mysql script ( load flat file into MySQL database):

LOAD DATA LOCAL INFILE 'weather.txt' INTO TABLE weather


FIELDS TERMINATED BY ','

PHP script to read from database and display in HTML format using apache:

<?php

// Create connection

$con=mysqli_connect("localhost","root","14r00t","weather_info");

// Check connection

if (mysqli_connect_errno($con))

echo "Failed to connect to MySQL: " . mysqli_connect_error();

else

echo "successfull connection to database";

echo "<br><br>";

$result = mysqli_query($con,"SELECT * FROM weather");

while($row = mysqli_fetch_array($result))

// echo $row['FirstName'] . " " . $row['LastName'];

echo $row['id']." ".$row['temp'] ." ".$row['humid'];

echo "<br />";

mysqli_close($con);

?>

You might also like