This system utilizes a Raspberry Pi equipped with a water sensor to detect leaks, collect data, and send email notifications.
-
Download the Files:
- Download the contents of the
Raspifolder onto your Raspberry Pi.
- Download the contents of the
-
Install Dependencies:
pip install mysql-connector-python RPi.GPIO requests
-
Configure Environmental Variables:
- Open the
run_script.shfile and replace placeholder values with your actual MySQL database credentials:export DB_HOST='insert host name' export DB_DATABASE='insert database name' export DB_USER='insert database username' export DB_PASS='insert database password'
- Open the
-
API and Email Setup:
- In the same
run_script.shfile, insert your weather API key and email notification details:export WEATHER_API_KEY='insert weather api key' export EMAIL_PASS='insert email password'
- Update the sender and receiver email addresses in the
raspi_main.pyfile:sender_email = "INSERT EMAIL #1" receiver_email = "INSERT EMAIL #2"
- In the same
-
Modify File Paths:
- Update file paths in the scripts as necessary for your setup.
-
Cron Job Setup:
- Set up a cron job to run the script hourly:
0 * * * * /home/yourusername/run_final_script.sh
- Set up a cron job to run the script hourly:
-
Download the Files:
- Download the contents of the
MainPCfolder onto the PC where you want to run the Streamlit application.
- Download the contents of the
-
Install Dependencies:
pip install streamlit pandas sqlalchemy pymysql
-
Configure Environmental Variables:
- Ensure your MySQL database credentials are set as environmental variables (
DB_USER,DB_PASS,DB_HOST,DB_NAME).
- Ensure your MySQL database credentials are set as environmental variables (
-
Running the Application:
- To view the collected data, run the Streamlit application:
streamlit run main.py
- Ensure a MySQL database is running and accessible to both the Raspberry Pi and your main PC.
If you encounter issues with the system setup or operation, ensure that:
- All file paths are correctly set in your scripts.
- The MySQL database is running and the credentials provided are correct.
- Cron job is set correctly and has the right permissions to execute.
- Python dependencies are installed without conflicts.