Projects:Spacestate: verschil tussen versies

Uit Hackerspace Nijmegen Wiki
Naar navigatie springen Naar zoeken springen
Geen bewerkingssamenvatting
Geen bewerkingssamenvatting
Regel 9: Regel 9:
=Spacestate Switch=
=Spacestate Switch=


[[Bestand:Spacestate-measure.jpg|miniatuur|267x267px|State measurement wires. Green = GND, connected to the bottom of the state switch. Yellow is where the Arduino measures, connected to the top of the state switch and with an internal pull-up resistor.]]
[[Bestand:Spacestate-measure.jpg|miniatuur|267x267px|State measurement wires. Green = GND, connected to the bottom of the state switch. Yellow is where the Arduino measures, connected to the top of the state switch and with an internal pull-up resistor. Also, in the top left of the picture, one of the two LED drivers is visible.]]


The Spacestate Switch was never documented, so this is an attempt to reverse engineer it. The physical device above was donated by SA007 (I think), and the controller was developed by Themba. I don't know whether there are still any copies of the source code.
The Spacestate Switch was never documented, so this is an attempt to reverse engineer it. The physical device above was donated by SA007 (I think), and the controller was developed by Themba. I don't know whether there are still any copies of the source code.

Versie van 29 okt 2022 13:55

This is our Spacestate Switch. It's currently red, indicating that the space is closed.

Hackerspace Nijmegen joins in a worldwide collaboration between hackerspaces to publish their Space State, i.e. whether they are open or not, in a standardized format.

The URL where we publish the Hackerspace Nijmegen Spacestate is https://hackerspacenijmegen.nl/state/state.json.

Spacestate Switch

State measurement wires. Green = GND, connected to the bottom of the state switch. Yellow is where the Arduino measures, connected to the top of the state switch and with an internal pull-up resistor. Also, in the top left of the picture, one of the two LED drivers is visible.

The Spacestate Switch was never documented, so this is an attempt to reverse engineer it. The physical device above was donated by SA007 (I think), and the controller was developed by Themba. I don't know whether there are still any copies of the source code.

The controller is powered by an Arduino Nano, which measures whether the huge switch is turned off or on, and communicates it to the LED controllers and via USB serial to the barcomputer (barometer) by sending "OPEN\n" or "CLOSED\n".

Originally the Arduino Nano was powered by its USB connection, but it's connected via a very long USB cable and the range extenders are iffy, so it receives only ~3.8V over USB. Therefore, the Arduino is now powered from the LED board (~10V) through its Vin port, where a linear regulator transforms it to 5V (or it should, but it actually seems to produce 6V for some reason).

The state of the switch is measured by pulling the bottom to ground (green wire in the image to the right), and then measuring the voltage at the top using the D5 pin with an internal pull-up (yellow wire). This will be ground when the space is OPEN (the two sides connect), and internal pull-up when the space is CLOSED.

Then, the D2/D4/D5 control the LEDs in such a way that they switch colors using some nice animation when the state changes.

Spacestate publishing

The bar computer (barometer) runs a `screen` session running `scripts/serial2irc.py` which is online as an IRC bot, and listens to the serial port. When it receives "OPEN\n" or "CLOSED\n", it prints the relevant message as a NOTICE to the IRC channel. Also, it calls the shell script which publishes to the website.

The shell script produces the JSON from its arguments and uploads it to the website. The last JSON uploaded is available at `scripts/state.json`.

The Wiki contains a small piece of Javascript which pulls the space state from the URL above, and adds one of two PNGs below the logo: https://hackerspacenijmegen.nl/state/wiki-state.js