Skip to content

secretengineer/SeedStarter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

16 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒฑ SeedStarter

Intelligent Raspberry Pi-Based Environmental Controller for Seed Starting Systems

Python License Tests

SeedStarter is a comprehensive automation solution designed to optimize seedling growth conditions through intelligent environmental monitoring and control. Built for Raspberry Pi, it seamlessly integrates multiple sensors, external APIs, and relay-controlled devices to create the perfect growing environment for your seeds.

๐ŸŽฏ Key Features

  • ๐ŸŒก๏ธ Multi-Sensor Monitoring: Temperature, humidity, light levels, and pH sensors
  • ๐Ÿ”„ Automated Control: Smart relay management for heat mats, lights, and dosing systems
  • โ˜๏ธ Weather Integration: OpenWeatherMap API for sunrise/sunset timing and environmental data
  • ๐ŸŒฟ Plant Database: Integration with Trefle API for species-specific growing conditions
  • ๐Ÿ“Š Data Logging: SQLite database for historical tracking and analysis
  • ๐Ÿ”ง Multiple Controller Types: From simple sensor monitoring to advanced ADC-based systems
  • ๐Ÿ’ป Cross-Platform Development: Mock hardware support for Windows/macOS development

๐Ÿ—๏ธ System Architecture

Hardware Components

Component Purpose GPIO Pin Interface
DHT22 Temperature & Humidity GPIO17 Digital
TSL2561 Light Sensor GPIO4 I2C
LM35 Soil Temperature GPIO27 Analog
pH Sensor Soil pH Monitoring GPIO22/ADC Analog
ADS1015 12-bit ADC Module I2C I2C Bus
Relay Module Device Control GPIO18,26,19,13,6,5 Digital Out

Software Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Sensor Layer      โ”‚    โ”‚   Control Layer      โ”‚    โ”‚   External APIs     โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚    โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚    โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ DHT22 (Temp/Hum)โ”‚ โ”‚    โ”‚ โ”‚ Relay Controllersโ”‚ โ”‚    โ”‚ โ”‚ OpenWeatherMap  โ”‚ โ”‚
โ”‚ โ”‚ TSL2561 (Light) โ”‚ โ”‚โ—„โ”€โ”€โ–บโ”‚ โ”‚ Heat Mats       โ”‚ โ”‚    โ”‚ โ”‚ Trefle Plant DB โ”‚ โ”‚
โ”‚ โ”‚ LM35 (Soil Temp)โ”‚ โ”‚    โ”‚ โ”‚ Grow Lights     โ”‚ โ”‚โ—„โ”€โ”€โ–บโ”‚ โ”‚ SQLite Database โ”‚ โ”‚
โ”‚ โ”‚ pH Sensor       โ”‚ โ”‚    โ”‚ โ”‚ Dosing Pumps    โ”‚ โ”‚    โ”‚ โ”‚                 โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚    โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚    โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Applications Included

1. SeedStarterSetup.py - Basic Environmental Controller

  • Simple sensor monitoring with relay control
  • Weather API integration for daylight detection
  • Configurable temperature and light thresholds
  • Best for: Basic setups, learning, and prototyping

2. GreenhouseControllerV1.py - Advanced Multi-Relay Controller

  • ADS1015 ADC integration for precise analog readings
  • Multi-relay control with independent timing
  • pH monitoring and automated dosing
  • Threading for concurrent operations
  • Best for: Production greenhouses, advanced monitoring

3. RaspPIControl.py - Comprehensive Sensor Suite

  • Full sensor array support (DHT22, TSL2561, LM35, pH)
  • Individual sensor calibration and control
  • Modular sensor library integration
  • Best for: Custom sensor configurations, research applications

4. APIconnection.py - Plant Database & API Integration

  • Trefle API integration for plant-specific data
  • SQLite database management for seed tracking
  • Optimal growing condition recommendations
  • Best for: Species-specific automation, data analysis

โšก Quick Start

Prerequisites

  • Hardware: Raspberry Pi 3B+ or newer
  • Python: 3.10 or higher
  • OS: Raspberry Pi OS (recommended) or compatible Linux distribution

๐Ÿ”ง Installation

  1. Clone the repository

    git clone https://github.com/secretengineer/SeedStarter.git
    cd SeedStarter
  2. Set up Python environment

    python -m venv .venv
    source .venv/bin/activate  # Linux/macOS
    # or
    .\.venv\Scripts\Activate.ps1  # Windows PowerShell
  3. Install dependencies

    # For development/testing (any OS)
    pip install -r requirements.txt
    
    # For Raspberry Pi deployment (additional hardware libraries)
    pip install adafruit-blinka adafruit-circuitpython-ads1x15 RPi.GPIO
  4. Configure environment variables

    cp .env.example .env
    # Edit .env with your API keys and settings

๐ŸŽฎ Running the Applications

Basic Environmental Control

python SeedStarterSetup.py

Perfect for getting started - monitors sensors and controls relays based on environmental conditions.

Advanced Greenhouse Controller

python GreenhouseControllerV1.py

Full-featured controller with ADC support, pH monitoring, and multi-relay management.

Plant Database Integration

# First, create test database
python create_test_db.py

# Then run the API integration
python APIconnection.py

๐Ÿงช Development & Testing

The project includes mock hardware support for development on non-Pi systems:

# Run tests
python -m pytest tests/ -v

# Check syntax
python -m py_compile *.py

# Simulate sensor input (development only)
python -c "import RPi.GPIO as GPIO; GPIO._pin_values[7] = True"

๐Ÿ“‹ Configuration

Environment Variables

Create a .env file from the template and configure the following variables:

Variable Description Example Required
WEATHER_API_KEY OpenWeatherMap API key your_api_key_here โœ…
WEATHER_CITY City for weather data Denver โŒ
TREFLE_API_KEY Trefle plant database API key your_trefle_key โœ…
RPI_BASE_URL Raspberry Pi base URL for remote monitoring http://192.168.1.42 โŒ

Hardware Configuration

GPIO Pin Mapping (BCM Mode)

# Digital Sensors
DHT22_PIN = 17        # Temperature & Humidity
TSL2561_PIN = 4       # Light Sensor (I2C)
LIGHT_SENSOR_PIN = 7  # Digital Light Sensor

# Analog Sensors (via ADS1015 ADC)
PH_SENSOR_ADC = ADS.P0    # pH Sensor
LM35_ADC = ADS.P1         # Soil Temperature

# Relay Controls
RELAY_PINS = [26, 19, 13, 6, 5]  # Heat mats, lights, dosing pumps
SEEDLING_HEAT_MAT_PIN = 11
GREENHOUSE_LIGHT_PIN = 13

I2C Configuration

Enable I2C on your Raspberry Pi:

sudo raspi-config
# Navigate to Interfacing Options โ†’ I2C โ†’ Enable

Control Thresholds

# Temperature Control
TEMP_THRESHOLD = 20.0      # ยฐC
PH_LOW_THRESHOLD = 5.0     # pH units  
PH_HIGH_THRESHOLD = 7.0    # pH units

# Timing Configuration
CONTROL_INTERVAL = 60      # seconds
PH_DOSE_INTERVAL = 3600    # seconds (1 hour)

๐Ÿ”ง Production Deployment

Systemd Service Setup

  1. Create service file

    sudo nano /etc/systemd/system/seedstarter.service
  2. Service configuration

    [Unit]
    Description=SeedStarter Environmental Controller
    After=network.target
    
    [Service]
    Type=simple
    User=pi
    WorkingDirectory=/home/pi/SeedStarter
    Environment=PATH=/home/pi/SeedStarter/.venv/bin
    ExecStart=/home/pi/SeedStarter/.venv/bin/python SeedStarterSetup.py
    Restart=always
    RestartSec=10
    
    [Install]
    WantedBy=multi-user.target
  3. Enable and start service

    sudo systemctl enable seedstarter.service
    sudo systemctl start seedstarter.service
    sudo systemctl status seedstarter.service

Monitoring & Logs

# View service logs
sudo journalctl -u seedstarter.service -f

# Check service status  
sudo systemctl status seedstarter.service

# Restart service
sudo systemctl restart seedstarter.service

๐Ÿ› ๏ธ Hardware Assembly

Required Components

Component Model/Type Quantity Purpose
Raspberry Pi 3B+ or 4B 1 Main controller
Temperature/Humidity DHT22 1 Environmental monitoring
Light Sensor TSL2561 1 Ambient light detection
Soil Temperature LM35 1 Root zone temperature
pH Sensor Analog pH probe 1 Soil pH monitoring
ADC Module ADS1015 (12-bit) 1 Analog signal conversion
Relay Module 5V 8-channel 1 Device switching
Power Supply 5V 3A + 12V 2A 1 System power

Wiring Diagram

Raspberry Pi 4B
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  3V3  5V   GND         โ”‚
โ”‚   โ”‚   โ”‚     โ”‚          โ”‚
โ”‚   โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€ Relay Module VCC
โ”‚   โ”‚         โ””โ”€โ”€โ”€โ”€ Relay Module GND
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ DHT22 VCC
โ”‚                    โ”‚
โ”‚  GPIO17 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ DHT22 Data
โ”‚  GPIO4  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ TSL2561 SDA  
โ”‚  GPIO5  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ TSL2561 SCL
โ”‚  GPIO7  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Digital Light Sensor
โ”‚                    โ”‚
โ”‚  SDA โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€ ADS1015 SDA
โ”‚  SCL โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ ADS1015 SCL
โ”‚                    โ”‚
โ”‚  GPIO26 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Relay 1 (Heat Mat)
โ”‚  GPIO19 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Relay 2 (Grow Light)
โ”‚  GPIO13 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Relay 3 (Dosing Pump 1)
โ”‚  GPIO6  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Relay 4 (Dosing Pump 2)  
โ”‚  GPIO5  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Relay 5 (Fan/Ventilation)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

ADS1015 ADC Module
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ A0 โ†โ”€โ”€โ”€ pH Probe โ”‚
โ”‚ A1 โ†โ”€โ”€โ”€ LM35    โ”‚  
โ”‚ A2              โ”‚
โ”‚ A3              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿšจ Troubleshooting

Common Issues

GPIO Permission Errors

# Add user to gpio group
sudo usermod -a -G gpio $USER
# Reboot required
sudo reboot

I2C Device Not Found

# Check I2C devices
i2cdetect -y 1
# Should show ADS1015 at address 0x48

Import Errors on Development Machine

# Expected - use included RPi.GPIO shim for development
# Or install mock libraries for testing
pip install fake-rpi

API Connection Issues

  • Verify API keys in .env file
  • Check internet connectivity
  • Review rate limits for external APIs

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow PEP 8 style guidelines
  • Add tests for new functionality
  • Update documentation for API changes
  • Use environment variables for configuration
  • Never commit API keys or secrets

๐Ÿ“„ License

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

๐Ÿ™ Acknowledgments

  • Adafruit for excellent sensor libraries
  • OpenWeatherMap for weather API
  • Trefle for their comprehensive plant database
  • Raspberry Pi Foundation

๐Ÿ“ž Support


Happy Growing! ๐ŸŒฑ

About

Environmental controller for seed-starting rack using Raspberry Pi

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published