Water quality testing
INTRODUCTION & WORKING:
This system can also be useful for people having small gardens, while it may not be possible for a
Four pins used of wifi module. Serial pins connected with esp8266. Tx pin of arduino connected with rx pin of esp8266. Rx pin of arduino connected with Tx pin.
Two pins of esp8266 connected with 3.3 v aand gnd pin.
Moisture sensor connectd with arduino pin A0
person to be continuously present at his/her garden but one can use this project to keep a track of ‘soil-moisture’ and ensure proper water supply even from a distance.
Power (USB / Barrel Jack)
Every Arduino board needs a way to be connected to a power source. The Arduino UNO can be powered from a USB cable coming from your computer or a wall power supply (like this) that is terminated in a barrel jack. In the picture above the USB connection is labeled (1) and the barrel jack is labeled (2).
The USB connection is also how you will load code onto your Arduino board. More on how to program with Arduino can be found in our Installing and Programming Arduino tutorial.
Pins (5V, 3.3V, GND, Analog, Digital, PWM, AREF)
The pins on your Arduino are the places where you connect wires to construct a circuit (probably in conjuction with a breadboard and some wire. They usually have black plastic ‘headers’ that allow you to just plug a wire right into the board. The Arduino has several different kinds of pins, each of which is labeled on the board and used for different functions.
GND (3): Short for ‘Ground’. There are several GND pins on the Arduino, any of which can be used to ground your circuit.
5V (4) & 3.3V (5): As you might guess, the 5V pin supplies 5 volts of power, and the 3.3V pin supplies 3.3 volts of power. Most of the simple components used with the Arduino run happily off of 5 or 3.3 volts.
Analog (6): The area of pins under the ‘Analog In’ label (A0 through A5 on the UNO) are Analog In pins. These pins can read the signal from an analog sensor (like a temperature sensor) and convert it into a digital value that we can read.
Digital (7): Across from the analog pins are the digital pins (0 through 13 on the UNO). These pins can be used for both digital input (like telling if a button is pushed) and digital output (like powering an LED).
PWM (8): You may have noticed the tilde (~) next to some of the digital pins (3, 5, 6, 9, 10, and 11 on the UNO). These pins act as normal digital pins, but can also be used for something called Pulse-Width Modulation (PWM). We have a tutorial on PWM, but for now, think of these pins as being able to simulate analog output (like fading an LED in and out).
AREF (9): Stands for Analog Reference. Most of the time you can leave this pin alone. It is sometimes used to set an external reference voltage (between 0 and 5 Volts) as the upper limit for the analog input pins.
code
//Libraires
#include <stdlib.h>
#include <LiquidCrystal.h>
/*———————————————————-*/
int sensorPin = A0;
int sensorPin1 = A1;
int sensorPin2 = A2;
int sensorPin3 = A3;
/*—————–ESP8266 Serial WiFi Module—————*/
#define SSID “garry” // “SSID-WiFiname”
#define PASS “garry123” // “password”
#define IP “184.106.153.149”// thingspeak.com ip
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
String msg = “GET /update?key=7H4P4WY9PJNM644V”; //change it with your key…
/*———————————————————–*/
//Variables
float temp;
float temp1;
float temp2;
float temp3;
int hum;
String tempC;
int error;
void setup()
{
Serial.begin(115200);
lcd.begin(16, 2);
Serial.println(“AT”);
delay(5000);
if(Serial.find(“OK”)){
connectWiFi();
}
}
void loop(){
temp1 = analogRead(sensorPin1);
temp2 = analogRead(sensorPin2);
temp3 = analogRead(sensorPin3);
temp = analogRead(sensorPin);
temp = temp/10;
temp= temp-90;
temp= 17-temp;
char buffer[10];
tempC = dtostrf(temp, 4, 1, buffer);
updateTemp();
//Resend if transmission is not completed
if (error==1){
goto start; //go to label “start”
}
delay(360); //Update every 1 hour
}
void updateTemp(){
String cmd = “AT+CIPSTART=\”TCP\”,\””;
if(Serial.find(“Error”)){
return;
}
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(“Temperature “);
lcd.print(temp);
// lcd.clear();
lcd.setCursor(0, 0);
lcd.print(temp1);
lcd.setCursor(8, 0);
lcd.print(temp2);
cmd = msg ;
cmd += “&field1=”; //field 1 for temperature
cmd += temp;
cmd += “&field2=”; //field 2 for humidity
cmd += String(temp1);
cmd += “&field3=”; //field 2 for humidity
cmd += String(temp2);
cmd += “&field4=”; //field 2 for humidity
cmd += String(temp3-60);
cmd += “\r\n”;
Serial.print(“AT+CIPSEND=”);
else{
Serial.println(“AT+CIPCLOSE”);
//Resend…
error=1;
}
}
boolean connectWiFi(){
Serial.println(“AT+CWMODE=1”);
delay(2000);
String cmd=”AT+CWJAP=\””;
cmd+=SSID;
cmd+=”\”,\””;
cmd+=PASS;
if(Serial.find(“OK”)){
return true;
}else{
return false;
}
}