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 as the main microcontroller, interfacing with various sensors and actuators including a soil moisture sensor, an air quality sensor (SGP30), a relay breakout board, LEDs, and a DC motor. The system also includes a toggle switch for user input.

Component List

  1. Adafruit SGP30

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

    • Description: Soil moisture sensor
    • Pins: VCC, GND, SIG
  3. Adafruit STEMMA Non-Latching Relay Breakout

    • Description: Relay breakout board
    • Pins: 1, 2, 3, GND, VIN, SIGNAL, NC, COM, NO
  4. Toggle Switch

    • Description: User input switch
    • 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: DC motor
    • Pins: pin 1, pin 2
  7. Resistors

    • Description: Various resistors
    • Pins: pin1, pin2
    • Properties: 1000 Ohms, 560 Ohms
  8. LED: Two Pin (red)

    • Description: Red LED
    • Pins: cathode, anode
  9. LED: Two Pin (yellow)

    • Description: Yellow LED
    • Pins: cathode, anode
  10. LED: Two Pin (green)

    • Description: Green LED
    • Pins: cathode, anode

Wiring Details

Adafruit SGP30

SparkFun Soil Moisture Sensor

Adafruit STEMMA Non-Latching Relay Breakout

Toggle Switch

Arduino UNO

DC Motor

Resistors

LEDs

Documented Code

//****************************************************************************************************************
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
  Sys