About

Introduction

Motivation

Living in a house and sharing a bathroom with several housemates can lead to several problems. Say you sit in the kitchen and feel the urge to go to the bathroom, walk the stairs up to the second floor just to find out that the bathroom is occupied. So the first idea was to install a light in every room that lights up whenver the bathroom is occupied and thus saving a potential useless walk to the loo. Shortly after that the idea was born not only to show when the bathroom is occupied but to somehow log that information together with a timestamp to get even more information.

Goal

The goal of this project is to get an overwiew of the bathroom usage and to get an idea of the loo usage patterns. With the help of statistical analysis it should be possible to get the desired information on a mathematical foundation. The work on this project is pretty dynamic and new ideas arise all along the way.

Overview

The next picture shows a simplified diagram showing what is happening:

Overall data flow diagram

An electrical switch is attached to the bathroom's door's lock. When the door is locked the switch is closed thus closing a circuit and igniting the lights in the rooms. This information also flows to a microcontroller that registers the status change and writes this information together with a timestamp that comes from a radio controlled DCF77 clock module into a file on a USB storage. This file is being read into a database a web application server is connected with. The web application server contains all the the logic to evaluate and report the desired information.

Door lock switch and logger circuit

Hardware

The door lock switch is a pretty simple construction made of several pieces of tinfoil attached to the door locking mechanism.
The following two pictures show indicator lamps that show that the loo is occupied:
The logger circuit mainly consists of the following parts: a Schmitt trigger that converts the battery powered door lock status information signal into a well defined TTL signal, a receiver module for receiving the DCF77 atomic clock signal, a microcontroller (an Atmel AT90CAN128 in this case [No, I'm not using the CAN bus at the moment]) and an STI100 USB memory stick to serial adapter.
Loo logger circuit
The next picture shows an animated sequence of the loo looger circuit in action:

The loo logger in action

Software

The firmware for the microcontroller is written in AVR C. It consists of a main loop that polls the status of the signal the Schmitt trigger delivers (and also does some simple debouncing on that signal), an ISR for reading and decoding the time signal from the DCF77 clock module and some routines for communication with the USB module over RS232.

Evaluation / Reporting


Both evaluation and reporting is handled by a CherryPy web application server that is connected to a MySQL database.

Files

For the logging circuit diagram and AVR source files look here...

To be continued ...

Powered by: |  AVR |  AVR Libc + AVRDUDE |  Python |  CherryPy |  MochiKit |  FusionCharts |  Webfaction |  and of course Linux | 
Hosted by Webfaction