Hackerspace Open Switch

From Hive13 Wiki
Revision as of 16:20, 11 August 2020 by Aeonsablaze (talk | contribs) (Updated for switch rebuild/rewrite)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Hive13 Project
Hackerspace Open Switch
Status: Active
Project Owner: Ian Blais
Project Location: One A Column By The Door
Where to contribute: https://github.com/Hive13/openswitch
Start Date: 12/04/2010



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.

This project has been suspended until we get one of the smaller LED displays working to a degree that we can interface it with other projects.

Project Manager


  • 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 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
  • It also logs the current temperature to the database every five minutes.

Project Details

GitHub for the source code: https://github.com/Hive13/openswitch

The 'Door Switch' or 'Is the Hackerspace Open?' switch has two main software components:

  1. The microcontroller client code.
  2. The webserver database and webpages.

The Microcontroller

The Electrical Components

  1. A standard light switch
  2. An Arduino Mega with POE Ethernet Board

The Code

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.

Light Status Codes

  • Waiting for response: Both LEDs solid
  • Cannot contact the network: Alternating blink of both LEDs
  • Cannot reach server: Simultaneous blink of both LEDS

The Web Server

The webserver contains several parts:

  1. A MySQL database with a 'doorEvents' table.
  2. The logger.php page which accepts 'get' requests from client.
  3. The checkStatus.php which polls the database for the current door status.
  4. An index.html which uses javascript to refresh the icon when the status changes.

Work Log

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

Sometime in 2016 - Re-implemented on ESP8266

Re-wrote the code nearly from scratch. Now works wirelessly and recovers from power loss gracefully.

December 4, 2017 - Updated code finally added to github

Yeah, it took a while. Deal with it.

August 11, 2020 - Rebuilt and rewritten

For reasons best left to the mists of irritation, the switch has now been rebuilt to run on ethernet again, this time powered by POE. The code has been re-written more or less from scratch (admittedly with a bit of copy/paste from the old code). It is now a billion times more responsive, updates the website instantaneously and has several different LED blinking patterns to indicate problems.