User Tools

Site Tools


projets:fuz:presence_button

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

projets:fuz:presence_button [2021-02-01 19:24] – [Misc] +https://www.iot-experiments.com/esp32-warning-light/ Lomanicprojets:fuz:presence_button [2023-02-02 22:06] (current) – external edit 127.0.0.1
Line 3: Line 3:
 <WRAP round box 60%> <WRAP round box 60%>
 ===== Goals ===== ===== Goals =====
-  * Notifying that the Hackerspace is open/closed on different channels (Matrix, Fuz.re homepage), while respecting the privacy of attendants+  * Notifying that the Hackerspace is open/closed on different channels ([[:infra:Matrix]], Fuz.re homepage, wiki, [[spaceapi]]), while respecting the privacy of attendants
 </WRAP> </WRAP>
  
Line 9: Line 9:
 ===== Hardware ===== ===== Hardware =====
   * some glorious esp8266 in a [[https://sonoff.tech/product/wifi-smart-plugs/s20|Sonoff S20 power plug]] (NodeMCU v0.9 for development)   * some glorious esp8266 in a [[https://sonoff.tech/product/wifi-smart-plugs/s20|Sonoff S20 power plug]] (NodeMCU v0.9 for development)
 +  * something to turn on/off that may get attendants attention, that they would want to turn off. We chose a revolving light that we already had, an off-the-shelf lamp (like [[https://www.amazon.fr/Eurolite-060090-Police-Lumi%C3%A8re-Rouge/dp/B000TGOGRS/|this one]]) which plugs to main via the Sonoff 
  
 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 [[https://medium.com/@jeffreyroshan/flashing-a-custom-firmware-to-sonoff-wifi-switch-with-arduino-ide-402e5a2f77b|this link]] and [[http://blinkingled.cc/update-firmware-of-smart-switch-sonoff-s20/|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). 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 [[https://medium.com/@jeffreyroshan/flashing-a-custom-firmware-to-sonoff-wifi-switch-with-arduino-ide-402e5a2f77b|this link]] and [[http://blinkingled.cc/update-firmware-of-smart-switch-sonoff-s20/|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).
Line 48: Line 49:
  
   - **DONE** [[https://gist.github.com/Lomanic/1fc51b4ae0df0d69c9e994ee8d6a9cbe|sonoff_s20_blinky_led.ino]]   - **DONE** [[https://gist.github.com/Lomanic/1fc51b4ae0df0d69c9e994ee8d6a9cbe|sonoff_s20_blinky_led.ino]]
-  - **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<del> and also each time someone mentions the Matrix account on Matrix</del> ; the S20 disables the rotating light when the button is pressed+  - **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 revolving light is lightened up by the Sonoff S20 when it is powered up<del> and also each time someone mentions the Matrix account on Matrix</del> ; the S20 disables the revolving light when the button is pressed
   - **DONE** <del>[[https://gist.github.com/Lomanic/b0b5e3eba81ecdc4f3065b5b3561bc92|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)</del> Sonoff S20 is not compatible with its only 1M flash. We should solder a bigger memory.   - **DONE** <del>[[https://gist.github.com/Lomanic/b0b5e3eba81ecdc4f3065b5b3561bc92|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)</del> Sonoff S20 is not compatible with its only 1M flash. We should solder a bigger memory.
   - **DONE** Unsurprisingly, it works, see this sketch I slightly adapted [[https://gist.github.com/Lomanic/798936d9564fb5d42ee3806e15e82c2f|sonoff_s20_wifimanager_with_button_reset.ino]], next step is to try to add custom options (Matrix login and room to post to), maybe adapt <del>https://github.com/tzapu/WiFiManager/blob/368ea928f014be9c1616b1a94caf81a8971142ee/examples/OnDemandConfigPortal/OnDemandConfigPortal.ino</del> check out [[https://gist.github.com/Lomanic/e8f4938202864c7b8e6da00211c07943|sonoff_s20_wifimanager_with_custom_settings_and_led_status_and_reset_button.ino]]   - **DONE** Unsurprisingly, it works, see this sketch I slightly adapted [[https://gist.github.com/Lomanic/798936d9564fb5d42ee3806e15e82c2f|sonoff_s20_wifimanager_with_button_reset.ino]], next step is to try to add custom options (Matrix login and room to post to), maybe adapt <del>https://github.com/tzapu/WiFiManager/blob/368ea928f014be9c1616b1a94caf81a8971142ee/examples/OnDemandConfigPortal/OnDemandConfigPortal.ino</del> check out [[https://gist.github.com/Lomanic/e8f4938202864c7b8e6da00211c07943|sonoff_s20_wifimanager_with_custom_settings_and_led_status_and_reset_button.ino]]
Line 59: Line 60:
   - **DONE** 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/presence-button/commit/450fdfcddf5a187fb261470427bf255231f175d5|450fdfcddf5a187fb261470427bf255231f175d5]], server side on the Glitch platform also done (via a JSON database file as container gets killed after a while and to be able to recover after being killed)   - **DONE** 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/presence-button/commit/450fdfcddf5a187fb261470427bf255231f175d5|450fdfcddf5a187fb261470427bf255231f175d5]], server side on the Glitch platform also done (via a JSON database file as container gets killed after a while and to be able to recover after being killed)
   - **DONE** check out [[https://github.com/Lomanic/presence-button/commit/450fdfcddf5a187fb261470427bf255231f175d5|450fdfcddf5a187fb261470427bf255231f175d5]] and https://glitch.com/edit/#!/presence-button [[https://presence.fuz.re/|presence-button]], image integrated on [[https://fuz.re|fuz.re]] on 2020-10-11 by @jeanjack \o/   - **DONE** check out [[https://github.com/Lomanic/presence-button/commit/450fdfcddf5a187fb261470427bf255231f175d5|450fdfcddf5a187fb261470427bf255231f175d5]] and https://glitch.com/edit/#!/presence-button [[https://presence.fuz.re/|presence-button]], image integrated on [[https://fuz.re|fuz.re]] on 2020-10-11 by @jeanjack \o/
-  - **DONE** Unfortunately, [[https://github.com/krzychb/EspSaveCrash|EspSaveCrash]] is not able to save crash information on flash and [[https://git.interhacker.space/Lomanic/presence-button/commit/404c440ed4128d0a19e97092025c69cfb92c612e|was removed]]. We did a complete rework/simplification, where the ESP is only pinging a remote server about its state and all the logic is on this server (in the future it could even be the server that tells the ESP to turn on or off the rotating light according to what the remote server replies to the HTTP ping). @mentions handling was also removed as it's not used in [[https://github.com/Lomanic/presence-button/commit/4c74d44d02f179aed81a439ef1abf0fd14eb860c|4c74d44d02f179aed81a439ef1abf0fd14eb860c]].+  - **DONE** Unfortunately, [[https://github.com/krzychb/EspSaveCrash|EspSaveCrash]] is not able to save crash information on flash and [[https://git.interhacker.space/Lomanic/presence-button/commit/404c440ed4128d0a19e97092025c69cfb92c612e|was removed]]. We did a complete rework/simplification, where the ESP is only pinging a remote server about its state and all the logic is on this server (in the future it could even be the server that tells the ESP to turn on or off the revolving light according to what the remote server replies to the HTTP ping). @mentions handling was also removed as it's not used in [[https://github.com/Lomanic/presence-button/commit/4c74d44d02f179aed81a439ef1abf0fd14eb860c|4c74d44d02f179aed81a439ef1abf0fd14eb860c]].
   - ??   - ??
   - **DOING**, when people push the button!   - **DOING**, when people push the button!
Line 73: Line 74:
   * https://www.itead.cc/wiki/S20_Smart_Socket S20 specifications   * https://www.itead.cc/wiki/S20_Smart_Socket S20 specifications
   * https://medium.com/@jeffreyroshan/flashing-a-custom-firmware-to-sonoff-wifi-switch-with-arduino-ide-402e5a2f77b   * https://medium.com/@jeffreyroshan/flashing-a-custom-firmware-to-sonoff-wifi-switch-with-arduino-ide-402e5a2f77b
-  * https://notenoughtech.com/category/home-automation/esp/ really great website about esp-based intelligent shits+  * https://notenoughtech.com/category/home-automation/esp/ really great website about esp-based smart shits
   * http://www.martyncurrey.com/category/esp8266/ nice little series of tutorials, may be obsolete   * http://www.martyncurrey.com/category/esp8266/ nice little series of tutorials, may be obsolete
   * https://diyprojects.io/hack-connected-sonoff-s20-plug-esp-easy-rules/ interesting part here is the hardware mod with a 3.5 mm jack used to connect the pins without opening the Sonoff case   * https://diyprojects.io/hack-connected-sonoff-s20-plug-esp-easy-rules/ interesting part here is the hardware mod with a 3.5 mm jack used to connect the pins without opening the Sonoff case
   * https://www.letscontrolit.com/forum/viewtopic.php?t=3263#p17124 GPIO15 physical location on Sonoff S20 PCB   * https://www.letscontrolit.com/forum/viewtopic.php?t=3263#p17124 GPIO15 physical location on Sonoff S20 PCB
-  * http://blog.zener.free.fr/index.php?post/2018/10/07/ESPEasy-et-le-Sonoff-S26 (french) how to flash Sonoff S26+  * http://blog.zener.free.fr/index.php?post/2018/10/07/ESPEasy-et-le-Sonoff-S26 (French) how to flash Sonoff S26
  
 ==== Misc ==== ==== Misc ====
projets/fuz/presence_button.1612207440.txt.gz · Last modified: 2023-02-02 22:06 (external edit)