Projects/OpenBot

From Leeds Hackspace Wiki
Jump to navigation Jump to search
The current OpenBot
Inside the case. It's not very interesting.

OpenBot is a device that will tweet how long the space is expected to be open for. Use it to announce to members how long the space will be open for. It is currently a mishmash of aluminium and laser cut MDF. The LED has retreated temporarily to the base, but will be returning to prominence soon!

It is inspired by MakeHackVoid's Space Probe and can be found on Twitter as @LHSOpenBot.

Code is available on GitHub.

Instructions for use

  • Turn the knob to indicate the number of hours you think you will be in the space.
  • Press the button to tweet this on @LHSOpenBot.

This doesn't replace the "Open to Members" and "Empty" notes on the website but rather complements it. If you are making a special journey and you don't have keyholder access make sure someone will be around when you arrive: use IRC, the mailing list or the Hackphone.

To provide a tidy announcement the time is rounded down to the nearest quarter hour.

About the device

The intended end result.

It's under development at the moment - please keep that in mind.

A NodeMCU dev board/ESP8266 runs Arduino code, pushing data over the wifi to [ThingSpeak], which subsequently tweets for us. The number selected on the knob and the estimated time of closing is stored on Thingspeak (web people, ask Aidan for an API key if you want one.)

NTP

At boot and every 720 minutes thereafter the time is updated from one of two NTP servers. The on-board oscillator is accurate enough to stay reasonably in sync over this period of time, after all it's not that important the time is that precise. In the event that synchronisation with NTP services cannot occur but the device can still connect to ThingSpeak and thus tweet, messages will be appended with #ntpfailure to prompt investigation.

The two services are at pool.ntp.org.uk and time.nist.gov.

Motorised Potentiometer

Eventually the knob (which is a motorised potentiometer) will slowly tick down as the time goes by. I'm looking for a suitable H-bridge or similar to facilitate this.

Connection to Slack

ThingSpeak is used to trigger a Slack notification whenever the button is pressed. This is achieved using the ThingHTTP "App" on the Thingspeak website to send a json parcel to the Slack Incoming Webhook - talk to a Slack Administrator if you need access to this.

 {
   "username":"OpenBot",
   "icon_emoji":":timer_clock:",
   "text":"%%channel_81854_field_3%%"
 }

API Output

The ThingSpeak channel has a JSON feed which will return the latest post, and another which will return more information about the feed.

For more information about the feeds see the ThingSpeak documentation.

The latest post feed takes the following form:

 {
   "created_at": "2016-02-18T11:54:12Z",
   "entry_id": 42,
   "field1": "1",
   "field2": "07:39",
   "field3": "Hackspace! Open to members! For approximately an hour! (Until ~08:30)",
   "field4": null
 }
JSON Name Example/Range Notes
created_at 2016-02-18T11:54:12Z ThingSpeak generated field, UTC time at server
entry_id ThingSpeak generated field, unique ID for entry.
field1 hours 0-8 Hours the space will be open, 0 is closed. Reflects the position of the knob/dial.
field2 until 07:30 The time the space will be expected to close. If prefixed with ERR: then an error report follows in the message field. This should not be shown to the end user. If this field is solely #ntpfailure then the NTP sync has failed and the device is in a failure mode.
field3 message Hackspace! Open to members! For approximately an hour! (Until ~08:30) If field2 does not contain an error message this is what has been tweeted to @LHSOpenBot.
field4 localutc Time in seconds since 1st Jan 1970. For debugging.

Previous Incarnations

The larval form of OpenBot with disgraceful MDF box.