This project is meant to use a Raspberry Pi (model Zero W+ up to 4B) to help measure water level in a water tank placed on the roof of a house.
- Flash Raspberry Pi OS Lite/Full (32-bit) in a microSD card.
- You can follow a headless configuration or use the advanced menu in the Raspberry Pi Imager tool to setup the user, network, and ssh.
If you are planning to use a serial sensor to read the level of your water tank, enable I2C on your Pi with the following command:
sudo raspi-config # then, enable I2C using the UI menu
Edit the /etc/dhcpcd.conf
file as shown in the official docs to have a static IP address.
The developer's preferred wiring for a 14-bit resolution discrete sensor is detailed in the following picture:
Note: the wiring can be overriden by the user to fit their needs.
Create a file under the name level_sensor.env
and place the proper env vars as described below
# For discrete sensors (recommended)
WATER_SENSOR="discrete"
WATER_PINS="[14,15,18,23,24,25,8,7,12,16,20,21,26,19]" # override with your list (longer, shorter or with different GPIO pins)
# For serial sensors (to be deprecated)
WATER_SENSOR="serial"
WATER_MIN_VOLTAGE="2.0" # calibrate with your values
WATER_MAX_VOLTAGE="3.14" # calibrate with your values
# For gravity sensors (to be deprecated)
WATER_SENSOR="gravity"
WATER_MIN_REF="[-0.66, 13]" # calibrate with your values
WATER_MAX_REF="[5.6, 65]" # calibrate with your values
Create a file under the name level_publisher.env
and place the proper env vars as described below
LOCAL_SENSOR_ENDPOINT=http://localhost:8000
# All files below must be placed in a directory named "iot"
AWS_IOT_HOST="Your AWS IoT endpoint"
AWS_IOT_TOPIC="Your AWS IoT topic"
AWS_IOT_CERT=your-certificate.pem.crt
AWS_IOT_KEY=your-private.pem.key
AWS_IOT_ROOT=YourAmazonRootCA1.pem
From apt
:
sudo apt update
sudo apt upgrade
sudo apt install software-properties-common
sudo apt update
sudo apt install python3.11-full python3-pip
sudo bash deploy.sh [reqs] # optional flag to install/upgrade Python dependencies
With the IP address of your Pi, enter the following URL in your browser:
http://{IP_ADDRESS_OF_YOUR_PI}:8080
or, curl
the following URL via CLI
curl http://{IP_ADDRESS_OF_YOUR_PI}:8080/cli