User Tools

Site Tools


projets:fuz:presence_button

This is an old revision of the document!


Presence button

Goals

  • Notifying that the Hackerspace is open on different channels (Matrix, Fuz.re homepage), while respecting the privacy of attendants

Hardware

  • some glorious esp8266 in a Sonoff S20 power plug (NodeMCU v0.9 for development)

To flash a Sonoff S20, solder the pins on the left of the push button, connect your USB-to-Serial convertor (RobotDyn CH340G in this case) to the headers like in the image below (from top to bottom, GND, TX, RX, 3.3v VCC), push Sonoff button while plugging in your USB-to-Serial convertor in your PC and then release the push button after a few seconds (check out this link and that one). Don't forget about the SPIFFS setting in Arduino IDE as we are using it to store custom settings via WifiManager (see step 6 below).

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 is not able to give enough current for the esp to run properly (crashes in loop with stacktraces).
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.

Roadmap

  1. make the LED blink (GPIO 13 is the green LED, not 12 as it's the relay and blue LED)
  2. define how to detect the Fuz is open
  3. check out ArduinoOTA or similar for easy iterations
  4. connect to Fuz WiFi, would be great to use https://github.com/tzapu/WiFiManager
  5. send (reply?) message on Matrix (work is already done)
  6. make things easily configurable via internal webserver (WiFi, Matrix login/channel/message). I think tzapu/WiFiManager is able to do that, check out examples
  7. react to @mentions on Matrix
  8. handle long press for reset
  9. handle multiple Matrix rooms
  10. resolve HTTPS on the esp8266 directly
  11. properly notify when the Fuz is closed
  12. notify if the Fuz is open or closed on https://fuz.re
  13. ??
  14. profit!

Current status

  1. DONE the Fuz is open when there is electricity in the basement and someone pushes the button. Someone wants to push the button because the rotating light is lightened up by the Sonoff S20 when it is powered up and also each time someone mentions the Matrix account on Matrix ; the S20 disables the rotating light when the button is pressed
  2. DONE sonoff_s20_wifimanager_with_custom_settings_and_led_status_and_reset_button_and_aruinoota_and_matrix_message.ino, in case of Authenticating…FAIL 18:43:52 [ERROR]: ERR: ERROR[4]: Not Enough Space :-(https://www.esp8266.com/viewtopic.php?f=32&t=19064#p80107 (see also step 6) Sonoff S20 is not compatible with its only 1M flash
  3. DOING, currently struggling with HTTPS, try using httpUpdateSecure.ino (includes some NTP!!, see also esp8266/Arduino#4749 as it's not instant) or BearSSL_CertStore.ino DONE (HTTP only through proxy though)! See sonoff_s20_wifimanager_with_custom_settings_and_led_status_and_reset_button_and_matrix_message.ino
  4. DONE Yup sonoff_s20_wifimanager_with_custom_settings_and_led_status_and_reset_button.ino, but you have to properly set up your Arduino IDE like this
  5. DONE following matrix-esp8266.ino#L70-L109 sonoff_s20_multiwifi_matrix_events.ino (maybe implement read receipts so even if nobody mentions the Matrix account, we see it running)
  6. DONE (only useful when using WifiManager) sonoff_s20_wifimanager_longpress_matrix_events.ino
  7. TODO
  8. TODO thinking about starting a webserver + mDNS on the esp with another machine (always up) checking its status ; or the other way, having the S20 regularly ping-ing 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. Will implement the latter
  9. 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!
  10. ??
  11. TODO

Today the elementary functionalities described in step 2 are implemented sonoff_s20_wifimanager_longpress_matrix_events.ino.

Next steps:

  1. handle multiple matrix channels configured (to listen to and to reply to)
  2. resolve HTTPS locally instead of relying on a HTTP/HTTPS proxy

Arduino sketch versions

Resources

projets/fuz/presence_button.1570029719.txt.gz · Last modified: 2023-02-02 22:06 (external edit)