{"action":"created","issue":{"url":"https://api.github.com/repos/chaeplin/esp8266_and_arduino/issues/37","repository_url":"https://api.github.com/repos/chaeplin/esp8266_and_arduino","labels_url":"https://api.github.com/repos/chaeplin/esp8266_and_arduino/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/chaeplin/esp8266_and_arduino/issues/37/comments","events_url":"https://api.github.com/repos/chaeplin/esp8266_and_arduino/issues/37/events","html_url":"https://github.com/chaeplin/esp8266_and_arduino/issues/37","id":187532277,"number":37,"title":"Wake up triggered by either the RTC or a momentary switch?","user":{"login":"kentaylor","id":339520,"avatar_url":"https://avatars.githubusercontent.com/u/339520?v=3","gravatar_id":"","url":"https://api.github.com/users/kentaylor","html_url":"https://github.com/kentaylor","followers_url":"https://api.github.com/users/kentaylor/followers","following_url":"https://api.github.com/users/kentaylor/following{/other_user}","gists_url":"https://api.github.com/users/kentaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/kentaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kentaylor/subscriptions","organizations_url":"https://api.github.com/users/kentaylor/orgs","repos_url":"https://api.github.com/users/kentaylor/repos","events_url":"https://api.github.com/users/kentaylor/events{/privacy}","received_events_url":"https://api.github.com/users/kentaylor/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-06T00:05:17Z","updated_at":"2016-11-07T08:53:20Z","closed_at":null,"body":"Thanks for providing this information, circuit, videos and explanation at http://chaeplin.github.io/project-01-button.html. \r\n\r\nIt can detect the momentary switch while awake which is nice but as far as I can tell it is not suitable for the case described by @me-no-dev at https://github.com/esp8266/Arduino/issues/1488#issuecomment-174268749 where the ESP wake up from deep sleep is to be triggered by either the RTC or a momentary switch. Is that correct and if so, is there a simple modification? \r\n\r\nI have ambitions of sampling temperatures at regular intervals and detecting contact closures from a tipping bucket rain gauge while the ESP remains mostly in deep sleep and am puzzling over a simple circuit that doesn't drain the battery to achieve it."},"comment":{"url":"https://api.github.com/repos/chaeplin/esp8266_and_arduino/issues/comments/258778449","html_url":"https://github.com/chaeplin/esp8266_and_arduino/issues/37#issuecomment-258778449","issue_url":"https://api.github.com/repos/chaeplin/esp8266_and_arduino/issues/37","id":258778449,"user":{"login":"kentaylor","id":339520,"avatar_url":"https://avatars.githubusercontent.com/u/339520?v=3","gravatar_id":"","url":"https://api.github.com/users/kentaylor","html_url":"https://github.com/kentaylor","followers_url":"https://api.github.com/users/kentaylor/followers","following_url":"https://api.github.com/users/kentaylor/following{/other_user}","gists_url":"https://api.github.com/users/kentaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/kentaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kentaylor/subscriptions","organizations_url":"https://api.github.com/users/kentaylor/orgs","repos_url":"https://api.github.com/users/kentaylor/repos","events_url":"https://api.github.com/users/kentaylor/events{/privacy}","received_events_url":"https://api.github.com/users/kentaylor/received_events","type":"User","site_admin":false},"created_at":"2016-11-07T08:53:20Z","updated_at":"2016-11-07T08:53:20Z","body":"Thanks for the fast and comprehensive response. It seems not to be as simple as I'd hoped. \r\n>It's not suitable for using both wakeup by internal rtc and external momentary switch.\r\nAs GPIO16 is used to control NPN TR.\r\n\r\nIt can use another GPIO if the circuit can deal with the pin acting as an input during deep sleep. Then GPIO16 could be used to provide its usual wake up signal.\r\n\r\n>If deepsleep interval is 5 mins, and 'tipping bucket rain gauge' generates low pulse\r\n---> gpio16 to rst, and rain guage output to rst also.\r\n---> 'tipping bucket rain gauge' output should be one time low pulse.\r\n\r\nThis hits the simplicity criterion. The tipping bucket magnet closes a reed switch as it tips to produce a momentary closure which can be configured to be either VCC or GND. The bucket could tip anytime which means a running program could be interrupted and that is why I was looking around for alternatives.\r\n\r\nThinking about it some more though I wonder if there is an algorithm that will work. \r\n\r\nThe issues :- \r\n\r\n1. If it was during a temperature reading it would be lost but that wouldn't matter much and a temperature can be included with each bucket tip report. \r\n2. A lost bucket tip can seriously impact rainfall measurement accuracy. The minimum interval between bucket tips is 0.4 secs which is long enough for a user program to start running but not long enough to send a message. \r\n3. It is quite likely that in a downpour associated with a maximum tipping rate WiFi wouldn't get through the rain.\r\n4. The ESP will lose track of time when reset by a bucket tip.\r\n5. Reporting no more often than 30 seconds intervals helps with battery consumption.\r\n\r\nPossible Solution\r\n\r\n1. Maintain a bucket tip counter in RTC memory. \r\n2. Always  send the total so tips are never missed.\r\n3. Timing for determining tipping rate is done by the receiving station. \r\n4. Wake up every 5 minutes.\r\n5. By default wake up with radio off  to reduce power consumption a lot. Figures are  [40 mAsecs](https://forum.makehackvoid.com/t/esp8266-deep-sleep-cycle-times-and-power-consumption-with-wifi-on/786/5?u=ken_taylor) to transmit a sample using UDP vs [15mAsecs](https://forum.makehackvoid.com/t/esp8266-deep-sleep-cycle-times-and-power-consumption-with-wifi-off/776/11?u=ken_taylor) to wake up with WiFi but not transmit vs [5mAsecs](https://forum.makehackvoid.com/t/esp8266-deep-sleep-cycle-times-and-power-consumption-with-wifi-off/776/12?u=ken_taylor) to wake up with WiFi off.\r\n\r\nPossible Algorithm \r\n\r\nIf just powered up set to wake up in 5 minutes with WiFi off.\r\n\r\nIf woken with WiFi on and (if woken by RTC or (reported tip counter - tip counter>10)) then report temperature and tip counter.\r\n- If message transmission successful set to wake up in 5 minutes with WiFi off, clear message failure counter, and set reported counter to tip counter.\r\n- If message transmission fails, set to wake again in 5 minutes with WiFi on and increment message failure counter.\r\n\r\nIf WiFi is off, there has been a bucket tip or temperature change and message failure counter = 0 wake up in 30 sec with WiFi on.\r\nElse if there has been a bucket tip and message failure counter >0, wake up in 5 min with WiFi on.\r\n\r\nNot sure that it covers all the scenarios?\r\n\r\n> I think attiny85 + DS3231 + momentary switch + esp8266 is good choice.\r\n\r\nThat is more physically complicated than I hoped but makes for a simpler algorithm. "}}
{"actor":{"display_login":"kentaylor"}}