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

Arduino-Based Smart Soil Moisture and Air Quality Monitoring System with LED Indicators and Motor Control

View and Edit Project In Cirkit DesignerImage of Arduino-Based Smart Soil Moisture and Air Quality Monitoring System with LED Indicators and Motor Control

Circuit Documentation

Summary

This circuit is designed to monitor soil moisture and air quality, and control a DC motor based on the readings. It uses an Arduino UNO microcontroller to interface with various sensors and actuators, including a soil moisture sensor, an air quality sensor (SGP30), a relay, a toggle switch, and multiple LEDs. The circuit also includes resistors to limit current to the LEDs.

Component List

  1. Adafruit SGP30

    • Description: Air quality sensor
    • Pins: VCC, 3.3V, GND, SCL, SDA
  2. SparkFun Soil Moisture Sensor

    • Description: Measures soil moisture levels
    • Pins: VCC, GND, SIG
  3. Adafruit STEMMA Non-Latching Relay Breakout

    • Description: Controls the DC motor
    • Pins: 1, 2, 3, GND, VIN, SIGNAL, NC, COM, NO
  4. Toggle Switch

    • Description: Used to start/stop the system
    • Pins: L1, COM, L2
  5. Arduino UNO

    • Description: Microcontroller
    • 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
  6. DC Motor

    • Description: Actuator controlled by the relay
    • Pins: pin 1, pin 2
  7. Resistors

    • Description: Current limiting resistors for LEDs
    • Pins: pin1, pin2
    • Properties: Various resistances (560 Ohms, 1000 Ohms)
  8. LEDs (Red, Yellow, Green)

    • Description: Indicate system status
    • Pins: cathode, anode
  9. Power Supply Bench

    • Description: Provides power to the circuit
    • Pins: -12V, GND, +12V, +5V, +3.3V

Wiring Details

Adafruit SGP30

SparkFun Soil Moisture Sensor

Adafruit STEMMA Non-Latching Relay Breakout

Toggle Switch

Arduino UNO

DC Motor

Resistors

LEDs

Power Supply Bench

Code Documentation

//****************************************************************************************************************
const int Grn1 = 2; const int Yel1 = 3; const int Red1 = 4; // Use digital I/O pin 2,3,4
const int Grn2 = 5; const int Yel2 = 6; const int Red2 = 7; // Use digital I/O pin 5,6,7

const int Switch = 8; // Use digital I/O pin 8
const int Motor = 9; // Use digital I/O pin 9

int SysState = 0; // Initial value for reading the button status 

int H2O = 0; //value for storing moisture value 
int H2OPin = A0;//Declare a variable for the soil moisture sensor 

//This is a function used to get the soil moisture content
int readH2O(){
  delay(10);//wait 10 milliseconds 
  H2O = analogRead(H2OPin);//Read the SIG value form sensor 
  return H2O;//send current moisture value
}

#include "SparkFun_SGP30_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_SGP30
#include <Wire.h>
SGP30 mySensor; //create an object of the SGP30 class

//******************************************************************************************************************
void setup() {
  // put your setup code here, to run once
  Serial.begin(9600);   // open serial over USB

  pinMode(Grn1, OUTPUT); pinMode(Yel1, OUTPUT); pinMode(Red1, OUTPUT); // Sets Green, Yellow, and Red Light 1 as Output
  pinMode(Grn2, OUTPUT); pinMode(Yel2, OUTPUT); pinMode(Red2, OUTPUT); // Sets Green, Yellow, and Red Light 2 as Output
  
  pinMode(Motor, OUTPUT); // Sets Motor as Output
  pinMode(Switch, INPUT); // Sets Start button as Input

  // Sets value for inital light outputs to off (LOW)
  digitalWrite(Grn1,LOW); digitalWrite(Yel1,LOW); digitalWrite(Red1,LOW); 
  digitalWrite(Grn2,LOW); digitalWrite(Yel2,LOW); digitalWrite(Red2,LOW);

  Wire.begin();
  //Initialize sensor
  if (mySensor.begin() == false) {
    Serial.println("No SGP30 Detected. Check connections.");
    while (1);
  }
  //Initializes sensor for air quality readings
  //measureAirQuality should be called in one second increments after a call to initAirQuality
  mySensor.initAirQuality();
}
//******************************************************************************************************************
void loop() {
  // Main code here, to run repeatedly

  delay(1000);//take a reading every half second
  SysState = digitalRead(Switch); //Sets the Start button as system state
  
  // Turn on sampling system and read moisture
    if(SysState == HIGH