P positrom2 Active Member Licensed User Longtime User Jan 1, 2017 #1 I am using a timer to read the BMP280 sensor periodically - maybe every hour. Meanwhile nothing is to be done, so the processor might go to Deep Sleep. Should one abandon the timer an just use Deep Sleep? Or what is the right way to implement Deep Sleep in combination with a Timer?
I am using a timer to read the BMP280 sensor periodically - maybe every hour. Meanwhile nothing is to be done, so the processor might go to Deep Sleep. Should one abandon the timer an just use Deep Sleep? Or what is the right way to implement Deep Sleep in combination with a Timer?
Erel B4X founder Staff member Licensed User Longtime User Jan 2, 2017 #2 positrom2 said: Should one abandon the timer an just use Deep Sleep? Click to expand... I think so. The timer is not needed. DeepSleep: https://www.b4x.com/android/forum/threads/wemos-d1-mini-deep-sleep-mode.69423/#post-440533 Upvote 0
positrom2 said: Should one abandon the timer an just use Deep Sleep? Click to expand... I think so. The timer is not needed. DeepSleep: https://www.b4x.com/android/forum/threads/wemos-d1-mini-deep-sleep-mode.69423/#post-440533
P positrom2 Active Member Licensed User Longtime User Jan 2, 2017 #3 I am not sure about the strategy. Should the DeepSleep run within an endless loop or calling it with the Timer? I tried with the Timer, but it does not wakeup. The wiring on the Nodemcu 1.0 board already looks right (assuming the resistors have the right values (12k). NODEMCU_DEVKIT_V1.0.PDF Code: tmr.Initialize("tmr_Tick",1000) tmr.Enabled = True Private Sub tmr_Tick Log("timer") Log(k) k=k+1 If k >= ssd.GFX.Width Then k= 0 End If If k = 127 Then normalize plott End If DeepSleep(100) End Sub Upvote 0
I am not sure about the strategy. Should the DeepSleep run within an endless loop or calling it with the Timer? I tried with the Timer, but it does not wakeup. The wiring on the Nodemcu 1.0 board already looks right (assuming the resistors have the right values (12k). NODEMCU_DEVKIT_V1.0.PDF Code: tmr.Initialize("tmr_Tick",1000) tmr.Enabled = True Private Sub tmr_Tick Log("timer") Log(k) k=k+1 If k >= ssd.GFX.Width Then k= 0 End If If k = 127 Then normalize plott End If DeepSleep(100) End Sub
Erel B4X founder Staff member Licensed User Longtime User Jan 2, 2017 #4 Add log messages before and after DeepSleep to better understand whats happening. Your code looks correct. You can also use CallSubPlus instead of the timer though it doesn't really matter. Upvote 0
Add log messages before and after DeepSleep to better understand whats happening. Your code looks correct. You can also use CallSubPlus instead of the timer though it doesn't really matter.
P positrom2 Active Member Licensed User Longtime User Jan 2, 2017 #5 The log (using the Timer) looks like this (had a little trouble to assemble this since the ESP log is at 74800 Baud whereas the B4R log comes at 115200 Baud). ets Jan 8 2013,rst cause:2, boot mode3,6) load 0x4010f000, len 1384, room 16 tail 8 chksum 0x2d csum 0x2d v00000000 ~ld AppStart Successful timer 0 ets Jan 8 2013,rst cause:5, boot mode3,6) ets_main.c Click to expand... Upvote 0
The log (using the Timer) looks like this (had a little trouble to assemble this since the ESP log is at 74800 Baud whereas the B4R log comes at 115200 Baud). ets Jan 8 2013,rst cause:2, boot mode3,6) load 0x4010f000, len 1384, room 16 tail 8 chksum 0x2d csum 0x2d v00000000 ~ld AppStart Successful timer 0 ets Jan 8 2013,rst cause:5, boot mode3,6) ets_main.c Click to expand...
Erel B4X founder Staff member Licensed User Longtime User Jan 2, 2017 #6 positrom2 said: had a little trouble to assemble this since the ESP log is at 74800 Baud whereas the B4R log comes at 115200 Baud Click to expand... The baud rate is set when you call Serial1.Initialize. I don't think that this error is related to the timer. Are you able to call DeepSleep without the program crashing? Upvote 0
positrom2 said: had a little trouble to assemble this since the ESP log is at 74800 Baud whereas the B4R log comes at 115200 Baud Click to expand... The baud rate is set when you call Serial1.Initialize. I don't think that this error is related to the timer. Are you able to call DeepSleep without the program crashing?
P positrom2 Active Member Licensed User Longtime User Jan 2, 2017 #7 I found more information on DeepSleep: Among others, GPIO16 has to be connected to RST. When I make that connection, DeepSleep works and the program runs periodically. The drawback is that the wakeup-Reset clears the SRAM. So data are lost. So, we have to make use of the EEPROM probably. Or might there be a different solution? Upvote 0
I found more information on DeepSleep: Among others, GPIO16 has to be connected to RST. When I make that connection, DeepSleep works and the program runs periodically. The drawback is that the wakeup-Reset clears the SRAM. So data are lost. So, we have to make use of the EEPROM probably. Or might there be a different solution?
Erel B4X founder Staff member Licensed User Longtime User Jan 3, 2017 #8 It is very simple to use the EEPROM. You can use it together with B4RSerializator to store an array of objects. Upvote 0
It is very simple to use the EEPROM. You can use it together with B4RSerializator to store an array of objects.
P positrom2 Active Member Licensed User Longtime User Jan 3, 2017 #9 Will the data be always stored at the same address in the Eeprom? Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Jan 3, 2017 #10 See this tutorial: https://www.b4x.com/android/forum/threads/writing-and-reading-from-the-eeprom.65711/#content For further discussion please start a new thread. Upvote 0
See this tutorial: https://www.b4x.com/android/forum/threads/writing-and-reading-from-the-eeprom.65711/#content For further discussion please start a new thread.