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

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
projets:fuz:presence_button [2019-11-01 23:52] – [Hardware] Lomanicprojets:fuz:presence_button [2019-11-03 17:41] – [Current status] Lomanic
Line 6: Line 6:
 </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 =====
   * some glorious esp8266 in a Sonoff S20 power plug (NodeMCU v0.9 for development)   * some glorious esp8266 in a Sonoff S20 power plug (NodeMCU v0.9 for development)
-  * another esp8266 to check when the S20 goes down (Fuz closing) 
  
 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 22: Line 16:
 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 =====
Line 53: Line 55:
   - **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</del> HTTP polling ([[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)</del>, S20-part done in [[https://github.com/Lomanic/presencebutton/commit/450fdfcddf5a187fb261470427bf255231f175d5|450fdfcddf5a187fb261470427bf255231f175d5]] 
-  - **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**
Line 63: Line 65:
  
   - 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
Line 76: Line 79:
   * [[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 =====
projets/fuz/presence_button.txt · Last modified: 2023-02-02 22:06 by 127.0.0.1