venerdì 1 ottobre 2010

CessLight - Part 2 - How it works

Here I describe my current implementation of CessLight. It has been tailored to my needs, so the number of red lights and the logic to check room engagement.
If you want to use it for your needs, it is likely you will have to modify the hardware and/or the software.

This is my workplace restroom (I think it is a very common arrangement). It is compound by:
  1. A common room with one sink, that is the main entry to the toilets.
  2. A room for the man's toilet.
  3. A room for the woman's toilet.
My restroom
I want to check them separately: I want to know whether the man's, the woman's or the common room are engaged. Let us call them, respectively, M, W and C.
Let us call their doors, respectively, Md, Wd and Cd.

This led me to put three red lights: M, W and C, as shown here:
CessLight's LEDs, buzzer and connector
Please note that this is a prototype and is still experimental. Sometimes I modify the circuit by adding components to test new features. This is why it is built on a stripboard and looks very ugly.
And yes: the green LEDs are fake: I did not have the time to make a shot showing all the LEDs on!

Problem 1: How can you determine if there is someone in M or W?
Currently I solved this by magnetic contact sensors, the one used for home anti-theft devices:
A very common magnetic contact.

Logic is very simple: M is engaged if and only if Md sensor is triggered (also apply to W).
For this reason, the door of M or W must be kept close if and only if there is someone inside.
This logic has a drawback: when you are in you usually keep the door closed. But keeping the door open  when nobody is in is not a generally accepted behavior. A lot of people would find this an impolite practice.

More advanced solution can be found. I decided to replace this with another method, but I will uncover this later. The point to me is that this is the cheapest solution.

Let us call the two sensors Mm (Man magnetic contact) and Wm (Woman magnetic contact).


Problem 2: How can you determine if there is someone in C?
I did not want to use the aforementioned approach for C. This is because usually a bathroom door is kept closed at any time, except to enter and exit, of course.
Since I had a spare infrared sensor, I decided to use it for this purpose:
A Passive InfraRed (PIR) sensor.
This is the logic: C is engaged if and only if its PIR sensor is triggered.
Let us call this Cp (Common PIR sensor).
Rationale: if there is someone in C, she should be moving, triggering Cp. Again, this have a drawback: sometimes one moves very little (e.g. while brushing her teeth) and this causes C to appear disengaged. 
Even at maximum sensitivity, such sensors are not able to read small movements, because they work by measuring differences of IR detected by two adjacent regions.
One thing I did to mitigate this is to add a monostable timer to the sensor: C red light will be off only five seconds after the sensor is no more triggered.
This was applied to Mm and Wm sensor as well. See Lights Logic.

Again, there is a better (and more costly) solution I plan to adopt. But I will reveal it only after having tested it.

Problem 3: How can you determine if there is a bad smell in the bathroom?
This is a very nice feature and not really easy to implement.
I searched for some information about this topic on the Internet and I could not find enough.
Maybe I missed something important. If you know a better way to do so, please contact me.

In Odor-Based Incontinence Sensor they used an array of 4 gas sensors (targeted at different gases).
I copied the idea by using two gas sensors: Figaro TGS 2602 (air contaminants) and Figaro TGS 2611 (methane). Both of them make sense, since methane is often present in human "back-produced" bad smell (someone told me that only 33% of men produce methane, but my statistic are about 90%). 
Let us call them Go (Gas sensor: organic) and Gm (Gas sensor: methane).
I have been testing them for two weeks. They proved to be sensitive to the substances of the bad small. 
Unfortunately, the air contaminants sensor is too much sensitive to alcohol. This means that is triggered by just ashing your hands with the hygienic products that are in fashion after Avian influenza.

I decided to employ two different sensors also to have a better filter over false positives. I am currently experimenting them in my restroom in order to find an algorithm to better discriminate between good and bad smells. Currently CessLight turns yellow light on if one of the two sensor reports a value above a predefined threshold (respectively To and Tm). This gives a lot of false positives and negatives. I definitely have to improve it.


Installation
This is how I installed it in the restroom:
CessLight connections


Lights Logic
This is very simple:
  1. M light is on if Mm is closed.
  2. M light is off five seconds after Mm is open.
  3. W light is on if Wm is closed.
  4. W light is off five seconds after Wm is open.
  5. C light is on if Cp reads a movement.
  6. C light is off five seconds after Cp does not read a movement anymore.
  7. Green light is on if and only if no red light is on.
  8. Yellow light is on if and only if (Go>To or Gm>Tm)
Points 2 and 4 are to allow stepping from M to C or from W to C without turning the green light on.
Otherwise, when a man exits M (or a woman exits W) the M red light immediately turns off but C red light is not still on because he has to intercept one of the rays of the PIR sensor.
This would turn the green light on for some seconds and has been perfectly eliminated by the 5 seconds timeout.

martedì 28 settembre 2010

CessLight

CessLight: The first Bathroom Traffic Lights ever built (at least by me)
Now with Odor Control
Sorry for the orrendous photo. It's the first time I shoot an electronic circuit.
What is CessLight?
CessLight is a bathroom (water closet room) traffic lights equipment.
It signals when the bathroom is engaged and when it is free. Ok, this is pretty obvious.

What is specially suited for?
It has been specifically designed to be used in a workplace, especially if the work is carried through computers.
In fact, it supports three restrooms (the common entry room, with a sink and a mirror, the man's toilet and the woman's toilet).
It can send such information to all PCs in the workplace, so that you can know when it is time to go to the toilet without moving your eyes from your work.

Why this name?
Cess from Italian word "cesso" (colloquial), that means both bathroom and water closet.
Light from "traffic lights". Don't know why ;-)

What makes CessLight different from any other similar product (at least the ones I know)?
  1. It has three red lights.
    Ok, this is very specific to my restroom: it is compound by a central room with a sink that allows entry in two lateral rooms (man WC room and woman one). Each red light signals that the corresponding room is engaged. The lateral rooms have an opening in the upper area of the walls so that air can flow from them to common room. So standing in the common room while someone is in a lateral room tamper that man's privacy (odors, noises, etc).
    So you can decide to enter the central room if you are a man and there is a man in its lateral room but not if there is a woman. Well, sort of.

  2. It has a green light that is on only when all the three rooms are free:

    Frew way!
  3. Last light but not least, it has a yellow light for "hazardous gases" alarm!
    The idea is to signal when the air in the restroom smell likes fresh roses or...rotten roses :-o

  4. It sends updates of its status to PC clients via Ethernet connection.
    Why? So we don't have to raise our eyes from our computer or turn the head to look backward (for those who have CessLight behind them).

  5. It is built upon Arduino.
    And this is really geeky, at the moment...
That's all for now. More about it later. Stay tuned!