Interfacing of Soil-Moisture Sensor with Arduino, Blynk, Bluetooth
Components Required:
Hardware Required:
- Arduino UNO and Cell-Phone
- OTG Cable
- Arduino Cable
- Soil-Moisture Sensor
- Sample Soil
- Bluetooth HC-05 Module
- Jumper Wires
Software Required:
- Arduino-Droid App in Cell-Phone
- Blynk App in Cell-Phone
Circuit Diagram:
Connections:
Connection Arduino and Bluetooth module
Arduino | Bluetooth Module |
---|---|
Digital Pin 10 | Tx |
Digital Pin 11 | Rx |
5V/3.3V | VCC |
Ground(GND) | GND |
Connection Arduino and Soil Moisture Sensor
Arduino | Soil Moisture Sensor |
---|---|
Analog Pin A0 | A0 |
5V/3.3V | VCC |
Ground(GND) | GND |
Steps to Follow:
- Make the Circuit-Connections as shown above.
- Open Arduino Droid App.
- Paste the Code written in the Code-Section.
- First Compile(try to remove comments if you get error) and then Upload the code to Arduino.
- Now open Blynk App.
Image Credit: Blynk Documentation
- Open Widget Box in Blynk App by touching (+) icon in the Upper-Right Corner.
- Choose Value Display by clicking on it and now set the Virtual Pin 1.
- Now similarly choose Bluetooth Button. (To know how to set it please refer Annexure).
- Click play button and now you can read your Soil-Moisture Sensor Reading in the Blynk App.
Code:
#define BLYNK_PRINT Serial #include <SoftwareSerial.h> SoftwareSerial SwSerial(10, 11); // RX, TX const int sensor_pin = A0; /* Soil moisture sensor O/P pin */ float moisture_percentage; int sensor_analog; #include <BlynkSimpleSerialBLE.h> #include <SoftwareSerial.h> BlynkTimer timer; // Announcing the timer // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "0efba9ac0b3f48daa6473567a34f4e00"; (Your Auth. Code) SoftwareSerial SerialBLE(10, 11); // RX, TX void myTimerEvent() { Blynk.virtualWrite(V1,moisture_percentage); delay(100); } void setup() { // Debug console Serial.begin(9600); pinMode(sensor_pin, INPUT); SerialBLE.begin(9600); Blynk.begin(SerialBLE, auth); timer.setInterval(1000L, myTimerEvent); Serial.println("Waiting for connections..."); } void loop() { moisture_percentage = analogRead(sensor_pin); moisture_percentage = map(moisture_percentage,1023,150,0,100); delay(1000); Blynk.run(); timer.run(); // You can inject your own code or combine it with other sketches. // Check other examples on how to communicate with Blynk. Remember // to avoid delay() function! }
Similar Challenges:
1. Automatic Plant Watering System.
2. Rain Alert System