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.
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.
- 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.
- 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).
- Arduino IDE (Version 2.x recommended)
- Python 3.8+
- Python dependencies are listed in the
requirements.txtfile.
/
├── 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
- 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.
- Open the
arduino_pot_hub/arduino_pot_hub.inosketch in the Arduino IDE. - 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};). - Connect the Arduino to your computer via USB.
- Select the correct Board (Arduino Uno) and Port in the IDE.
- Upload the sketch to the board.
- Clone this repository to your laptop.
- It is highly recommended to use a Python virtual environment.
python3 -m venv env source env/bin/activate - Install the required packages using the
requirements.txtfile:pip install -r requirements.txt
- Run the main script:
The script will automatically connect to the Arduino and display the parsed sensor data.
python3 python_laptop_side/read_moisture.py
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.
- 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.
- 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.
- 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.
This project is licensed under the MIT License. See the LICENSE file for details.