Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino Nano ESP32-Based Aquaponics Monitoring System with Battery Power

Image of Arduino Nano ESP32-Based Aquaponics Monitoring System with Battery Power

Circuit Documentation

Summary

This document provides a detailed overview of an aquaponics monitoring and control system. The system utilizes an Arduino Nano ESP32 microcontroller to interface with various sensors and a relay to control a water pump. The sensors include a TDS sensor, a pH meter, a dissolved oxygen (DO) sensor, a temperature sensor, and an AHT10 sensor for humidity and air temperature. A buck converter is used to regulate the power supply from a LiPo battery.

Component List

  1. Arduino Nano ESP32

    • Description: Microcontroller used to interface with sensors and control the relay.
    • Pins: D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, GND, RST, RX0, TX1, D13, 3.3V, B0, A0, A1, A2, A3, A4, A5, A6, A7, VBUS, B1, VIN
  2. DO Sensor

    • Description: Sensor used to measure dissolved oxygen levels in water.
    • Pins: Vcc, Gnd, Out
  3. TDS Sensor

    • Description: Sensor used to measure Total Dissolved Solids (TDS) in water.
    • Pins: AI, GND, 5V
  4. Temperature Sensor

    • Description: Sensor used to measure water temperature.
    • Pins: Temp GND Black, Temp VDD Red, Temp DQ Data Yellow
  5. PH Meter

    • Description: Sensor used to measure the pH level of water.
    • Pins: Signal, VCC, GND
  6. AHT10

    • Description: Sensor used to measure humidity and air temperature.
    • Pins: Vcc, Gnd, SCL, SDA
  7. Buck Converter

    • Description: Used to regulate the power supply from the LiPo battery.
    • Pins: IN+, IN-, OUT+, OUT-
  8. LiPo Battery 2200mAH 30c

    • Description: Power source for the circuit.
    • Pins: VCC, GND
  9. Water Pump

    • Description: Pump used to circulate water in the aquaponics system.
    • Pins: positive, negative
  10. 1-Channel Relay (5V 10A)

    • Description: Relay used to control the water pump.
    • Pins: NC, signal, C, power, NO, ground

Wiring Details

Arduino Nano ESP32

  • D8 connected to 1-Channel Relay (5V 10A) signal pin
  • D5 connected to Temperature Sensor Temp DQ Data Yellow pin
  • A0 connected to TDS Sensor AI pin
  • A1 connected to DO Sensor Out pin
  • A3 connected to PH Meter Signal pin
  • A4 connected to AHT10 SDA pin
  • A5 connected to AHT10 SCL pin

DO Sensor

  • Vcc connected to Buck Converter OUT+ pin
  • Gnd connected to Buck Converter OUT- pin
  • Out connected to Arduino Nano ESP32 A1 pin

TDS Sensor

  • AI connected to Arduino Nano ESP32 A0 pin
  • GND connected to Buck Converter OUT- pin
  • 5V connected to Buck Converter OUT+ pin

Temperature Sensor

  • Temp GND Black connected to Buck Converter OUT- pin
  • Temp VDD Red connected to Buck Converter OUT+ pin
  • Temp DQ Data Yellow connected to Arduino Nano ESP32 D5 pin

PH Meter

  • Signal connected to Arduino Nano ESP32 A3 pin
  • VCC connected to Buck Converter OUT+ pin
  • GND connected to Buck Converter OUT- pin

AHT10

  • Vcc connected to Buck Converter OUT+ pin
  • Gnd connected to Buck Converter OUT- pin
  • SCL connected to Arduino Nano ESP32 A5 pin
  • SDA connected to Arduino Nano ESP32 A4 pin

Buck Converter

  • OUT+ connected to PH Meter VCC pin, DO Sensor Vcc pin, Temperature Sensor Temp VDD Red pin, 1-Channel Relay (5V 10A) power pin, TDS Sensor 5V pin, AHT10 Vcc pin
  • OUT- connected to PH Meter GND pin, DO Sensor Gnd pin, Temperature Sensor Temp GND Black pin, TDS Sensor GND pin, AHT10 Gnd pin
  • IN+ connected to LiPo Battery 2200mAH 30c VCC pin, 1-Channel Relay (5V 10A) C pin
  • IN- connected to LiPo Battery 2200mAH 30c GND pin, Water Pump negative pin, 1-Channel Relay (5V 10A) ground pin

LiPo Battery 2200mAH 30c

  • VCC connected to Buck Converter IN+ pin
  • GND connected to Buck Converter IN- pin

Water Pump

  • positive connected to 1-Channel Relay (5V 10A) NO pin
  • negative connected to Buck Converter IN- pin

1-Channel Relay (5V 10A)

  • signal connected to Arduino Nano ESP32 D8 pin
  • C connected to Buck Converter IN+ pin
  • power connected to Buck Converter OUT+ pin
  • NO connected to Water Pump positive pin
  • ground connected to Buck Converter IN- pin

Code Documentation

#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <AHT10.h>
#include <DFRobot_ESP_PH.h>
#include <DFRobot_DO.h> // Added dissolved oxygen sensor library

// Pin Definitions
#define TDS_SENSOR_PIN A0
#define PH_SENSOR_PIN A3
#define DS18B20_PIN 5
#define RELAY_PIN 8
#define ONE_WIRE_BUS DS18B20_PIN
#define DO_SENSOR_PIN A1 // Added pin for dissolved oxygen sensor
#define SCL_PIN A5 // Typical SCL pin for I2C
#define SDA_PIN A4 // Typical SDA pin for I2C

// Sensor Objects
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature tempSensor(&oneWire);
AHT10 aht10;
DFRobot_ESP_PH ph;
DFRobot_DO do_sensor; // Dissolved oxygen sensor object
float tdsSensorValue = 0;
float phValue = 0;
float doValue = 0; // Dissolved oxygen value

void setup()
{
    Serial.begin(115200);

    // Initialize I2C with specific SCL and SDA pins
    Wire.begin(SDA_PIN, SCL_PIN);

    // Initialize Sensors
    tempSensor.begin();

    // AHT10 Initialization
    if (!aht10.begin())
    {
        Serial.println("AHT10 not found. Check wiring!");
    }

    // PH Sensor Initialization
    ph.begin();

    // Dissolved Oxygen Sensor Initialization
    do_sensor.begin();

    // Relay Setup
    pinMode(RELAY_PIN, OUTPUT);
    digitalWrite(RELAY_PIN, LOW);
}

void loop()
{
    // Read Temperature Sensors
    tempSensor.requestTemperatures();
    float waterTemp = tempSensor.getTempCByIndex(0);

    // Read AHT10 (Humidity and Air Temperature)
    float humidity = aht10.readHumidity();
    float airTemp = aht10.readTemperature();

    // Read TDS Sensor
    tdsSensorValue = readTDSSensor();

    // Read PH Sensor
    phValue = readPHSensor();

    // Read Dissolved Oxygen Sensor
    doValue = readDOSensor(waterTemp);

    // Print Sensor Readings
    Serial.println("--- Aquaponics Sensor Readings ---");
    Serial.print("Water Temperature: ");
    Serial.print(waterTemp);
    Serial.println(" °C");

    Serial.print("Air Temperature: ");
    Serial.print(airTemp);
    Serial.println(" °C");

    Serial.print("Humidity: ");
    Serial.print(humidity);
    Serial.println(" %");

    Serial.print("TDS Value: ");
    Serial.print(tdsSensorValue);
    Serial.println(" ppm");

    Serial.print("PH Value: ");
    Serial.print(phValue);
    Serial.println("");

    Serial.print("Dissolved Oxygen: ");
    Serial.print(doValue);
    Serial.println(" mg/L");

    // Control Relay (example: turn on if water temp is below 20°C)
    if (waterTemp < 20.0)
    {
        digitalWrite(RELAY_PIN, HIGH);
    }
    else
    {
        digitalWrite(RELAY_PIN, LOW