Arduino UNO and Bluetooth HC-06 Based Smart Soil Moisture Monitoring System
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit integrates an Arduino UNO microcontroller with a Bluetooth HC-06 module, a water sensor, a rain/snow sensor board, and a servo motor. The Arduino UNO reads data from the sensors and controls the servo motor. The Bluetooth module allows for wireless communication, enabling the transmission of sensor data to a remote device.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
Bluetooth HC-06
- Description: A Bluetooth module for wireless communication.
- Pins: VCC, GND, TXD, RXD
Water Sensor
- Description: A sensor to detect the presence of water.
- Pins: -, +
Rain/Snow Sensor - Board
- Description: A sensor board to detect rain or snow.
- Pins: 1, 2, A0 (Analog), D0 (Digital), GND, VCC (5V)
Servo
- Description: A servo motor for precise control of angular position.
- Pins: GND, VCC, PWM
Wiring Details
Arduino UNO
- 5V: Connected to VCC of Rain/Snow Sensor - Board, VCC of Servo, VCC of Bluetooth HC-06
- GND: Connected to GND of Rain/Snow Sensor - Board, GND of Servo, GND of Bluetooth HC-06
- D3: Connected to TXD of Bluetooth HC-06
- D2: Connected to RXD of Bluetooth HC-06
- A0: Connected to A0 (Analog) of Rain/Snow Sensor - Board
- D7: Connected to PWM of Servo
Bluetooth HC-06
- VCC: Connected to 5V of Arduino UNO
- GND: Connected to GND of Arduino UNO
- TXD: Connected to D3 of Arduino UNO
- RXD: Connected to D2 of Arduino UNO
Water Sensor
- -: Connected to pin 1 of Rain/Snow Sensor - Board
- +: Connected to pin 2 of Rain/Snow Sensor - Board
Rain/Snow Sensor - Board
- VCC (5V): Connected to 5V of Arduino UNO
- GND: Connected to GND of Arduino UNO
- A0 (Analog): Connected to A0 of Arduino UNO
- 1: Connected to - of Water Sensor
- 2: Connected to + of Water Sensor
Servo
- VCC: Connected to 5V of Arduino UNO
- GND: Connected to GND of Arduino UNO
- PWM: Connected to D7 of Arduino UNO
Code Documentation
Arduino UNO Code
#include <SoftwareSerial.h>
SoftwareSerial mySerial(3,2);
const int soilSensorPin = A0;
int moistureValue = 0;
Servo myServo;
const int servoPin = 7;
void setup() {
Serial.begin(9600); //open the serial port
mySerial.begin(9600); // open the bluetooth serial port
}
void loop() {
moistureValue = analogRead(soilSensorPin);
int percentage = map(moistureValue, 1023, 0, 0, 100);
Serial.print("Вологість дорівнює:");
Serial.print(percentage);
Serial.println("%");
mySerial.print("Вологість:");
mySerial.print(percentage);
mySerial.println("%");
if(mySerial.available()){
Serial.println(mySerial.readString()); // send from serial to bluetooth
}
if(Serial.available()){
mySerial.println(Serial.readString()); // send from bluetooth to serial
}
}
This code initializes a software serial connection on pins D3 and D2 for communication with the Bluetooth HC-06 module. It reads the moisture value from the rain/snow sensor connected to pin A0 and maps it to a percentage. The moisture percentage is then printed to both the serial monitor and the Bluetooth module. The code also handles data transmission between the serial monitor and the Bluetooth module.