Acknowledgment: This project was inspired by the original Raspberry Pi Automated Mushroom Farm project. While the original project is no longer maintained, it provided the foundational concepts and ideas for this implementation. We're grateful for their pioneering work in automated mushroom cultivation.
The Raspberry Pi Automated Mushroom Farm is a complete system for automating humidity control in mushroom cultivation environments. It uses a Raspberry Pi to monitor humidity levels via Zigbee sensors and automatically activates a humidifier (connected through an Energenie smart plug) when humidity falls below your specified threshold.
- Automated Humidity Control: Maintains optimal growing conditions (80-95% humidity) without constant monitoring
- Multi-Sensor Support: Works with multiple Zigbee humidity sensors for accurate environmental readings
- Smart Plug Integration: Controls standard humidifiers through affordable Energenie ENER002-2PI smart plugs
- Test Mode: Includes a simulation script for testing without physical hardware
- Auto-Start Capability: Can be configured as a system service that runs automatically on boot
- Comprehensive Logging: Detailed logging for monitoring system performance and troubleshooting
- Hardware: Raspberry Pi, Zigbee sensors, Energenie ENER002-2PI smart plug
- Software: Python, RPi.GPIO, Zigbee2MQTT
- Communication: GPIO pins for smart plug control, Zigbee for wireless sensor data
- Raspberry Pi (any model with GPIO access)
- Energenie ENER002-2PI smart plug
- One or more Zigbee humidity sensors
- Zigbee coordinator/hub
- Python 3.6+
# Clone repository
git clone https://github.com/aaronjacobs-chelt/Raspberry-PI-Automated-Mushroom-Farm.git
cd Raspberry-PI-Automated-Mushroom-Farm
# Install dependencies
sudo apt update && sudo apt install python3 python3-pip
pip3 install RPi.GPIO
# Run the automation script
sudo python3 humidifier_automation.pyFor detailed setup instructions, see the Configuration Guide.
This project includes comprehensive documentation to help you get started and make the most of your automated mushroom farm:
| Document | Description |
|---|---|
| Configuration Guide | Detailed configuration of sensors, state.json format, and script settings |
| Troubleshooting Guide | Common issues and solutions for system problems |
| Development Guide | Information for contributors and developers |
| docs/images/ | Diagrams and visual references |
Tip: Before beginning installation, we recommend reviewing the System Architecture Diagram and GPIO Connection Diagram for a visual understanding of how all components fit together.
Connect your Energenie ENER002-2PI smart plug to the Raspberry Pi GPIO pins:
| Energenie Wire | Raspberry Pi GPIO Pin |
|---|---|
| Red | Pin 11 (CTRL1) |
| Black | Pin 13 (OUTLET) |
| White | Pin 15 (CTRL2) |
| Green | Pin 16 (CTRL3) |
| Yellow | Pin 18 (CTRL4) |
| Blue | Pin 22 (TRIGGER) |
# Install required packages
sudo apt update
sudo apt install python3 python3-pip git
pip3 install RPi.GPIO
# Clone and set up the repository
git clone https://github.com/aaronjacobs-chelt/Raspberry-PI-Automated-Mushroom-Farm.git
cd Raspberry-PI-Automated-Mushroom-FarmEnsure Zigbee2MQTT is configured to write sensor data to a state.json file. For detailed instructions, see the Configuration Guide.
Set up as a systemd service to run on boot:
sudo nano /etc/systemd/system/humidifier.service[Unit]
Description=Mushroom Farm Humidity Automation
After=network.target
[Service]
ExecStart=/usr/bin/python3 /home/pi/Raspberry-PI-Automated-Mushroom-Farm/humidifier_automation.py
WorkingDirectory=/home/pi/Raspberry-PI-Automated-Mushroom-Farm
Restart=always
User=pi
[Install]
WantedBy=multi-user.targetEnable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable humidifier.service
sudo systemctl start humidifier.serviceOnce installed and configured, the system will:
- Read humidity data from your Zigbee sensors via the
state.jsonfile - Compare current humidity levels against your configured threshold (default: 95%)
- Activate the humidifier when humidity falls below the threshold
- Deactivate the humidifier when humidity reaches satisfactory levels
- Log all activities to
/var/log/humidifier.log
For testing without physical sensors:
python3 simulate_state_json.pyThis will generate simulated sensor data, allowing you to test the system's logic without actual hardware.
Check the log file for system activity:
cat /var/log/humidifier.logThe main configuration options are found in humidifier_automation.py:
# User configurable settings
HUMIDITY_THRESHOLD = 95.0 # Activate humidifier when humidity falls below this value
SENSOR_NAMES = ["sensor1", "sensor2"] # Names of your Zigbee sensors in state.json
STATE_FILE_PATH = "/opt/zigbee2mqtt/data/state.json" # Path to your state.json file
LOG_FILE = "/var/log/humidifier.log" # Path for log file
REBOOT_AFTER_CYCLES = 30 # Reboot after this many cycles (set to 0 to disable)For detailed configuration information, see the Configuration Guide.
We welcome contributions to improve this project! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Commit with clear messages (
git commit -m 'Add feature: description') - Push to your branch (
git push origin feature/amazing-feature) - Open a Pull Request
See the Development Guide for coding standards and development workflow details.
MIT License β Use and modify freely.
Made with β€οΈ for mushroom growers everywhere