Detect Occupied Toilet

I’d like to be able to detect a person sitting on a toilet in one of my bathrooms. As a result of someone going #2 (perhaps, sitting for more than 1 minute…or whatever) send a signal to my Zwave controlled exhaust fan to turn on. At that point, detect when the person leaves the toilet and turn fan off, say 15 minutes later (or 45 minutes later for some of my ‘bigger’ friends. : )

The question is really about the IR sensor that is needed to detect a person sitting on the toilet…just like automatic urinals and toilets in restaurants and offices. I’m just looking to get the notifications from an IR sensor to my Zwave controller, so IR -->Zwave. Are there any known IR devices that exist for this? Am I looking at an Arduino or Rasberri Pi project?

PS: I’ve been using OpenHab for a while and think it’s amazing so just a quick thank you to all the maintainers out there.

You could use an ESP8266 with a proximity sensor (Ultrasound) and send MQTT payloads to openHAB

1 Like

You can use any ZWave motion detector such as a Fibaro FGMS. In case your fan actuator has a spare input contact, you could get away without anotherr ZWave device. Simply attach any classic wired motion detector there.

1 Like

Motion, alone, will not suffice though. Motion will only tell me if someone enters the bathroom. I don’t want to kick the fan on if someone enters to simply wash their hands, get a towel, do #1…etc. I want to determine if someone is sitting on the toilet for a particular amount of time. Once I get that signal to my zwave network, I’ll simply turn the fan on, which will be controlled by a zwave switch.

Most if not all motion detectors are IR detectors, so they provide the same kind of detection. With a FGMS, you can set a sensitivity and a number of moves required to be seen before it’s signalling presence. It’s battery powered so you can place it anywhere such that it only watches the relevant area.
Plus, you can persist the data and activate your fan only if you’ve detected presence n times in a row or for a period of 1 minute orwhatever is appropriate.

1 Like

I also suggest what vzorglub wrote.
It’s the cheapest solution and does exactly what you need.
Use an ESP8266 which is a WiFi connected microcontroller (~3€ on AliExpress) and an ultrasonic distance sensor (~1€).
Put some code on it that sends an MQTT message to openhab if and only if the distance measured is below let’s say 1m for longer than 2 minutes or so (assuming the sensor is mounted near the toilet so it will read more than 1m if the toilet isn’t occupied.
Even better: send out the message after the sensor reads „toilet free again“ and send the occupation time.
Based on that message put a rule that decides if and maybe also how long the fan should run.
As I like your crazy idea I would also suggest to buy one of those automatic scent sprayers that are usually activated by a change of light/motion, and disconnect the sensor and instead connect it to one of the unused I/O Pins of the ESP8266. The ESP8266 listens on a MQTT channel and if your rule in openhab decides based on occupation time that it may be useful you send out a message from openhab that causes the sprayer to activate. Depending on the habits of your „bigger“ friends you could also determine upon occupation time who was there and install multiple scent sprayers with different scents - or put up a small screen - let’s say 50inch - that shows a chart of personalized occupation percentage or let’s say a highscore. I‘d love to see that - but maybe for the beginning you’ll be fine with that one ultrasonic sensor and the fan.
I suggest to use a Wemos D1 Mini (it has esp8266 on it) as it already comes breadboard-friendly and with USB for power and flashing.
There are also Wemos D1 Mini lite which are even cheaper (~1,60€) which habe less memory but still enough for your project. But for those you have to do some work to add them to Arduino IDE for programming, so if you never used such thing before I’d rather choose the standard one as the can be programmed out-of-the-box.

1 Like

Thanks all for the info, much appreciated. I think I have enough to go on. I’ll post my final solution when it’s done.

Just for completeness (and fun) I want to report that I tried to do exactly this using a MQ-4 Methane sensor and I failed miserably. The biggest problem was that it was not easy to determine when somebody did #2. The methane measurement was affected by humidity and whether the windows on the bathroom were already open or not (i.e. natural ventilation)… In very few occasions a “big #2” would score a number above 100 (0-1024)… :slight_smile:

Good luck with your approach



Matias, very interesting…didn’t really consider this approach since I assumed the sensitivity of these cheap little sensors would not be tuned to detect a #2 (vice an actual natural gas leak or something). I have no windows in the bathroom in question and it’s a climate controlled area, do you feel this could work for my case? Not sure if you took any metrics on the actual sensitivity of the MQ-4 or other sensors.

I got this idea from people that have used this sensor to “measure farting”. My, not very scientific, conclusion is that if the sensor spikes you can assume #2, but it will not spike every time somebody uses the toilet.

Sorry for not being able to provide more guidance


I’m doing a similar thing for our showers, sensors on the hot pipe and the shower outlet pipe is how I have done it and it auto activates the fan to remove steam. Will look at toilet too at some stage and it would be possible to also use a sensor on the water pipe or inside the cistern to detect which button is pushed for dual flush toilets. Our toilets do a half or a full flush.

Just for further completeness - and assuming you can physically lift the bowl up temporarily for fitting of… you could install a loadcell under the bowl and then you can monitor everything - and then adjust fan-on time based on that :wink:

Might need a little engi-nerd-ing but a wifi esp and the loadcell to send mqtt… add a display for “before and after” comparisons too might be interesting “feedback”.

Just a thought :wink:

1 Like

Fwiw: I have installed an eBay water meter on my shower outlet pipe. I can measure the litres/min (12/min) and when I see it spin, I start a timer, after 5 mins it it starts to beep… annoyingly.
Our water bills have never been so low (teenagers!!)

Iv also threatened to install a valve on the hot water line… if time > 6, valve turns off = cold shower!
(Yes, wife is not impressed with that idea)

1 Like


very interesting - can you please share which components you used for your solution?

Ntc thermistors glued onto the copper pipe cost is dirt cheap then I am still yet to do the pcb for the other end which I have heaps of boards I have designed for other uses that I can adapt in a few hours, I just need more time to finish that one off. Doing all the building work myself so it is already many years into this with heaps of loose ends to finish.