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

Arduino Mega 2560-Based Soil Nutrient Testing System with Bluetooth and LCD Display

View and Edit Project In Cirkit DesignerImage of Arduino Mega 2560-Based Soil Nutrient Testing System with Bluetooth and LCD Display

Circuit Documentation

Summary

This circuit is designed to perform various tests using sensors and relays controlled by an Arduino Mega 2560. The system includes a turbidity sensor, a color sensor, a Bluetooth module, multiple relays, an LCD display, and a water pump. The Arduino Mega 2560 serves as the central controller, interfacing with all the components to execute the tests and display results.

Component List

  1. Arduino Mega 2560

    • Description: Microcontroller board based on the ATmega2560.
    • Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0-A15, D0-D53, AREF, SDA, SCL
  2. Turbidity Sensor

    • Description: Measures the turbidity (cloudiness) of water.
    • Pins: gnd, in, vcc
  3. TCS230 Color Sensor

    • Description: Detects color by measuring the frequency of light.
    • Pins: GND, OE, S1, S0, VCC, OUT, S2, S3
  4. HC-05 Bluetooth Module

    • Description: Enables wireless communication.
    • Pins: Key, VCC, GND, TXD, RXD, State
  5. 5V 8-Channel Relay

    • Description: Controls high voltage devices with a low voltage signal.
    • Pins: GND, IN1-IN8, VCC, NC, C, NO
  6. 16x2 I2C LCD

    • Description: Displays information in a 16x2 character format.
    • Pins: GND, VCC, SDA, SCL
  7. Two Channel Relay 5V

    • Description: Controls two high voltage devices with a low voltage signal.
    • Pins: VCC, IN2, IN1, GND, NC2, C2, NO2, NC1, C1, NO1
  8. 12V Single Channel Relay

    • Description: Controls a single high voltage device with a low voltage signal.
    • Pins: NC, COM, NO, IN, GND, VCC
  9. DC Motor

    • Description: Converts electrical energy into mechanical motion.
    • Pins: pin 1, pin 2
  10. 5V Mini Water Pump

    • Description: Pumps water when powered.
    • Pins: positive pin, negative pin

Wiring Details

Arduino Mega 2560

Turbidity Sensor

TCS230 Color Sensor

HC-05 Bluetooth Module

5V 8-Channel Relay

16x2 I2C LCD

Two Channel Relay 5V

12V Single Channel Relay

5V Mini Water Pump

Documented Code

#include "LiquidCrystal_I2C.h"
#include "Wire.h"

// Relay Pins
const int relayPins[] = {4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
const int numRelays = sizeof(relayPins) / sizeof(relayPins[0]);

// LCD Setup
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Turbidity Sensor
const int turbiditySensorPin = A2;

// Color Sensor
const int S0 = 22, S1 = 23, S2 = 24, S3 = 25, OUT = 26;

// Bluetooth
HardwareSerial &bt = Serial1;

// Variables
char option = "";

// Helper Function: Initialize Relays
void initializeRelays() {
  for (int i = 0; i < numRelays; i++) {
    pinMode(relayPins[i], OUTPUT);
    digitalWrite(relayPins[i], HIGH); // Default to OFF
  }
}

// Helper Function: Display Message on LCD
void display