Projects/OpenBot: Difference between revisions

From Leeds Hackspace Wiki
Jump to navigation Jump to search
mNo edit summary
m (Add slack integration)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:In_Progress|OpenBot]]
[[Category:In_Progress|OpenBot]]
 
[[File:OpenBot-v2.jpeg|200px|thumb|right|The current OpenBot]]
[[File:Openbot-mdf.jpeg|200px|thumb|right|The larval form of OpenBot]]
[[File:InsideOpenBotv2.jpeg|200px|thumb|right|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. It is temporarily housed within small MDF box with a large aluminium knob, an LED, a button and a power cable attached.
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 [https://makehackvoid.com/projects/space-probe/ Space Probe] and can be found on Twitter as [https://twitter.com/LHSOpenBot @LHSOpenBot].
It is inspired by MakeHackVoid's [https://makehackvoid.com/projects/space-probe/ Space Probe] and can be found on Twitter as [https://twitter.com/LHSOpenBot @LHSOpenBot].


[https://github.com/adnbr/OpenBot Code is available on GitHub.]
==Instructions for use==
==Instructions for use==


Line 12: Line 13:


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.
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==
==About the device==
[[File:OpenBotIntent.png|200px|thumb|right|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 [[https://thingspeak.com/ 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 [[User:Ad|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 [http://api.thingspeak.com/channels/81854/feed/last.json return the latest post], and another which will return [http://api.thingspeak.com/channels/81854/feed.json more information] about the feed.
For more information about the feeds see the [https://uk.mathworks.com/help/thingspeak/get-a-channel-feed.html ThingSpeak documentation].
The latest post feed takes the following form:


It's under development at the moment - please keep that in mind. A new enclosure is being designed as we speak. For the mean time though use it, see what works, what doesn't and let Aidan know your thoughts.
  {
    "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
  }


Everything runs on an ESP8266 pushing data over the wifi to [[https://thingspeak.com/ ThingSpeak]], which tweets for us. The number selected on the knob and the estimated time of closing is stored on (web people, ask Aidan for an API key if you want it.)
{| class="wikitable"
! style="font-weight: bold;" | JSON
! style="font-weight: bold;" | Name
! style="font-weight: bold;" | Example/Range
! style="font-weight: bold;" | Notes
|-
| style="font-weight: bold;" | created_at
|
| 2016-02-18T11:54:12Z
| ThingSpeak generated field, UTC time at server
|-
| style="font-weight: bold;" | entry_id
|
|
| ThingSpeak generated field, unique ID for entry.
|-
| style="font-weight: bold;" | field1
| hours
| 0-8
| Hours the space will be open, 0 is closed. Reflects the position of the knob/dial.
|-
| style="font-weight: bold;" | 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.
|-
| style="font-weight: bold;" | 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 [https://twitter.com/LHSOpenBot @LHSOpenBot].
|-
| style="font-weight: bold;" | field4
| localutc
|
| Time in seconds since 1st Jan 1970. For debugging.
|}


Eventually the knob (which is a motorised potentiometer) will slowly tick down as the time goes by, but I'll get to that later right after I've made the source code less embarrassing and more robust.
==Previous Incarnations==
[[File:Openbot-mdf.jpeg|200px|thumb|left|The larval form of OpenBot with disgraceful MDF box.]]

Latest revision as of 17:30, 9 September 2016

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.