Weather Monitoring System Project
Weather Monitoring System Project
Directed Project
Weather Monitoring System
Mohamed Kamal Eldin Ali
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.
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.
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).
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/
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
2
VOUT
U1
95.0 R4 3 LM35
4.7M
%HR
HCH-1000
HRDES1: Arduino UNO development board which is built around a low power and
affordable microcontroller ATMEGA 328P.
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
int readValue = 0;
float temperature = 0;
float temperatureF = 0;
void setup() {
Serial.begin(9600);
pinMode(pin, INPUT);
void loop() {
readValue = analogRead(analogPin);
//Serial.println(readValue);
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.print("C ");
Serial.print(temperatureF);
Serial.println("F");
delay(1000);
duration = 0;
duration /=16;
Serial.print("sensor = " );
Serial.println(" %");
}
Server Code (Linux code to read from serial):
#include<unistd.h>
#include<fcntl.h>
#include<stdio.h>
#include<termios.h>
int main ()
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);
if(serialfd==-1)
else
while(1)
readbuffer=read(serialfd,buffer,sizeof(buffer));
if (readbuffer<0)
else
writebuffer=write(datafile,buffer,sizeof(buffer));
if (writebuffer<0)
return 0;
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))
else
echo "<br><br>";
while($row = mysqli_fetch_array($result))
mysqli_close($con);
?>