The Basement Monitor
Our basement used to be a busy entertainment center, but we visit it far less frequently these days. It got flooded when the sump pump broke and got moldy when the dehumidifier went on strike. This project is to minimize damage if similar things happen again.
1. Water level sensor to detect overflow conditions
2. Humidity sensor to detect persistent moldy conditions
3. Temperature sensor (thermometer) for no good reason
4. Ability to send email or SMS alerts when an anomaly is detected
5. Web interface to display current values
6. Maintenance free operation
An ESP8266 serves as the main computer. It has a built-in WiFi capability that can connect to our home network and can act as a web server. It only needs a USB Micro 5v power supply to keep it alive. The AHT20 chip reports temperature & humidity. It came mounted on a breakout board with a BMP280 attached. The BMP280 reports only temperature and pressure. FYI, its cousin, the BME280 reports temperature, pressure and humidity, and they are all now superseded by the BMP390. The ESP8266 communicates with the chips using the I2C “wire” interface, using pins D1 and D2.
The water level sensor simply comprises two conducting electrodes dangling above the normal maximum height of the water in the sump. The electrodes are normally not submerged in water and will not be subject to corrosion and gunk. At worst, there may be some spider webs. The A/D converter measures the resistance across the conductors. Normally, there will be no current flowing between them. When the water level reaches the electrodes, the resistance changes, and the difference is easily detected by the A/D converter. The figure below shows the voltage divider ‘network’, with the purple analog pin marked A0. The A/D converter returns a value in the range 0 to 1024.
The voltage divider is powered by a GPIO pin instead of Vcc. This allows voltage to be turned on only when required, a minor precaution. Resistor R1 avoids damage if the electrodes are shorted. Resistor R2 is used to detect loss of connectivity to the sensor. This network design allows detection of five different situations, as shown in the table below:
Message |
Sensor value |
|
>= |
<= |
|
Sensor is shorted! |
0 |
19 |
Level is VERY HIGH!! |
20 |
399 |
Level is HIGH!! |
400 |
799 |
Level is OK |
800 |
1021 |
Sensor is not connected! |
1022 |
1024 |
Note that the ADC sensor values shown above are dependent on the sensor electrode’s area and separation. My sensor consists of two aluminum bars (6” long, 1” wide, and 1/8” thick) spaced 1/4” apart. The sensor mount and spacer were 3D printed and the STL files are linked. A custom case is also linked. The salt concentrations of the groundwater in your area may also affect the numbers.
Alerts are sent via email. Most carriers allow sending SMS via email. For example, with T-Mobile, sending a properly formatted email to 2122211212@tmomail.net usually works. Unfortunately, it fails about 25% of the time and often takes several minutes to be delivered.
Browsing to the web server displays the following. The page will refresh every 5 secs to show the latest values. A copy of the C/C++ software for this project is included here.
The drivers for the ATH20 and BMP280 were ‘found’ on the web at: https://github.com/peff74/ESP_AHT20_BMP280. Many thanks to the OP. The code works very well. The email code was adapted from Random Nerd’s site.