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! ๐ฑ