Skip to content

skhg/toilet-sensor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

toilet-sensor

An Arduino-based toilet cistern monitor.

Concept

Sometimes the toilet needs an extra flush, and the cistern takes a while to fill up. How full is it? How long should I wait?

These are important questions.

Finally, we have answers.

Installed sensor

Sensor at work:

Sensor at work

Overview

An ultrasound distance sensor is installed within the toilet cistern. It emits ultrasound pulses which are reflected from the water surface and indicate the tank fill level. The sensor is controller by an Arduino microcontroller which reads the data, and generates the "image" to be displayed on the connected 8x8 LED matrix.

Overview

Materials required

Electronics:

Other:

  • 1 Small plastic box
  • Double-sided sticky tape
  • Cardboard
  • Small screws
  • Drill and assorted bits
  • Various small pliers, screwdriver, common tools

Construction

This was done in 2 parts, with the sensor adapter and the display module built seperately

Sensor

Within the toilet cistern I found that there were 2 removable plastic clips which hold a protective plate onto it's front. Each of these had a small pre-existing hole bored through it, which was ideal for mounting the sensor in the right direction. To this plastic clip I attached an angled piece of metal, and the mini breadboard on the other end. The sensor sits here facing downward and "secured" by a tie-wrap. I cut open an Ethernet cable and used 4 of the inner wires to connect the breadboard.

Display

Initially I prototyped the project using the Ethernet cable trailing out and everything hooked up to a breadboard:

This was enough to prove the concept worked within the cistern and interference didn't occur with the sides of the tank.

Next I moved on to mounting the components in a case. This was a repurposed 200g Ferrero Rocher box. I drilled two holes in the bottom (not visible here) large enough to admit the Ethernet cable and micro-USB power supply.

And connecting them with some 12cm lengths of ribbon cable:

And with this complete, I tidied up the wiring, reattached the flush button, mounted the whole unit to the wall, and powered it up:

Code

See the full Arduino C++ code in toilet-sensor.ino.

Circuit

Circuit diagram

This can also be viewed in the Fritzing software using the diagram.fzz file.

Calibration

Once the sensor and display were installed, the readings needed to be calibrated, since there's no way to know exactly how high or low the water level will be in comparison to the test runs (The sensor angle might have shifted during installation, etc). Calibration can be done very easily by capturing the serial output of the Arduino and exporting it to a spreadsheet.

Flush graph

Due to the confined space within the cistern and the natural movement of the water as it refills, the data at the start and end of the refill cycle is quite noisy. Ideally this would be solved by taking higher frequency measurements and smoothing for an average value, but this can come later.

For simplicity, in this example I take the top value as 400 and the bottom value as 1900. These values are configured at the top of the code file.

References

These tutorials and guides proved useful during the project

About

🚽An Arduino-based toilet cistern monitor

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published