No products in the cart.
With the growing interest in smart gardening and plant care, having a reliable system to monitor environmental conditions can greatly enhance plant health and growth. This project aims to develop a Smart Plant Monitoring System using the ESP32-C3 Xiao, a DHT11 temperature and humidity sensor, a soil moisture sensor, and an SSD1306 OLED display. This system provides real-time monitoring of the environmental conditions crucial for plant health, such as temperature, humidity, and soil moisture levels.
Here’s an example of how to set up your ESP32-C3 Xiao to work with the DHT11 sensor, a soil moisture sensor, and an SSD1306 OLED display. The code will read environmental data from the sensors and display it on the OLED.
You’ll need the following libraries:
Adafruit_Sensor
DHT
Adafruit_SSD1306
Adafruit_GFX
Wire
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#include <DHT.h>
// Define sensor and display pins
#define DHTPIN 2
#define DHTTYPE DHT11
#define MOISTURE_SENSOR_PIN A0
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
// Initialize DHT sensor
DHT dht(DHTPIN, DHTTYPE);
// Initialize OLED display
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
// Start serial communication
Serial.begin(115200);
// Initialize the DHT sensor
dht.begin();
// Initialize the OLED display
if (!display.begin(SSD1306_I2C_ADDRESS, OLED_RESET)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;);
}
display.display();
delay(2000);
display.clearDisplay();
// Initialize moisture sensor pin
pinMode(MOISTURE_SENSOR_PIN, INPUT);
}
void loop() {
// Read temperature and humidity from DHT11 sensor
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
// Read soil moisture level
int moistureLevel = analogRead(MOISTURE_SENSOR_PIN);
moistureLevel = map(moistureLevel, 1023, 0, 0, 100); // Convert to percentage
// Check if any reads failed and exit early (to try again).
if (isnan(temperature) || isnan(humidity)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
// Display data on the OLED screen
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.print("Temp: ");
display.print(temperature);
display.println(" *C");
display.print("Humidity: ");
display.print(humidity);
display.println(" %");
display.print("Soil Moisture: ");
display.print(moistureLevel);
display.println(" %");
display.display();
// Print data to Serial Monitor
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" *C");
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println(" %");
Serial.print("Soil Moisture: ");
Serial.print(moistureLevel);
Serial.println(" %");
// Wait for a second before the next loop
delay(1000);
}
You can customize the thresholds for alerts or add additional functionality such as Wi-Fi connectivity for remote monitoring. For instance, integrating with a web server or a mobile app for remote access can enhance the system’s capabilities.
The Smart Plant Monitoring System offers a versatile and reliable solution for plant care, providing real-time monitoring of essential environmental parameters. By integrating sensors, real-time data display, and connectivity features, it enhances the ability to maintain optimal conditions for plant growth. Whether for home gardening enthusiasts or professional horticulturists, this project showcases the capabilities of modern IoT technology in improving plant health and growth.
No matter how big your company is, as you expand and reach new highs you’ll want an agency to have your back. One with a process
© 2023 AI FUTURE All rights Reserved