Circuit Documentation
Summary of the Circuit
This circuit is designed to monitor the health of a plant by measuring soil moisture, ambient light, and temperature. It uses an Arduino UNO as the central microcontroller to read data from a soil moisture sensor, a photocell (LDR), and a temperature sensor (LM35). The Arduino processes these readings and outputs the health status of the plant through the serial monitor. The circuit is powered by the Arduino's 5V output, and the sensors are connected to the analog input pins for data acquisition.
Component List
Temperature Sensor (LM35)
- Pins: +Vs, Vout, GND
- Description: A precision temperature sensor with an output voltage linearly proportional to the Centigrade temperature.
SparkFun Soil Moisture Sensor
- Pins: VCC, GND, SIG
- Description: A simple breakout for measuring the moisture in soil and similar materials.
Resistor
- Pins: pin1, pin2
- Description: A passive two-terminal electrical component that implements electrical resistance as a circuit element.
- Properties: Resistance: 1 Ohm
Arduino UNO
- 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
- Description: A microcontroller board based on the ATmega328P, with digital input/output pins, analog inputs, and various other features useful for building interactive objects.
Photocell (LDR)
- Pins: pin 0, pin 1
- Description: A light-dependent resistor whose resistance decreases as the intensity of light it is exposed to increases.
Wiring Details
Temperature Sensor (LM35)
- +Vs: Connected to the 5V output of the Arduino UNO.
- Vout: Connected to the analog input pin A0 of the Arduino UNO.
- GND: Connected to the ground (GND) pin of the Arduino UNO.
SparkFun Soil Moisture Sensor
- VCC: Connected to the 5V output of the Arduino UNO.
- GND: Connected to the ground (GND) pin of the Arduino UNO.
- SIG: Connected to the analog input pin A2 of the Arduino UNO.
Resistor
- pin1: Connected to the ground (GND) pin of the Arduino UNO.
- pin2: Connected to the pin 0 of the Photocell (LDR).
Arduino UNO
- 5V: Provides power to the Temperature Sensor, Soil Moisture Sensor, and Photocell (LDR).
- GND: Common ground for all components.
- A0: Receives the temperature reading from the LM35.
- A1: Receives the light level reading from the Photocell (LDR) through the resistor.
- A2: Receives the soil moisture level from the Soil Moisture Sensor.
Photocell (LDR)
- pin 0: Connected to the analog input pin A1 of the Arduino UNO through a 1 Ohm resistor.
- pin 1: Connected to the 5V output of the Arduino UNO.
Documented Code
// Plant Health Detection Code
int temp_pin = A0; // Temperature sensor pin
int light_pin = A1; // Light sensor pin
int soil_pin = A2; // Soil moisture sensor pin
void setup() {
pinMode(temp_pin, INPUT);
pinMode(light_pin, INPUT);
pinMode(soil_pin, INPUT);
Serial.begin(9600); // Start serial communication at 9600 baud rate
}
void loop() {
float moisture_percentage;
int soil_value;
soil_value = analogRead(soil_pin); // Read soil moisture value
moisture_percentage = (soil_value / 1023.00) * 100; // Convert to percentage
int light_value = analogRead(light_pin); // Read light level
int temp_value = analogRead(temp_pin); // Read temperature value
temp_value = (temp_value / 1023.00) * 100; // Convert to percentage
// Print temperature and moisture percentage to serial monitor
Serial.print("Temperature = ");
Serial.print(temp_value);
Serial.print("\n");
Serial.print("Moisture percent = ");
Serial.print(moisture_percentage);
Serial.print("\n");
// Check if plant is healthy based on sensor values
if (moisture_percentage < 70.00 || light_value < 512 || (temp_value < 23 || temp_value > 30)) {
Serial.print("Plant not healthy\n");
} else {
Serial.print("Plant healthy\n");
}
delay(1000); // Wait for 1 second before next reading
}
This code continuously reads the values from the temperature, light, and soil moisture sensors. It then calculates the moisture percentage and checks if the plant is healthy based on predefined conditions. If the plant is not healthy, it prints "Plant not healthy" to the serial monitor; otherwise, it prints "Plant healthy". The readings and status are updated every second.
