water softener circuit detail and water monitoring system using Wireless Sensor Network (zigbee configuration) Arduino software coding and real time matlab plotting of arduino data.
Popular-NO1 Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialis...
final report_51_33_17
1. 0 | P a g e
Water Quality Monitoring and conditioning Using Wireless sensor
Network
MAJOR-PROJECT REPORT
By
Shah Darshil Hareshbhai (12BECR051)
Patel Jainam Sureshbhai (12BECR033)
Jain Darshan Ranjitbhai (12BECR017)
Project Guide:
Prof. Ankur Changela
Department of Electronics and Communication Engineering
Indus Institute of Technology and Engineering
Ahmedabad
MAY 2016
2. II | P a g e
BONAFIDE CERTIFICATE
This is to certify that this project report entitled “Water Quality Monitoring
and conditioning using wireless sensor network” submitted to Department
of Electronics and Communication Engineering, IITE, Ahmedabad, is a
bonafide record of work done by “Shah Darshil Hareshbhai” under my
supervision from “4th
January 2016” to “13th
May 2016”.
Prof. Ankur Changela
Faculty, EC Department
Prof R.N. Mutagi
Head of Department
Electronics and Communication
Place
Date
3. III | P a g e
BONAFIDE CERTIFICATE
This is to certify that this project report entitled “Water Quality Monitoring
and conditioning using wireless sensor network” submitted to Department
of Electronics and Communication Engineering, IITE, Ahmedabad, is a
bonafide record of work done by “Patel Jainam Sureshbhai” under my
supervision from “4th
January 2016” to “13th
May 2016”.
Prof. Ankur Changela
Faculty, EC Department
Prof R.N. Mutagi
Head of Department
Electronics and Communication
Place
Date
4. IV | P a g e
BONAFIDE CERTIFICATE
This is to certify that this project report entitled “Water Quality Monitoring
and conditioning using wireless sensor network” submitted to Department
of Electronics and Communication Engineering, IITE, Ahmedabad, is a
bonafide record of work done by “Jain Darshan Ranjitbhai” under my
supervision from “4th
January 2016” to “13th
May 2016”.
Prof. Ankur Changela
Faculty, EC Department
Prof R.N. Mutagi
Head of Department
Electronics and Communication
Place
Date
5. V | P a g e
Declaration by Author
This is to declare that this report has been written by me. No part of the report is
plagiarized from other sources. All information included from other sources has
been duly acknowledged. I aver that if any part of the report is found to be
plagiarized, I shall take full responsibility for it.
Shah Darshil Hareshbhai (12BECR051)
Patel Jainam Sureshbhai (12BECR033)
Jain Darshan Ranjitbhai (12BECR017)
Place
Date
6. VI | P a g e
ACKNOWLEDGMENT
I gratefully acknowledge my mentor Prof. Ankur Changela, Faculty EC
department, Indus University for his suggestions and guidance during the entire
duration of the project. I am thankful to him for helping me to understanding
and develop problem solving ability.
I express sincere gratitude to Prof. R. N. Mutagi, Head of Department,
Electronics and Communication Department, Indus University for strengthening
my fundamental knowledge. I am thankful to him for his views, suggestions and
reviewing.
Finally, I express deep appreciation to my parents and friends for their
unconditional support, patience and encouragement.
7. VII | P a g e
ABSTRACT
Underwater wireless sensor network is the simple and basic way to monitor the
quality of water using wireless sensor network (WSN) technology. To monitor
the quality of water over different sites as a real time application, A WSN
technology like Zigbee is used to connect the nodes and base station. The
collected data of PH sensor is sent to base station and at the base station
collected data is displayed on 16x2 LCD. If displayed PH>7 then the water said
to be hard hence to soft the water we design water softener circuit which is
working until water PH should not be equal to 7.
8. VIII | P a g e
Contents
ACKNOWLEDGMENT.....................................................................................VI
ABSTRACT...................................................................................................... VII
List of figures:......................................................................................................X
List of Table.........................................................................................................X
CHAPTER 1: INTRODUCTION.........................................................................1
1.1 Definition of Project: ..............................................................................................................1
1.2 PH sensor Circuit:...................................................................................................................2
1.3 Water Softener Circuit:...........................................................................................................3
CHAPTER 2 APPROACH USED........................................................................4
2.1 ZIGBEE Configuration:..........................................................................................................4
2.1.1 ADD or Find Radio module devices as shown in fig......................................................4
2.1.2 Configure Radio Devices with certain parameter like Baud Rate, Data Rate, Parity, ....4
And Stop Bit. ..................................................................................................................................4
2.1.3 To configure Point to Point topology we have to add two Radio module devices. ........5
2.1.4 To done Point to Point communication we have to select one as a Router and one as a
coordinator and select on update to select Radio Module Firmware. .............................................5
2.1.5 If we have to add two devices in same cloud (network) we have to equal PAN Ids. ....6
2.1.6 To done Point to Point communication we have do following process:.........................6
2.1.7 Point to Point communication between Router and coordinator.....................................7
2.2 Arduino interfacing with MATLAB:......................................................................................7
2.3 Arduino interfacing with Terminal Software:.........................................................................8
2.4 Arduino UNO with Zigbee configuration Mode:..................................................................10
2.5 LCD interfacing with Arduino Uno:.....................................................................................11
2.6 Detail of Arduino Uno: .........................................................................................................11
CHAPTER 3: RESULT AND DISCUSSION....................................................12
3.1 Software Implementation......................................................................................................12
3.2 Software Implementation:.....................................................................................................13
3.2.1 WQMC TX: ..................................................................................................................13
3.2.2 WQMC RX:..................................................................................................................13
3.3 Output Response of sample water.........................................................................................14
3.3.1 Bar Chart displaying LCD binary values of water sample............................................14
3.4 Titration Method:..................................................................................................................15
9. IX | P a g e
3.5 Water softener circuit design: ...............................................................................................16
3.6 Softener circuit Implementation in Proteus: .........................................................................17
3.7 Calculate required flux to soft the water...............................................................................17
3.8 Arduino interfacing with MATLAB:....................................................................................18
CHAPTER 4: CONCLUSION AND RECOOMENDATION...........................19
4.1 Scope.....................................................................................................................................19
4.2 Applications..........................................................................................................................19
4.3 Conclusions...........................................................................................................................19
APPENDICES ....................................................................................................20
Appendix I: Arduino Uno.................................................................................................................20
Appendix II: Zigbee..........................................................................................................................21
Appendix III: MATLAB Code: ........................................................................................................22
Appendix IV: Arduino code:.............................................................................................................24
Arduino TX code: .........................................................................................................................24
Arduino Rx Code:.........................................................................................................................26
LIST OF REFERENCES....................................................................................28
10. X | P a g e
List of figures:
Sr. No. Name Pg. No.
1.2 PH sensor Circuit 2
1.3 Water softener circuit 3
2.1.1 Radio Module 4
2.1.2 Configure Radio Module 4
2.1.3 P to P Topology 5
2.1.4 Select Firmware 5
2.1.5 Same PAN IDs 6
2.1.6 Addressing Zigbee 6
2.1.7 Communication process 7
2.2 MATLAB Plotting 7
2.3.1 COM Port selection 8
2.3.2 Select CSV file In Terminal 8
2.3.3 Select CSV File 8
2.3.4 Plotting Data 9
2.4.1 Zigbee interface with Arduino 10
2.4.1 Zigbee Pin out 10
2.5 LCD interface with Arduino 11
2.6 AT mega 328 Pin out 11
3.2.1 WQMC TX 13
3.2.2 WQMC RX 13
3.3.1 Water Sample Bar Chart 14
3.4 Titration Method 15
3.6 WSC in proteus 17
3.8 PH Result in matlab 18
List of Table
Sr. No. Name Pg. No.
3.3 Water Samples Readings 14
A-I AT mega 328p Specification 20
A-II Zigbee Specification 21
11. 1 | P a g e
CHAPTER 1: INTRODUCTION
1.1 Definition of Project:
To take preventive actions for quality maintenance we got an idea that a system should be
implemented to monitor the quality of water in easy way, so it can easily analyze some of the
critical and important factors of water. Various environmental parameters such as
temperature, pH, oxygen density, turbidity and so on from water can be collected by these
systems using different sensors.
Here only monitoring of the system is not sufficient so that we will design such an
application which is if water Ph should not be equal to 7 the conditioning of water will start
and did not stop until water Ph should not be equal to 7.
A water softener circuit is based on electromagnetic or electric field causes small calcium
carbonate crystals in water to join and form larger crystals
The Electronic water softener operates at a frequency of 15 kHz and amplitude of 12 volts
A 555 timer was used to produce a rectangular-wave signal which induced the field required
in the water supply passing through a tube using two open ended copper coils wound round it
The coils were insulated to prevent electrical contact with the tubes. An activity indicator was
designed to detect the presence of the 15 kHz oscillator signal.
12. 2 | P a g e
1.2 PH sensor Circuit:
Sensing circuit is designed using two electrodes and these electrodes would be dipped in the
solution of water samples. Inside the water solution these electrode form the cathode-anode
pair, certain amount of current will be generated
1K resistor connected to this sensor circuit which will oppose the flow of the current and thus
Potential Difference occurs between the two electrodes.
Electrodes
Water
Fig. 1.2 PH Sensor Circuit
V01K
+5v
0V
13. 3 | P a g e
1.3 Water Softener Circuit:
A water softener circuit is based on electromagnetic or electric field causes small calcium
carbonate crystals in water to join and form larger crystals
The Electronic water softener circuit operates at variable frequency 1 kHz and 50 kHz. The
operated frequency generated from Arduino Uno and passes through power amplifier circuit
which induced the field required in the water supply passing through a tube using two open
ended copper coils wound around it.
Fig. 1.3 Water Softener Circuit
PIPE
14. 4 | P a g e
CHAPTER 2 APPROACH USED
2.1 ZIGBEE Configuration:
2.1.1 ADD or Find Radio module devices as shown in fig.
Fig. 2.1.1 ADD Radio Module
2.1.2 Configure Radio Devices with certain parameter like Baud Rate, Data Rate, Parity,
And Stop Bit.
Fig. 2.1.2 configure Radio module
15. 5 | P a g e
2.1.3 To configure Point to Point topology we have to add two Radio module devices.
Fig. 2.1.3 P to P Topology
2.1.4 To done Point to Point communication we have to select one as a Router and one as a
coordinator and select on update to select Radio Module Firmware.
Fig. 2.1.4 Select Firmware
16. 6 | P a g e
2.1.5 If we have to add two devices in same cloud (network) we have to equal PAN Ids.
Fig. 2.1.5 Same PAN IDs
2.1.6 To done Point to Point communication we have do following process:
DHrouter = SHcoordinator DLrouter = SLcoordinator
DLcoordinator = SLrouter DHcoordinator = SHcoordinator
Fig. 2.1.6 Addressing in zigbee
17. 7 | P a g e
2.1.7 Point to Point communication between Router and coordinator.
Fig. 2.1.7 communication process
2.2 Arduino interfacing with MATLAB:
Real time data plot from a serial port and this MATLAB script is for plotting a graph
by accessing serial port data in real time.
Fig. 2.2 MATLAB Plotting
18. 8 | P a g e
2.3 Arduino interfacing with Terminal Software:
1. Select The COM Port
Fig. 2.3.1 Com port selection
2. Select the CSV (comma delimited) file
Fig.2.3.2 Select CSV File In terminal
3. Excel CSV File
Fig.2.3.3 Select CSV File
19. 9 | P a g e
4. Excel Plotting And data Collection From serial port
Fig. 2.3.4 Plotting Data
20. 10 | P a g e
2.4 Arduino UNO with Zigbee configuration Mode:
As shown in Fig.
Data out (2) Zigbee is connected to Rx (0) Arduino Uno
Data IN (3) Zigbee is connected to Tx (1) Arduino Uno
Fig. 2.4.1 Zigbee interface with Arduino
Zigbee Pin out
Fig. 2.4.2 Zigbee Pin out
21. 11 | P a g e
2.5 LCD interfacing with Arduino Uno:
Fig. 2.5 LCD interface With Arduino
2.6 Detail of Arduino Uno:
The Uno is a microcontroller board based on the ATmega328P. It has 14 digital input/output
pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a
USB connection, a power jack, an ICSP header and a reset button. It contains everything
needed to support the microcontroller; simply connect it to a computer with a USB cable or
power it with an AC-to-DC adapter or battery to get started.
Fig. 2.6 AT mega 328 PINOUT
22. 12 | P a g e
CHAPTER 3: RESULT AND DISCUSSION
3.1Software Implementation
Start
Initialize PH=0
Read analogue
Signal Using the
Arduino
(Inbuilt ADC)
YES If PH >=7 NO
Arduino module (2)
Display it on the LCD
END
Transmit data via wireless
network Using Zigbee
Start Water
softener circuit
23. 13 | P a g e
3.2Software Implementation:
3.2.1 WQMC TX:
Fig. 3.2.1 WQMC TX
3.2.2 WQMC RX:
Fig. 3.2.2 WQMC RX
24. 14 | P a g e
3.3Output Response of sample water
Table 3.3 Water samples Reading
3.3.1 Bar Chart displaying LCD binary values of water sample
FIG 3.3.1 Water samples Bar chart
Sr. No. Water sample Binary Reading
1 Acidic Water 101
2 Hard Water 652
3 Regular Water 895
0
100
200
300
400
500
600
700
800
900
1000
Acidic water Hard water Regular water
Series 1
Column1
Column2
25. 15 | P a g e
3.4Titration Method:
Take 10ml sample water (Soft Water) then added into 1ml Buffer solution and 3 drops of
EBT (Eriochrome Black T).
Add EDTA (Ethylenediaminetetraacetic acid) continuously while sample water colour is not
come to transparent Blue. And at that time we note the readings of glass tube.
Fig.3.4 Titration Method
26. 16 | P a g e
3.5Water softener circuit design:
Maximum input and output voltages = 15 volts
Maximum input current = 200 mA
The frequency of oscillators of NE555 IC was determined using the RC network.
Tc = charging time = 0.693 (R1 + R2) C
Td = Discharging time = 0.693 R2 C
Period (T) = Tc + Td
Frequency (f) = I/T
For frequency (f) = 15 x 103 Hz
Period (T) = 1/f = 1/15 x 103 = 66.666 x 10-6 s
Using;
R1 = 10k
R2 = 10R1 = 100k for about 1:10 mark to space ratio.
Using equation (4), for T = 66.67x10-6 s
C = 4.58 x 10-10 F
= 0.458 x 10-9 F
= 0.45 n F
Two capacitors C1 = C2 = 100nF were used. One at the input to control the unwanted radio
frequency signals and the other at pin 5 to block the R.F signals. This capacitor offers a reactance of
106 ohm approximately to block the R-F signals.
Resistor R3 is current controlled Resistor.
TIP 122 Darlington Transistor is used to amplify the current to generate strong flux.
Maximum output current: 424mA
IE2 = ß2 x ß1 x IB1
IE2= 1000*424 uA
IE2=424 mA
27. 17 | P a g e
3.6Softener circuit Implementation in Proteus:
Fig. 3.6 WSC IN Proteus
3.7Calculate required flux to soft the water
By Using faraday’s LAW we can calculate the change in flux.
V= N × d/dt
Where V=di/dt
Hence change in current is proportional to change in flux
Here Maximum output current is 424mA
Number of turns of inductor wire at positive output = 77
Number of turns of inductor wire at ground output = 75
Hence Total turns would be = 155
Hence calculated maximum flux would be
=424mA/155 = 2.73x10-3
V.m
28. 18 | P a g e
3.8Arduino interfacing with MATLAB:
1. Variable Declaration
2. Set Serial Port
3. Set Figure
4. Set axis
5. Create x-label, y-label, and title
6. Initialize the variable
7. Re-creating Serial Port before timeout
8. Serial data accessing
9. For reducing Error Use your own constant
10. Clean up the serial port
Fig.3.8 PH Result in MATLAB
29. 19 | P a g e
CHAPTER 4: CONCLUSION AND RECOOMENDATION
4.1 Scope
A system was with more sensor nodes and more base stations. Nodes and base stations are
connected as WSN, the different base stations are connected via Ethernet. The Ethernet can
also be connected to internet so the user can just login to the system and get a real time water
quality data faraway.
Water softening technique depends on the input from the ph sensor.
4.2 Applications
Chemical leakage detection in rivers: This is very important as due to chemical spills in
rivers, the aquatic animals and creatures living in the rivers get affected and die in large
numbers. So early detection of the leakage will not only save cost of cleaning the river beds,
but also save a lot of aquatic life.
Maintain the swimming pool water quality: By testing the pH level and Chloride levels of
pool water, the quality of water in swimming pools is maintained.
Maintenance of Fish Tank water: The bacteria, pathogen detection in water are possible to
maintain the quality of tank water.
4.3 Conclusions
Sequential follow up of water pollution status in remote region can be achieved by
monitoring the quality of water & collecting comprehensive data.
The system not only provides comprehensive evaluation of water environment but also can
quickly discover urgent water pollution accident or natural disasters, transferring the
abnormal water quality information to monitoring centres by quicker communication network
and provides graphical references for the decision making department to comprehend the
status of the disaster to establish the prevention and cure policy.
The designed system is used to test the water for various dose responses for more type of
infection in a sample, at the various temperatures. This water quality sensor model is very
beneficial for the society in various
application of water.
This research work is used to design the system to study the water sample. The sample food
material is checked under the different atmospheric condition. The impurity is added in
the testing material is analyze at the different interval of time of a day by the monitoring pH
value and by measuring the hardness of water.
30. 20 | P a g e
APPENDICES
Appendix I: Arduino Uno
Table I AT mega 328p Specification
Microcontroller ATmega328P
Operating Voltage 5V
Input Voltage
(recommended)
7-12V
Input Voltage (limit) 6-20V
Digital I/O Pins
14 (of which 6 provide PWM
output)
PWM Digital I/O Pins 6
Analog Input Pins 6
DC Current per I/O Pin 20 mA
DC Current for 3.3V Pin 50 mA
Flash Memory
32 KB (ATmega328P)
of which 0.5 KB used by boot
loader
SRAM 2 KB (ATmega328P)
EEPROM 1 KB (ATmega328P)
Clock Speed 16 MHz
Length 68.6 mm
Width 53.4 mm
Weight 25 g
31. 21 | P a g e
Appendix II: Zigbee
Table II Zigbee Specification
32. 22 | P a g e
Appendix III: MATLAB Code:
4 clear all;
5
6 %%Variables (Edit yourself)
7
8 SerialPort='com10'; %serial port
9 MaxDeviation = 14;%Maximum Allowable Change from one value to next
10 TimeInterval=0.2;%time interval between each input.
11 loop=500;%count values
12
13 %%Set up the serial port object
14
15 s = serial(SerialPort)
16 fopen(s);
17 PH =now;
18 Time = 0;
19
20 %% Set up the figure
21
22 figureHandle = figure('NumberTitle','off',...
23 'Name','PH Characteristics',...
24 'Color',[0 0 0],'Visible','off');
25
26 % Set axes
27
28 axesHandle = axes('Parent',figureHandle,...
29 'YGrid','on',...
30 'YColor',[0.9725 0.9725 0.9725],...
31 'XGrid','on',...
32 'XColor',[0.9725 0.9725 0.9725],...
33 'Color',[0 0 0]);
34
35 hold on;
36 plotHandle = plot(axesHandle,PH,Time,'Marker','.','LineWidth',1,'Color',[0 1 0]);
37 xlim(axesHandle,[min(PH) max(PH+0.001)]);
38
39 % Create xlabel
40
41 xlabel('Time','FontWeight','bold','FontSize',14,'Color',[1 1 0]);
42
43 % Create ylabel
44
45 ylabel('PH','FontWeight','bold','FontSize',14,'Color',[1 1 0]);
46
47 % Create title
48
49 title('Real Time Data','FontSize',15,'Color',[1 1 0]);
50
51 %% Initializing variables
52
53 Time(1)=0;
54 PH(1)=0;
55 count = 2;
56 k=1;
57 while ~isequal(count,loop)
58
59 %%Re creating Serial port before timeout
60
61 k=k+1;
62 if k==25
33. 23 | P a g e
63 fclose(s);
64 delete(s);
65 clear s;
66 s = serial('com10');
67 fopen(s)
68 k=0;
69 end
70
71 %%Serial data accessing
72
73 Time(count) = fscanf(s,'%d'); %#ok<*SAGROW>
74
75 %%For reducing Error Use your own costant
76
77 Time(1)=0;
78 if (Time(count)-Time(count-1)>MaxDeviation)
79 Time(count)=Time(count-1);
80 end
81 PH(count) = count;
82 set(plotHandle,'YData',Time,'XData',PH);
83 set(figureHandle,'Visible','on');
84 datetick('x','mm/DD HH:MM');
85
86 pause(TimeInterval);
87 count = count +1;
88 end
89
90 %% Clean up the serial port
91 fclose(s);
92 delete(s);
93 clear s;
34. 24 | P a g e
Appendix IV: Arduino code:
Arduino TX code:
///////////////// VRS ///////////////////////////
int reading;
int val;
/////////////////////////////////////////////////
//##################### main setup ##############
void setup()
{
pinMode(A0,INPUT); // A0 as input
Serial.begin(9600); // zigbee init.
pinMode(3,OUTPUT); // SOFT RELAY
pinMode(4,OUTPUT); // HARD RELAY
digitalWrite(3,LOW);
digitalWrite(4,LOW);
}
///////////////////////////////////////////////////
//############### main loop ######################
void loop()
{
val = analogRead(A0); // a0 read
35. 25 | P a g e
reading = map(val,0,1023,0,14); // mapping
if(reading>7)
digitalWrite(4,HIGH);
else if(reading<7)
digitalWrite(3,HIGH);
else
{digitalWrite(3,LOW);digitalWrite(4,LOW);}
//Serial.write('a');
//Serial.write(',');
Serial.println(reading); // transmit over zigbee.
delay(1000);// sample at every 1 seconds.
}
///////////////////////////////////////////////////////
//############ extra functions and ISRS ///////////////
37. 27 | P a g e
/////////////////////////////////////////////////////////////
//######################## main loop #######################
void loop()
{
if(Serial.available()>0)
{
// if(Serial.read()=='a')
// {
data = Serial.parseInt(); // receive data in int. form.
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(data); // print on lcd
// }
}
}
//////////////////////////////////////////////////////////////
//############# extra functions and ISRS //////////////////////
38. 28 | P a g e
LIST OF REFERENCES
1. http://ijsetr.org/wp-content/uploads/2014/03/IJSETR-VOL-3-ISSUE-3-385-389.pdf
2. http://www.researchinventy.com/papers/v1i3/I013039042.pdf
3. http://www.isca.in/IJES/Archive/v3/i11/2.ISCA-RJEngS-2014-70.pdf
4. http://tathastuservices.com/english/tws/scince-behind-this.html
5. http://www.vivabluwater.com/products/explanation.pdf
6. http://www.informit.com/articles/article.aspx?p=1409785&seqNum=4
7. http://www.mouser.com/pdfdocs/Gravitech_ATMEGA328_datasheet.pdf
8. https://www.sparkfun.com/datasheets/Wireless/Zigbee/XBee-Datasheet.pdf