Académique Documents
Professionnel Documents
Culture Documents
Software Implmentation
➢ Introduction
This chapter discusses the implementation of the system. Section 7.2 provides the technical
information
about the database system, System 7.3 outlines the modular structure of the system, showing the
various
Modules Implemented to form coplete System. Section 7.4 provides an actual code which implement
in
coding phase of software development life cycle.
➢ Database used
Parallax Data Acquisition tool (PLX-DAQ) software add-in for Microsoft Excel acquires up to 26
channels of data from any Parallax microcontrollers and drops the numbers into columns as they
arrive. PLX-DAQ provides easy spreadsheet analysis of data collected in the field, laboratory analysis
of sensors and real-time equipment monitoring.
There are several ways to save data from a sensor attached to an Arduino. If you’re connected to
a personal computer, you can simply send the data from the Arduino to the personal computer
serially, and save it to a file. If you’ve got an SD card attached to the microcontroller, you can
save the data to the card. Or, if you have access to the internet and a device that can connect to
a server, you can save the data to a server. In the tutorial below, you’ll read a DHT11
temperature and humidity sensor and log data
It features calculation, graphing tools, pivot tables, and a macro programming language
called Visual Basic for Applications. It has been a very widely applied spreadsheet for these
platforms
➢ Important Modules And Algorithm
The important module and algorithm used in project are as follows.
Registration Module
This module is usedfor registration of customer. Admin user is allready present in the system. For
more secure login MD-5 hash algorithm is used to calculated hash value for password. Using these
hash values login authentication is provided.
➢ Algorithm Used
MD5 Hash algorithm:
The MD5 message-digest algorithm is a widely used hash function producing a 128-bit hash value.
Although MD5 was initially designed to be used as a cryptographic hash function, it has been found
to suffer from extensive vulnerabilities. It can still be used as a checksum to verify data integrity, but
only against unintentional corruption. It remains suitable for other non-cryptographic purposes, for
example for determining the partition for a particular key in a partitioned database.
One basic requirement of any cryptographic hash function is that it should be computationally
infeasible to find two distinct messages which hash to the same value. MD5 fails this requirement
catastrophically; such collisions can be found in seconds on an ordinary home computer.
Input: Arbitrary Length Message(Password)
Output: 128 bit Message Digest for input.
Steps - It operates as follows
1. Take User password as input to calculate Message Digest for it.
2. Input Message is broken up into chunks of 512 bits blocks (16 - 32 bits words).
3.Append Padding bits. (Message is padded , so that its length (in bits) become compatible to 448 ,
module 512 bits.) Padding A single 1 is appended, and then 0 bits are appended , and then 0 bits are
appended, so that the length in bits of padded message becomes to 448, modulo 512.
4.Append Length: A 64 bit representation of b(Message length) is appended to the result of previous
step.
At this point the resulting Message has a length exact multiple of 512 bits.
5.Initialize MD Buffers: A four word buffers (A,B,C,D) are used to compute the message digest.
(A,B,C,D
6.Process Message in sixteen word blocks.
(F,G,H,I). There are 4 round , each involve 16 basic operation.
7.Message Digest is generated.
➢ Major Code
The major code of project is given below.
A. INTEGRATED CODE
int led = 13; // the pin that the LED is atteched to
int PIRsensor = 2; // the pin that the sensor is atteched to
int MOTION; // variable to store the sensor status (value)
int sensorPin1_OUTSIDE = A5; // select the input pin for LDR
int sensorPin2_INSIDE = A1;
int In1 = 7;
int In2 = 8;
int ENA = 5;
int SPEED = 255;
int MQ_PIN=A0;
int voltagef=0;
int voltage1=0;
//--------FAN VARIABLES
int temp=A3;
int temperature=0;
int MQCalibration(MQ_PIN);
int sensorValue1_OUTSIDE = 0; // variable to store the value coming from the sensor
int sensorValue2_INSIDE = 0;
int voltage=0;
//-----------------------------------------------------------------------------
void setup() {
pinMode(led, OUTPUT); // initalize LED as an output
pinMode(PIRsensor, INPUT); // initialize sensor as an input
pinMode(In1, OUTPUT);
pinMode(In2, OUTPUT);
pinMode(ENA, OUTPUT);
pinMode(In1f, OUTPUT);
pinMode(In2f, OUTPUT);
pinMode(ENA, OUTPUT);
Serial.begin(9600);
Serial.println("CLEARDATA");
Serial.println("LABEL,Date,Computer Time,MOTION SENSED,BULB
VOLTAGE(mv),TEMPRETURE VALUE,FAN VOLTAGE(mv),MOTION STATUS");
delay(2000);
//Serial.begin(9600); //UART setup, baudrate = 9600bps
//-----------------------------------------------------------------------------
void loop() {
MOTION=0;
sensorValue1_OUTSIDE = analogRead(sensorPin1_OUTSIDE); // read the value from the sensor
LDR
sensorValue2_INSIDE = analogRead(sensorPin2_INSIDE); // read the value from the sensor LDR
MOTION = digitalRead(PIRsensor); // read sensor valueU
//------------------------------------------
//motor code
digitalWrite(In1, HIGH);
digitalWrite(In2,LOW);
analogWrite(ENA, SPEED);
delay(1000);
// Serial.println("Outside light is High");
digitalWrite(led, LOW);
delay(2000);
digitalWrite(In1, LOW);
digitalWrite(In2,LOW);
}
else if (sensorValue1_OUTSIDE < sensorValue2_INSIDE)
{
// Serial.print(sensorValue2_INSIDE);
// Serial.println("Inside light is High");
digitalWrite(led, LOW);
delay(3000);
digitalWrite(In1, LOW);
digitalWrite(In2,LOW);
// VOLTAGE CALCULATION
// Serial.println(voltage);
}
//----------------------------------------FAN OPERATION---------------------------------------------
temperature=analogRead(temp);
temperature=(5.0 * temperature * 100.0) / 1024;
// Serial.print("hiiiii");
//Serial.print("temperature");
//Serial.println(temperature);
if (temperature > 38)
{
digitalWrite(In1f, HIGH);
digitalWrite(In2f, LOW);
analogWrite(ENAf, SPEEDf);
int sensorValue = analogRead(In1f);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltagef = sensorValue * (5.0 / 1023.0);
int voltage1=voltagef/10;
// Serial.println(voltage);
}
else
{
digitalWrite(In1f, LOW);
digitalWrite(In2f, LOW);
analogWrite(ENAf, 0);
}
//-----------------------MQ2 SENSOR CODE-----------------------------------//
/*
else if(gas detected)
Buzzer on
*/
}
//------------------------------------MOTION NOT DETECTED--------------------------------------
if(MOTION==LOW)
{
//LIGHT OFF
digitalWrite(led, LOW);
Serial.print("Motion NOT Detected");
//FAN OFF
digitalWrite(In1f, LOW);
digitalWrite(In2f, LOW);
//analogWrite(ENAf, 0);
}
int sensorValue = analogRead(13);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltagef = sensorValue * (5.0 / 1023.0);
//Serial.print("ON");
// Serial.println(voltagef);
Serial.println("--------------------");
Serial.print("DATA,DATE,TIME," + String(MOTION) +","+ int(sensorValue2_INSIDE) +","+
int(sensorValue1_OUTSIDE) +","+ float(temperature) +","+ int(voltage1));
delay(1000);
#define MQ_PIN (0) //define which analog input channel you are going to use
#define RL_VALUE (.01) //define the load resistance on the board, in kilo ohms
#define RO_CLEAN_AIR_FACTOR (.083) //RO_CLEAR_AIR_FACTOR=(Sensor
resistance in clean air)/RO,
//which is derived from the chart in datasheet
/****************************Globals**********************************************/
float LPGCurve[3] = {2.3,0.21,-0.47}; //two points are taken from the curve.
void loop(){
Serial.print("DATA,TIME,");
Serial.print(",");
Serial.print("LPG:");
Serial.print(MQGetGasPercentage(MQRead(MQ_PIN)/Ro,GAS_LPG) );
Serial.print( "ppm" );
Serial.print(" ");
Serial.print(" ");
Serial.print("SMOKE:");
Serial.print(MQGetGasPercentage(MQRead(MQ_PIN)/Ro,GAS_SMOKE) );
Serial.print( "ppm" );
Serial.print("\n");
return val;
}
/*************************** MQRead *******************************************
Input: mq_pin - analog channel
Output: Rs of the sensor
Remarks: This function use MQResistanceCalculation to caculate the sensor resistenc (Rs).
The Rs changes as the sensor is in the different consentration of the target
gas. The sample times and the time interval between samples could be configured
by changing the definition of the macros.
**********************************************************************************
/
float MQRead(int mq_pin)
{
int i;
float rs=0;
for (i=0;i<READ_SAMPLE_TIMES;i++) {
rs += MQResistanceCalculation(analogRead(mq_pin));
delay(READ_SAMPLE_INTERVAL);
}
rs = rs/READ_SAMPLE_TIMES;
return rs;
}
return 0;
}