Blog

Solar Powered Well Water Level Monitor - Hackster.io

Add the following snippet to your HTML:

After some dry summers our well level has dropped significantly, so this allows us to monitor the well water level & send alerts. 15 Inch Panel PC

Solar Powered Well Water Level Monitor - Hackster.io

Read up about this project on

After some dry summers our well level has dropped significantly, so this allows us to monitor the well water level & send alerts.

The purpose of this project was to monitor a well water level 100' away from the house in the back yard with no available power supply. The project was orignally done with a Raspberry Pi Pico W but decided to go with a ESP32-Wroom-32U for the external antenna.

Option 2: Tracking Solar Panel (Comming Soon)

The ESP32 collect the sensor data and sends the data to InfluxDB and then imported to Grafana for trending and visulization over Wifi. InfluxDB Cloud & Grafana in this project are free and allow for 30days of historical data. You would need to setup accounts and obtain your InfluxDB token and create your dashboard. I will not go over this process in this built as a simple google search can give you some examples how to setup the accounts and just replace "<Your Token here>", "<Your bucket here>" & "<Your Organization>" in the provided code to publish the data to InluxDB.

Power(+) from both the battery and the solar panel is run through a 4 pin switch to elminate all sources of power while working. I found that both the Solar input and battery input needed to be switched or the ESP32 would not shutdown due to the voltage from the solar panel. Ensure your switch does not connect these two sources as they have different voltage potenitals.

Each power source is run through its own INA226 to measure the voltage, current and power then connected to the Solar Power Management Board by DFRobot. More information on the board can be found here: https://www.dfrobot.com/product-1712.html

3.3V and ground is supplied to the INA226s from the ESP32 and SDA/SCL for communiation.

The ESP32 is connected to the Solar Power Management Board with a USB cable to provide the power supply to the ESP32.

The ESP32 supplies the 5V+/- to the level sensor and pin 33 is used for the analogue signal from the level sensor. Important to note that the level sensor selected has a higher range then the well can get too so the output voltage from the sensor does not exceed the limit for the ADC on the ESP32. A 10M Range level sensor was used for a well that is 7M deep and the output voltage of the sensor at max range is 4.5V so at 7M the voltage would be around 3.3V

(7 - 0) / (10 - 0) = (V - 0.5) / (4.5 - 0.5).V ≈ 3.3V

If this is not possible in your situation a voltage divider could be used to drop the voltage instead

ESP32 Pins 21/22 are used for the communciation from the INA226s and the light intensity module.

Code Breakdown (Fixed Solar Panel) :

MicroPython script designed for an ESP32 microcontroller. Here's a breakdown of its functionality:

Importing Libraries: The code starts by importing various libraries required for different functionalities, such as networking, timekeeping, hardware control, and sensor readings.

GPIO Configuration: The code configures the GPIO pins defined in the gpio_pins list as inputs with pull-down resistors. It also disables the Bluetooth functionality by setting the pin 0 as an output and setting its value to 0.

I2C Initialization: The code initializes the I2C interface using the SoftI2C class with specified SCL (clock) and SDA (data) pins.

INA226 Device Initialization: The code initializes two INA226 devices connected via I2C (0x40 and 0x44 addresses). It sets the variables ina1 and ina2 accordingly and flags I2C1_connected and I2C2_connected to indicate successful connections.

LED Initialization: The code initializes an LED pin (pin 2) as an output.

Blinking LED: The code defines a timer event ( timer1) that toggles the state of the LED using the blink function. It then blinks the LED once by setting its value to 1.

ADC Initialization: The code initializes an Analog-to-Digital Converter (ADC) object for a specific pin (pin 33).

WiFi Configuration: The code defines the SSID and password of the WiFi networks in the WIFI_NETWORKS list. It also includes a function connect_to_wifi() that attempts to connect to each WiFi network sequentially until a successful connection is established.

Device Connection: The code includes a function connect_devices() that attempts to connect to the INA226 devices via I2C.

Sensor Data Collection: The code defines a function send_sensor_data() that collects sensor data, including pressure, battery current, battery voltage, battery power, solar current, solar voltage, solar power, and CPU temperature. The data is then formatted into InfluxDB line protocol strings and sent to an InfluxDB Cloud server using HTTP POST requests.

Main Execution: The code initializes variables, sets constants for light sleep time and watchdog timeout, and starts an infinite loop.

The code resets the watchdog timer, reconnects to devices if necessary, connects to WiFi if not connected, and tracks consecutive failed WiFi connection attempts.

Sensor data is collected and sent to InfluxDB Cloud using the send_sensor_data() function. If the data transmission fails, it increments a failed transmissions counter and continues the loop.

If data is sent successfully, the LED blinks and the failed transmissions counter is reset.

The code then enters a light sleep mode for the specified duration and repeats the loop.

Solar Powered Well Water Level Monitor - Hackster.io

19" Waterproof Panel PC Hackster.io, an Avnet Community © 2023