Skip to content

A scalable, open-source environmental control system using Arduino and Python for precision automated indoor farming.

Notifications You must be signed in to change notification settings

agent1040/cea-1040

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project CEA-1040: Arduino Moisture Sensor Hub

Author: Agent1040 Status: In Development (Alpha)

This repository contains the open-source code for an Arduino-based sensor hub designed to monitor coco coir (or soil) moisture levels for automated plant irrigation. This "Pot Hub" serves as the "Precision & Insight Layer" for a cannabis cultivation project, sending sensor data to a laptop for processing and control logic.

Core Philosophy

This project blends a reliable commercial "Platform Layer" (e.g., a complete grow tent kit) with a custom-built open-source "Precision & Insight Layer" (this project) for monitoring and controlling critical variables.

Features

  • Dynamic Sensor Handling: The Arduino sketch is written to handle a variable number of sensors without code changes—simply update the configuration array.
  • Flexible Data Output: Sensor data is sent over serial in a simple, machine-readable format (M0:value0,M1:value1,...).
  • Python Client: A Python script on the host machine connects to the Arduino, parses the data into a flexible dictionary, and displays the readings.
  • Scalable: Designed to be the foundation for more advanced automation, including pump control, data logging, and integration with platforms like Mycodo.

Hardware Components

  • Microcontroller: 1x AZDelivery ATmega328 (Arduino Uno R3 Compatible)
  • Sensors: Aideepen V1.2 Analog Capacitive Soil Moisture Sensors
  • Prototyping: MB-102 Breadboard & Dupont Jumper Wires
  • Host Machine: ThinkPad laptop running a Debian-based Linux distribution (e.g., Ubuntu).

Software & Dependencies

  • Arduino IDE (Version 2.x recommended)
  • Python 3.8+
  • Python dependencies are listed in the requirements.txt file.

Project Structure

/
├── arduino_pot_hub/     # All code to be run on the Arduino MCU
├── python_laptop_side/  # All client-side code for the laptop
├── .gitignore           # Specifies files for Git to ignore
├── LICENSE              # Project's open-source license
├── README.md            # This file
└── requirements.txt     # Python dependencies

Setup & Usage

1. Hardware Setup

  • Connect the VCC, GND, and AOUT pins of each capacitive moisture sensor to the Arduino's 5V, GND, and an Analog In pin (A0, A1, etc.), respectively. A breadboard is recommended for organizing connections.

2. Arduino Setup

  1. Open the arduino_pot_hub/arduino_pot_hub.ino sketch in the Arduino IDE.
  2. In the sketch, modify the SENSOR_PINS[] array to match the analog pins you have connected your sensors to (e.g., const int SENSOR_PINS[] = {A0, A1};).
  3. Connect the Arduino to your computer via USB.
  4. Select the correct Board (Arduino Uno) and Port in the IDE.
  5. Upload the sketch to the board.

3. Python Client Setup

  1. Clone this repository to your laptop.
  2. It is highly recommended to use a Python virtual environment.
    python3 -m venv env
    source env/bin/activate
  3. Install the required packages using the requirements.txt file:
    pip install -r requirements.txt
  4. Run the main script:
    python3 python_laptop_side/read_moisture.py
    The script will automatically connect to the Arduino and display the parsed sensor data.

Calibration: The Most Important Step

Raw analog sensor values are meaningless without calibration. You must determine the sensor's readings in your specific grow medium at desired "dry" and "wet" levels.

NOTE: The initial calibration for this project is being performed on Canna Terra Professional soil for an autoflower run. These calibration values will not be directly transferable to the final project's Plagron Cocos Premium medium. Calibration must be performed for each new medium.

  1. Find Dry Setpoint: Place a sensor in the medium as it comes from the bag. Record the stabilized sensor value. This is the value at which you'll want to trigger watering.
  2. Find Wet Setpoint: Fully saturate the medium with water and allow it to drain completely for 15-20 minutes (to reach "Field Capacity"). Record the new, lower stabilized value. This is the value that indicates watering is complete.

Roadmap

  • Implement pump control via a USB relay module.
  • Add data logging to a CSV file or database.
  • Develop a simple GUI or web dashboard for real-time visualization.
  • Integrate with Mycodo.

License

This project is licensed under the MIT License. See the LICENSE file for details.