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 revision Previous revision
Next revision
Previous revision
projets:fuz:presence_button [2019/11/02 01:57]
lomanic [Current status]
projets:fuz:presence_button [2019/11/03 19:53] (current)
lomanic [Current status]
Line 9: Line 9:
 ===== 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 21:
  
 {{:​projets:​fuz:​presence_button:​sonoff_s20_ftdi_pinout.jpg?​200|}} {{:​projets:​fuz:​presence_button:​sonoff_s20_ftdi_pinout.jpg?​200|}}
 +
 +===== Software =====
 +
 +See [[https://​github.com/​Lomanic/​presencebutton|Lomanic/​presencebutton]] on Github.
  
 ===== Roadmap ===== ===== Roadmap =====
Line 52: 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 ([[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**
Line 65: Line 68:
   - 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.1572656255.txt.gz · Last modified: 2019/11/02 01:57 by lomanic