Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision |
projets:fuz:presence_button [2019-11-01 23:50] – [Current status] Lomanic | projets:fuz:presence_button [2019-11-03 18:53] – [Current status] Lomanic |
---|
</WRAP> | </WRAP> |
| |
===== What does it look like? ===== | |
| |
In the meatspace, a button sets the hackerspace in OPEN mode. It does light a 🚨 beacon 🚨 which is pretty amazing. It also makes this status available to a [[:infra:matrix|Matrix]] bot, so people around the ''fuz General'' room can !query for it. | |
| |
FIXME Unfortunately, we don't have documented this Matrix bot and its commands yet. | |
| |
===== Hardware ===== | ===== Hardware ===== |
Unplug the 3V3 VCC cable to be able to watch the serial monitor when the Sonoff is powered on through main **else you will fry the esp**. You can also flash Sonoff's esp like this (**be careful to not touch main current through the Sonoff** when manipulating it). \\ | Unplug the 3V3 VCC cable to be able to watch the serial monitor when the Sonoff is powered on through main **else you will fry the esp**. You can also flash Sonoff's esp like this (**be careful to not touch main current through the Sonoff** when manipulating it). \\ |
It also looks like when the program is of a given size, the USB/serial adapter (CH340G at least) is not able to give enough current for the esp to run properly (crashes in loop with stacktraces). An FTDI adapter looks more reliable.\\ | It also looks like when the program is of a given size, the USB/serial adapter (CH340G at least) is not able to give enough current for the esp to run properly (crashes in loop with stacktraces). An FTDI adapter looks more reliable.\\ |
You can also use ''screen /dev/ttyUSB0 115200'' to watch the serial monitor, but Arduino IDE serial monitor is more practical to use as it is relaunched each time it detects when the USB/serial adapter is plugged to a running chip. | You can also use ''screen /dev/ttyUSB0 115200'' to watch the serial monitor, but Arduino IDE serial monitor is more practical to use as it is relaunched each time it detects when the USB/serial adapter is plugged to a running chip. |
| |
| Using a FTDI as below is more practical as it's able to properly power the Sonoff S20. **Don't forget to set the jumper to 3.3V or you will fry the ESP**. |
| |
| {{:projets:fuz:presence_button:sonoff_s20_ftdi_pinout.jpg?200|}} |
| |
| ===== Software ===== |
| |
| See [[https://github.com/Lomanic/presencebutton|Lomanic/presencebutton]] on Github. |
| |
===== Roadmap ===== | ===== Roadmap ===== |
- **TODO** | - **TODO** |
- **TODO** https://github.com/esp8266/Arduino/issues/4826#issuecomment-491813938 (insecure) https://github.com/esp8266/Arduino/pull/3271/files (more secure). https://github.com/SensorsIot/HTTPS-for-Makers | - **TODO** https://github.com/esp8266/Arduino/issues/4826#issuecomment-491813938 (insecure) https://github.com/esp8266/Arduino/pull/3271/files (more secure). https://github.com/SensorsIot/HTTPS-for-Makers |
- **DOING** <del>making the S20 regularly ping a remote server. This remote server would then send a message on Matrix saying Fuz is closed if it's not ping-ed after some delay. Implementing the latter using MQTT ([[https://github.com/knolleary/pubsubclient|PubSubClient library]]).</del> simpler, have an HTTP server on the S20 indicating if the button has been pushed once, and have an always-on esp8266 poll this webserver and notify the Matrix channel and a remote server when it's gone after a few minutes. S20 webserver done in [[https://gist.github.com/Lomanic/3ac81aa6bb5ce4cdb88da3a76fe4aa1c|sonoff_s20_wifimanager_longpress_matrix_events_webserver_admin.ino]] (with an admin interface as a bonus) | - **DOING** making the S20 regularly ping a remote server. This remote server would then send a message on Matrix saying Fuz is closed if it's not ping-ed after some delay. Implementing the latter using <del>MQTT ([[https://github.com/knolleary/pubsubclient|PubSubClient library]])</del> HTTP polling. <del>simpler, have an HTTP server on the S20 indicating if the button has been pushed once, and have an always-on esp8266 poll this webserver and notify the Matrix channel and a remote server when it's gone after a few minutes. S20 webserver done in [[https://gist.github.com/Lomanic/3ac81aa6bb5ce4cdb88da3a76fe4aa1c|sonoff_s20_wifimanager_longpress_matrix_events_webserver_admin.ino]] (with an admin interface as a bonus)</del>, S20 part done in [[https://github.com/Lomanic/presencebutton/commit/450fdfcddf5a187fb261470427bf255231f175d5|450fdfcddf5a187fb261470427bf255231f175d5]], still need to find a way to reliably send a message on Matrix after a delay once on the Glitch platform as container gets killed after a while |
- **TODO** needs a publicly accessible server to serve an image/API (probably the same server as previous step), include the image/JS on fuz.re and yadda! | - **ALMOST DONE** check out [[https://github.com/Lomanic/presencebutton/commit/450fdfcddf5a187fb261470427bf255231f175d5|450fdfcddf5a187fb261470427bf255231f175d5]] and https://glitch.com/edit/#!/presence-button [[https://presence-button.glitch.me/|presence-button]] |
- ?? | - ?? |
- **TODO** | - **TODO** |
| |
- handle multiple matrix channels configured (to listen to and to reply to) | - handle multiple matrix channels configured (to listen to and to reply to) |
| - notify when the Fuz is closing |
- resolve HTTPS locally instead of relying on a HTTP/HTTPS proxy | - resolve HTTPS locally instead of relying on a HTTP/HTTPS proxy |
| |
===== Arduino sketch versions ===== | ===== Arduino sketch revisions ===== |
| |
In chronological order for a better comprehension compared to the note-taking style above | In chronological order for a better comprehension compared to the note-taking style above |
* [[https://gist.github.com/Lomanic/dba3cd9f93161cc1acc32c83197298eb|sonoff_s20_wifimanager_longpress_matrix_events.ino]] | * [[https://gist.github.com/Lomanic/dba3cd9f93161cc1acc32c83197298eb|sonoff_s20_wifimanager_longpress_matrix_events.ino]] |
* [[https://gist.github.com/Lomanic/3ac81aa6bb5ce4cdb88da3a76fe4aa1c|sonoff_s20_wifimanager_longpress_matrix_events_webserver_admin.ino]] | * [[https://gist.github.com/Lomanic/3ac81aa6bb5ce4cdb88da3a76fe4aa1c|sonoff_s20_wifimanager_longpress_matrix_events_webserver_admin.ino]] |
| |
| Subsequent versions on [[https://github.com/Lomanic/presencebutton|Github Lomanic/presencebutton]]. |
| |
===== Resources ===== | ===== Resources ===== |