Intelligent Raspberry Pi-Based Environmental Controller for Seed Starting Systems
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.
- 🌡️ 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
| 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 |
┌─────────────────────┐ ┌──────────────────────┐ ┌─────────────────────┐
│ 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 │ │ │ │ │ │
│ └─────────────────┘ │ │ └──────────────────┘ │ │ └─────────────────┘ │
└─────────────────────┘ └──────────────────────┘ └─────────────────────┘
- Simple sensor monitoring with relay control
- Weather API integration for daylight detection
- Configurable temperature and light thresholds
- Best for: Basic setups, learning, and prototyping
- 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
- Full sensor array support (DHT22, TSL2561, LM35, pH)
- Individual sensor calibration and control
- Modular sensor library integration
- Best for: Custom sensor configurations, research applications
- Trefle API integration for plant-specific data
- SQLite database management for seed tracking
- Optimal growing condition recommendations
- Best for: Species-specific automation, data analysis
- Hardware: Raspberry Pi 3B+ or newer
- Python: 3.10 or higher
- OS: Raspberry Pi OS (recommended) or compatible Linux distribution
-
Clone the repository
git clone https://github.com/secretengineer/SeedStarter.git cd SeedStarter -
Set up Python environment
python -m venv .venv source .venv/bin/activate # Linux/macOS # or .\.venv\Scripts\Activate.ps1 # Windows PowerShell
-
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
-
Configure environment variables
cp .env.example .env # Edit .env with your API keys and settings
python SeedStarterSetup.pyPerfect for getting started - monitors sensors and controls relays based on environmental conditions.
python GreenhouseControllerV1.pyFull-featured controller with ADC support, pH monitoring, and multi-relay management.
# First, create test database
python create_test_db.py
# Then run the API integration
python APIconnection.pyThe 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"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 |
❌ |
# 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 = 13Enable I2C on your Raspberry Pi:
sudo raspi-config
# Navigate to Interfacing Options → I2C → Enable# 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)-
Create service file
sudo nano /etc/systemd/system/seedstarter.service
-
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
-
Enable and start service
sudo systemctl enable seedstarter.service sudo systemctl start seedstarter.service sudo systemctl status seedstarter.service
# View service logs
sudo journalctl -u seedstarter.service -f
# Check service status
sudo systemctl status seedstarter.service
# Restart service
sudo systemctl restart seedstarter.service| 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 |
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 │
└─────────────────┘
GPIO Permission Errors
# Add user to gpio group
sudo usermod -a -G gpio $USER
# Reboot required
sudo rebootI2C Device Not Found
# Check I2C devices
i2cdetect -y 1
# Should show ADS1015 at address 0x48Import Errors on Development Machine
# Expected - use included RPi.GPIO shim for development
# Or install mock libraries for testing
pip install fake-rpiAPI Connection Issues
- Verify API keys in
.envfile - Check internet connectivity
- Review rate limits for external APIs
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- 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
This project is licensed under the MIT License - see the LICENSE file for details.
- Adafruit for excellent sensor libraries
- OpenWeatherMap for weather API
- Trefle for their comprehensive plant database
- Raspberry Pi Foundation
- 📧 Email: [email protected]
- 🐛 Issues: GitHub Issues
- 📖 Documentation: Wiki
Happy Growing! 🌱