Hackerspace Open Switch
Property "ProjectImage" (as page type) with input value "Image:Open.png|240px" contains invalid characters or is incomplete and therefore can cause unexpected results during a query or annotation process.
|Hackerspace Open Switch|
|Start Date: 12/04/2010|
- 1 Overview
- 2 Project Details
- 3 Gallery
- 4 Work Log
This project allows members at the HIVE13 space to indicate when someone is there and when the last person leaves. Ideally this will increase the activity at the HIVE since other members are more likely to drop by when they know stuff is going on in the space.
- Add yourself here if you have contributed to this project.
Goal of the Project
Since the kickoff of the Hive13 hackerspace we have talked about how cool it would be to have a way to alert other people that the hackerspace was currently populated with people. We tossed around ideas from the absurd to the mundane, but it always stayed at the theoretical level. The more I thought about it I realized I had all the components needed to implement it, and if it was overkill, who the **** cares. We can either keep talking about how cool it is, or someone can get off their arse and do it.
What needs to be done
- Refactor the code to use a common MySQL connection setup routine.
- Refactor the code to be more consistent.
- Add a 'stale data' warning to the display page at http://www.hive13.org/isOpen if the switch has not changed states in over 6 hours.
- Figure out a way to grab a webcam image of the person who flipped the switch.
- Add an RSS feed to the data to allow for easy hooking into the data from other programs. *Cough* IRC Bot *Cough*
- Tweet the status change to our Twitter account
What has been done
- Arduino w/ Ethernet Shield sends "GET" request to PHP web page which enters a 'Door Event' into the database which is polled by another web page to determine if the hackerspace is open or closed.
- It works: http://www.hive13.org/isOpen
GitHub for the source code: https://github.com/Hive13/openswitch
The 'Door Switch' or 'Is the Hackerspace Open?' switch has two main software components:
- The microcontroller client code.
- The webserver database and webpages.
The Electrical Components
- A standard light switch
- An Arduino clone a Diavolino
- An Arduino Ethernet Shield
- The linked version is lightly newer, current version does not have the Micro-SD card adaptor.
The code is based off of the Arduino Ethernet Shield example code for a web client. The micro remembers the last state of the switch, when the state changes it sends out an HTTP 'GET' request to the webserver to 'isOpen/logger.php?switch=[0|1]'. A switch state of '0' means the hackerspace is closed, a switch state of '1' means the hackerspace is open.
The Web Server
The webserver contains several parts:
- A MySQL database with a 'doorEvents' table.
- The logger.php page which accepts 'get' requests from client.
- The checkStatus.php which polls the database for the current door status.
This is a living log of work that has been completed on the machine.
December 4, 2010 - Started Project
Installed Diavolino & Ethernet shield in the project case (A 2x light switch wall mount w/ one lightswitch). Also did some basic tests with how to configure the Arduino software for the Ethernet Shield. At this point I am planning on having a website poll the arduino for changes to the switch.
December 7, 2010 - Arduino Coding
Followed Craig's suggestion to instead use the Arduino as a web-client and do 'HTTP GET' requests to a php webpage. I was able to get this working, woohoo!
December 11, 2010 - IT WORKS!
Spent several hours working with Craig to get the MySQL database set up along with a series of PHP and HTML webpages that poll the database for changes to the "Hive13 Open Status" in the database. View the live data at: http://www.hive13.org/isOpen