What is IOT ?
Over the past few years Internet of thing has made a revelation in IT, Operations of the techniques are made of connecting objects to a network to transfer data without human to human or human-computer interaction, IoT is an interdisciplinary field, which requires working with electronics and sensors to capture data from physical objects, computer networking for data transfer and IT skills for building meaningful applications.
In this blog I will introduce how to connect soil moisture sensor to Arduino board and receive the data via a HC-006 Bluetooth module.
Required Items
- Arduino Board(UNO)
- Soil Moisture Sensor
- Bread Board
- Bluetooth Module(HC-006)
- Jumper Cables
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyBpBjQ7_YUmfdGWSziziT8wcUn0ose07xHWKhJEOnqTz-npLlAvjCkgDtHw2lcqz6PH10RZXbiAlz5N3O0nLOC9ohML3HCcL53s2Scp510L0xVW9-dymX8XYoTd6xHe8AcZ3podAVe3M/s200/64-02.jpg) |
Bread board |
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcXxhvrmRN6Z5Y0AbAOWIzbXVnqp_bAWCRQj7m1ygXxqagUl2dEKDFnKOJxY9ga6Jk0249o8EolyQINno3e7oi67EKr-zqt0WZCCFYYQ17LDSxTPkyOw7-P_DcOKB2hWyx0aSIGFUUp0o/s200/A000066-Arduino-Uno-TH-2tri.jpg) |
Arduino Board(UNO) |
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUaKSGeUZOnBaU0VgUqFAgmqGZHIuTaGRUv-J4fbYYa7wXfW-rUGrz_ltzQpoxzb2FWk8eC0yn2UJn5SckpFMLmM36Zm5Zs4dTKqJxNUuQzs6lGfnWmyPHZWHIm4ET7m2bRfSa8HEEwPw/s200/download.jpg) |
soil moisture sensor |
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiH252QWDcTaKt4AJzVkcpXRLSWDOHX8Wn_y3otmoNuPoQnyUODEusjUzx7WwsQ7mN05wfSxH8qDA_I6OrOmVDnEQb88BpiIlrhkr0YrNZ1BGYow3B8mnPitW5JD942MYq6b-DI7-ddSQM/s200/images.jpg) |
Bluetooth Module
Check out the video in the link for better understanding how these devices are assembled and connected https://www.youtube.com/watch?v=Pm83L104naY
Check out the code below how to receive the data via Bluetooth module
#include <SoftwareSerial.h>
SoftwareSerial BTserial(10, 11); // RX | TX
#define ledPin 7
char c = ' ';
int x;
boolean get1 = true;
const int buttonPin = 2;
const int led = 8;
String color;
String state;
boolean call;
boolean standS = true;
boolean standS1 = true;
void setup() {
Serial.begin(9600); // Default communication rate of the Bluetooth module
BTserial.begin(9600);
Serial.println("Arduino is Ready");
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
pinMode(buttonPin, INPUT);
pinMode(led, OUTPUT);
digitalWrite(led, HIGH);
}
void Bluetooth (){
while (BTserial.available())
{
delay(10);
c = BTserial.read();
color += c;
if(color=="on"){
call = true;
}
}
if (color.length() >0)
{
if(call){
while(get1){
digitalWrite(ledPin,HIGH);
delay(200);
digitalWrite(ledPin,LOW);
delay(200);
c = BTserial.read();
Serial.print(c);
// BTserial.flush();
if(c == 'f'){
// BTserial.flush();
break;
}
c=' ';
}
// }else if(color == "off"){
// get = false;
// digitalWrite(ledPin, LOW);
// delay(20);
// }
}
color ="";
}
}
void loop() {
Bluetooth();
stand();
}
void stand(){
int butt = digitalRead(buttonPin);
int LED = digitalRead(led);
if(butt == HIGH){
digitalWrite(led,LOW);
standS1 = true;
if(standS){
Serial.print("yes");
BTserial.print("yes");
delay(100);
}
standS=false;
}else{
digitalWrite(led,HIGH);
standS=true;
if(standS1){
Serial.print("no");
BTserial.print("no");
delay(100);
}
standS1=false;
}
// if(digitalRead(buttonPin)==HIGH && standS == true){
//
// digitalWrite(led,LOW);
//
// state = "yes";
// BTserial.print(state);
// delay(1000);
//
// BTserial.flush();
//
//
// }else{
// standS = false;
// digitalWrite(led,HIGH);
//
//
// delay(1000);
//
//
// BTserial.flush();
//
// }
}
|
Comments
Post a Comment