Welcome to Atalasoft Community Sign in | Help

Making Office Life Better One Bathroom at a Time

Christina, our head of the Ministry of Culture, had a complaint at lunchtime one day: nearing the end of her second trimester of pregnancy, she was getting more and more frustrated having to walk across the office only to find out that the bathroom was already occupied.  Several of the engineers present discussed ways of solving this problem using or misusing technology.  There are several ways to do this, most of which involve switches and some kind of remote monitoring software.

I decided that this task would be best done with an Arduino with an Ethernet Shield.  Essentially, the Arduino would be acting as a web server for the door state.  I priced it out and sent Christina a parts list for the prototype: the Arduino boards from EIO and a magnetic switch from All Electronics.  I magnanimously donated a 10K resistor and other implements of destruction.  I set aside a few hours on a Friday afternoon and knocked this together:



The code running on the Arduino is this:

void loop()
  buttonState = digitalRead(buttonPin);
  // listen for incoming clients
  Client client = server.available();
  if (client) {
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        if (c == '\n' && currentLineIsBlank) {
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          if (buttonState == HIGH)
        if (c == '\n') {
          currentLineIsBlank = true;
        else if (c != '\r') {
          currentLineIsBlank = false;
    // give the web browser time to receive the data
    // close the connection:

Once the bench prototype was working, I mounted it into a project box and with the help of Jay, installed it in our server room.


image Total cost: about $100, not including my time.  It’s already paid off in terms of laughter and people trying the door and mashing on F5 to see if it works as advertised, which it does:


I love my job.

Published Monday, March 14, 2011 3:26 PM by Steve Hawley


Monday, March 14, 2011 4:16 PM by Atalasoft Office Blog

# The Luckiest Girl in the World

A couple of weeks ago, I started complaining. I complain a lot these days. You see, I’m about 7 months

Anonymous comments are disabled