/automated-hydroponics

Automated home garden using hydroponics concepts

Primary LanguageC++

automated-hydroponics

Automated home garden using hydroponics concepts

Components

Schematics

Schematics

RPi setup

# Choose Menu > Preferences > Raspberry Pi Configuration
#>> Change pi password
#>> Change hostname to what you would like your RPi to be named.
#>> Enable SSH and VNC
# (A reboot will be needed after these changes)

# Camera setup
# RPi camera setup instructions: https://www.raspberrypi.org/documentation/configuration/camera.md

# Install a web interface for controlling the camera and doing timelapses
# Install instructions: https://elinux.org/RPi-Cam-Web-Interface

# Check to see if Arduino is seen
Should see /dev/ttyACM0
ls /dev/tty*

# Install Arduino IDE on RPi, though optional
sudo apt-get install arduino

# Install Arduino CLI
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/usr/local/bin sh
# Might need to fiddle a bit on where it is installed

arduino-cli core update-index
arduino-cli board list

# Install platform core for board Arduino Uno/Mega
arduino-cli core install arduino:avr

# Clone this project
cd ~
git clone https://github.com/petcupaula/automated-hydroponics.git

# Install Arduino libraries
# You can search for libraries using: arduino-cli lib search DHT
arduino-cli lib install "DHT sensor library"
arduino-cli lib install "Adafruit AS7341"
arduino-cli lib install "OneWire"
# Libraries to be installed from zip files - files will go into  /home/pi/Arduino/libraries/
cd /home/pi/Arduino/libraries/
git clone https://github.com/DFRobot/GravityTDS.git

# Test compile and upload from cmd line:
cd ~/automated_hydroponics
arduino-cli compile --fqbn arduino:avr:uno arduino_hydroponics/arduino_hydroponics.ino 
arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:avr:uno arduino_hydroponics

# To communicate between Arduino and Raspberry Pi via serial, there are 
# three scripts that can be used

# The `arduino_com.py` sends a message via serial to the Arduino, which in turn returns sensor data
python3 arduino_com.py

# The `mqtt_client.py` is an enhanced version of that, but sends the data to an MQTT broker. 
# (Note: certificates will be required that are not included in this repo)
# Path to certificates can be added in config.py (see config_template.py for what is expected)
python3 mqtt_client.py

# Install Adafruit IO for sending and receiving data from Adafruit IO's MQTT broker
sudo pip3 install adafruit-io
# To communicate with Adafruit IO, and subscribe to the `hydroponics feed`
python3 aio_client.py

# To ensure the aio_client.py (or mqtt_client.py) are run at Raspberry Pi reboot:
sudo nano /etc/rc.local
# Add the following line before the exit:
sudo bash -c '/usr/bin/python3 /home/pi/automated-hydroponics/aio_client.py > /home/pi/Desktop/log.txt 2>&1' &
# Test it by restarting the Raspberry Pi:
sudo reboot
# And after reconnecting check that the python script is running:
ps aux | grep python

# That is it.

Dashboard and command center

Example created in Adafruit IO:

AIO_dash