Hand on heart, men: how often does your life companion remind you to close the toilet lid? Even my mother told me in a quiet hour that she has talked about this with my father, and to this day this is still a bone of contention in an otherwise happy marriage.
I would like to have a positive effect on you and, with the help of a small circuit, ensure that on the one hand you are not on the throne too long killing time there with your smartphone or reading the newspaper and that on the other hand you actually will be acoustically reminded to close the lid.
Here you will learn something about the use of a timer and how to get a short, but annoying, melody out of a little buzzer.
- Buzzer: GND and A4
- Reed Switch: D2 and D4
My toilet is a commercial model without automatic closure with an electric motor, but the open lid remains open - for whatever reason.
As soon as the lid is opened, a timer is triggered which, after the preset timer time has elapsed, calls a function which visually and, above all, acoustically informs the user of the opened lid. This is repeated as long as the switch is open.
I have placed the components in a housing for "splash water protection" and paying attention to hygiene.
For the sake of aesthetics, I hid the case under the toilet cover.
Only the switch peeps out and is attached to the lid. As soon as my family understands the educational benefits, I will be able to shorten the cables and dispense with the crocodile plug connection.
You will notice the missing lines of code within the loop: the timer is defined at the beginning and is "armed" in setup. It is primarily responsible for calling the switch check function after the set time has expired (for 2 minutes with the standard_toilette_session variable) and to trigger an action in case the switch remains open.
The code runs without any additional libaries, but care must be taken that the instruction #include "application.h" is mandatory for the execution of the timer. Make sure that your Photon / Core is running at least with firmware version 0.4.9, as this SoftwareTimer were introduced.
Here's another challenge for the statisticians among you:
- How often was the toilet used? Any ideas for a counter?
- How long is the lid actually open? (To adjust the time for the variable standard_toilette_session)