Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO-Based Environmental Monitoring System with I2C LCD, Soil Moisture Sensing, and Data Logging

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Environmental Monitoring System with I2C LCD, Soil Moisture Sensing, and Data Logging

Circuit Documentation

Summary

This circuit is designed around an Arduino UNO microcontroller and includes various sensors and input/output devices to create an interactive system. The system is capable of reading environmental data such as soil moisture, humidity, and temperature, as well as controlling a speaker and displaying information on an I2C LCD screen. User input is captured through pushbuttons, allowing navigation through a menu system implemented in the Arduino's code. The circuit is powered by a pair of 18650 Li-ion batteries, and it also includes a solar panel for additional power input or monitoring.

Component List

Arduino UNO

Pushbutton (x3)

I2C LCD 16x2 Screen

Speaker

Capacitive Soil Moisture Sensor V1.2

18650 Li-ion Battery x 2

Solar Panel

DHT11 Humidity and Temperature Sensor

Micro SD Card Module

Wiring Details

Arduino UNO

Pushbuttons (x3)

I2C LCD 16x2 Screen

Speaker

Capacitive Soil Moisture Sensor V1.2

18650 Li-ion Battery x 2

Solar Panel

DHT11 Humidity and Temperature Sensor

Micro SD Card Module

Documented Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>

// Pin configuration
#define DHTPIN 2            // Pin for DHT11 sensor
#define DHTTYPE DHT11       // DHT 11 sensor type
#define SPEAKER_PIN 3       // Pin for speaker
#define MOISTURE_PIN A0     // Analog pin for moisture sensor
#define SUNLIGHT_PIN A1     // Analog pin for solar panel to measure sunlight

#define BUTTON_SELECT 4     // Button to select and navigate
#define BUTTON_ENTER 5      // Button to enter the selected option
#define BUTTON_EXIT 6       // Button to exit the submenus

// Initialize LCD with I2C address 0x27 (common address, check yours)
LiquidCrystal_I2C lcd(0x27, 16, 2);
DHT dht(DHTPIN, DHTTYPE);

// Variables for navigation
int currentOption = 0;      // Keeps track of the main menu option (A, B, C)
int subOption = 0;          // Keeps track of the sub-menu options
bool inSubmenu = false;     // Track if the system is in a submenu

void setup() {
  lcd.begin(16,2);               // Initialize the LCD
  pinMode(BUTTON_SELECT, INPUT_PULLUP);
  pinMode(BUTTON_ENTER, INPUT_PULLUP);
  pinMode(BUTTON_EXIT, INPUT_PULLUP);
  pinMode(SPEAKER_PIN, OUTPUT);
  dht.begin();

  // Show welcome message
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("HELLO, TERA IQ");
  delay(4000); // Show message for 4 seconds

  // Show main menu options
  displayMenu();
}

void loop() {
  // Navigate through the options
  if (!digitalRead(BUTTON_SELECT)) {
    navigateMenu();
    delay(300); // Debounce delay
  }

  // Enter selected option
  if (!digitalRead(BUTTON_ENTER)) {
    enterOption();
    delay(300); // Debounce delay
  }

  // Exit to main menu if in a submenu
  if (!digitalRead(BUTTON_EXIT) && inSubmenu) {
    exitSubmenu();
    delay(300); // Debounce delay
  }
}

// Function to navigate the main menu (A, B, C)
void navigateMenu() {
  if (!inSubmenu) {
    currentOption = (currentOption + 1) % 3; // Cycle through A -> B -> C -> A
    displayMenu();
  }
}

// Display the main menu on the LCD
void displayMenu() {
  lcd.clear();
  lcd.setCursor(0, 0);
  if (currentOption == 0) {
    lcd.print("> A: Problem Mode");
  } else {
    lcd.print("  A: Problem Mode");
  }

  lcd.setCursor(0, 1);
  if (currentOption == 1) {
    lcd.print("> B: Soil Scan Mode");
  } else {
    lcd.print("  B: Soil Scan Mode");
  }

  lcd.setCursor(0, 2);
  if (currentOption == 2) {
    lcd.print("> C: Humidity, Light");
    lcd.setCursor(0, 3);
    lcd.print("   And Moisture Level");
  } else {
    lcd.print("  C: Humidity, Light");
    lcd.setCursor(0, 3);
    lcd.print("   And Moisture Level");
  }
}

// Function to handle entering an option
void enterOption() {
  if (!inSubmenu) {
    inSubmenu = true; // Now in the submenu

    switch (currentOption) {
      case 0:
        displayProblemMode();
        break;
      case 1:
        displaySoilScanMode();
        break;
      case 2:
        displayEnvironmentalData();
        break;
    }
  }
}

// Display the submenu for "A: Problem Mode"
void displayProblemMode() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("> A: Soil Not Fertile");
  lcd.setCursor(0, 1);
  lcd.print("  B: Insect Plants");

  subOption = 0; // Default to the first sub-option
}

// Function to navigate and select sub-options
void navigateProblemMode() {
  subOption = (subOption + 1) % 2;
  lcd.clear();
  if (subOption == 0) {
    lcd.setCursor(0, 0);
    lcd