-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Low-Power demo #6989
Merged
+564
−0
Merged
add Low-Power demo #6989
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
0c870ae
add Low-Power demo
Tech-TX fd1c366
add Low-Power demo
Tech-TX b912664
add Low-Power demo, remove OTA and add WiFi timeout
Tech-TX 287bc2d
add Low-Power demo
Tech-TX 7ea68d8
add Low-Power demo
Tech-TX f77a2c5
add Low-Power demo, remove OTA and add WiFi timeout
Tech-TX 387e30d
add Low-Power demo, remove OTA and add WiFi timeout
Tech-TX 0db9254
Merge branch 'master' into add_Low-Power_demo
Tech-TX 3f3ab30
Merge branch 'add_Low-Power_demo' of https://github.com/Tech-TX/Ardui…
Tech-TX df75200
add Low-Power demo
Tech-TX ab30950
Merge branch 'master' into add_Low-Power_demo
Tech-TX 11f1931
add Low-Power demo
Tech-TX 7d6a03b
Merge branch 'add_Low-Power_demo' of https://github.com/Tech-TX/Ardui…
Tech-TX 2003ef4
add Low-Power demo
Tech-TX acf3cec
add Low-Power demo
Tech-TX 2f2c508
add Low-Power demo
Tech-TX 47b73a2
add Low-Power demo
Tech-TX 36a8dbb
add Low-Power demo
Tech-TX 7178362
Merge branch 'master' into add_Low-Power_demo
Tech-TX 5d16fca
add Low-Power demo
Tech-TX 7a74da2
Merge branch 'add_Low-Power_demo' of https://github.com/Tech-TX/Ardui…
Tech-TX aa4feb2
add Low-Power demo
Tech-TX 8f4448d
add Low-Power demo
Tech-TX b8e42e4
add Low-Power demo
Tech-TX 068f4bd
add Low-Power demo
Tech-TX 3118de5
add Low-Power demo
Tech-TX ac40b6e
add Low-Power demo
Tech-TX 662b1f2
add Low-Power demo
Tech-TX 5695626
add Low-Power demo
Tech-TX 7627080
Merge branch 'master' into add_Low-Power_demo
Tech-TX 7b0e515
add Low-Power demo
Tech-TX a41c381
Merge branch 'add_Low-Power_demo' of https://github.com/Tech-TX/Ardui…
Tech-TX b93c2e3
add Low-Power demo
Tech-TX f4d00c6
add Low-Power demo
Tech-TX 841fa1b
add Low-Power demo
Tech-TX efe55a0
Merge branch 'master' into add_Low-Power_demo
Tech-TX ebc2b0a
add Low-Power demo
Tech-TX c9c073a
Merge branch 'add_Low-Power_demo' of https://github.com/Tech-TX/Ardui…
Tech-TX 222b9e8
add Low-Power demo
Tech-TX 9ef40f8
Merge branch 'master' into add_Low-Power_demo
Tech-TX 3ffb8ec
add Low-Power demo
Tech-TX b902ed2
Merge branch 'add_Low-Power_demo' of https://github.com/Tech-TX/Ardui…
Tech-TX 6ff566d
Merge branch 'master' into add_Low-Power_demo
Tech-TX c8a5955
add Low-Power demo
Tech-TX d9ea100
Merge branch 'add_Low-Power_demo' of https://github.com/Tech-TX/Ardui…
Tech-TX 431f5dc
add Low-Power demo
Tech-TX 9597a12
Merge branch 'master' into add_Low-Power_demo
Tech-TX 7d3ee8d
add Low-Power demo
Tech-TX 701634e
Merge branch 'add_Low-Power_demo' of https://github.com/Tech-TX/Ardui…
Tech-TX b618e6c
add Low-Power demo
Tech-TX 3292f9b
add Low-Power demo
Tech-TX 1e80279
add Low-Power demo
Tech-TX 93a527b
add Low-Power demo
Tech-TX 6018d0b
add Low-Power demo
Tech-TX 55d95e2
Merge branch 'master' into add_Low-Power_demo
Tech-TX b990e59
add Low-Power demo
Tech-TX c107c43
add Low-Power demo
Tech-TX fecacfd
add Low-Power demo
Tech-TX 601a5ae
add Low-Power demo
Tech-TX a3ddde1
add Low-Power demo
Tech-TX 535d483
add Low-Power demo
Tech-TX 3775b1b
add Low-Power demo
Tech-TX 56cb239
add Low-Power demo
Tech-TX c26ce4a
add Low-Power demo
Tech-TX a76ec12
add Low-Power demo
Tech-TX a79f48c
add Low-Power demo
Tech-TX ee4c701
add Low-Power demo
Tech-TX d378102
add Low-Power demo
Tech-TX df1a494
Merge branch 'master' into add_Low-Power_demo
Tech-TX File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add Low-Power demo
commit 7ea68d82d4bb8f1836dd86355349df8d4f1330b0
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,11 +39,11 @@ | |
#define DEBUG_PRINT(x) | ||
#endif | ||
|
||
#define WAKE_UP_PIN D3 // GPIO0, can also force a serial flash upload with RESET | ||
#define WAKE_UP_PIN 0 // D3/GPIO0, can also force a serial flash upload with RESET | ||
|
||
// un-comment one of the two lines below for your LED connection | ||
#define LED D1 // external LED for modules with built-in LEDs so it doesn't add to the current | ||
//#define LED D4 // GPIO2 LED for ESP-01,07 modules; D4 is LED_BUILTIN on most other modules | ||
#define LED 5 // D1/GPIO5 external LED for modules with built-in LEDs so it doesn't add to the current | ||
//#define LED 2 // D4/GPIO2 LED for ESP-01,07 modules; D4 is LED_BUILTIN on most other modules | ||
|
||
ADC_MODE(ADC_VCC); // allows us to monitor the internal VCC level; it varies with WiFi load | ||
// don't connect anything to the analog input pin(s)! | ||
|
@@ -69,7 +69,7 @@ struct { | |
byte data[4]; // the last byte stores the reset count | ||
} rtcData; | ||
|
||
byte resetLoop = 0; // keeps track of the number of Deep Sleep tests / resets | ||
byte resetCount = 0; // keeps track of the number of Deep Sleep tests / resets | ||
String resetCause = ""; | ||
|
||
const unsigned int blinkDelay = 100; // fast blink rate for the LED when waiting for the user | ||
|
@@ -91,23 +91,23 @@ void setup() { | |
Serial.println(resetCause); | ||
if (resetCause == "External System") { | ||
Serial.println(F("I'm awake and starting the low power tests")); | ||
resetLoop = 5; | ||
resetCount = 5; | ||
updateRTC(); // if external reset, wipe the RTC memory and start all over | ||
} | ||
|
||
// Read struct from RTC memory | ||
if (ESP.rtcUserMemoryRead(64, (uint32_t*) &rtcData, sizeof(rtcData))) { | ||
uint32_t crcOfData = calculateCRC32((uint8_t*) &rtcData.data[0], sizeof(rtcData.data)); | ||
if (crcOfData != rtcData.crc32) { // if the CRC is invalid | ||
resetLoop = 0; // set first test loop since power on or external reset | ||
resetCount = 0; // set first test loop since power on or external reset | ||
} else { | ||
resetLoop = rtcData.data[3]; // read the previous reset count | ||
resetCount = rtcData.data[3]; // read the previous reset count | ||
} | ||
} | ||
} // end of Setup() | ||
|
||
void loop() { | ||
devyte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (resetLoop == 0) { | ||
if (resetCount == 0) { | ||
// 1st test - running with WiFi unconfigured, reads ~67 mA minimum | ||
Serial.println(F("\n1st test - running with WiFi unconfigured")); | ||
float volts = ESP.getVcc(); | ||
|
@@ -171,7 +171,7 @@ void loop() { | |
Serial.println(F("\n6th test - Deep Sleep for 10 seconds, wake with RF_DEFAULT")); | ||
init_WiFi(); // initialize WiFi since we turned it off in the last test | ||
init_OTA(); | ||
resetLoop = 1; // advance to the next Deep Sleep test after the reset | ||
resetCount = 1; // advance to the next Deep Sleep test after the reset | ||
updateRTC(); // save the current test state in RTC memory | ||
volts = ESP.getVcc(); | ||
Serial.printf("The internal VCC reads %1.3f volts\n", volts / 1000 ); | ||
|
@@ -192,12 +192,12 @@ void loop() { | |
} | ||
|
||
// 7th test - Deep Sleep for 10 seconds, wake with RFCAL | ||
if (resetLoop < 4) { | ||
if (resetCount < 4) { | ||
init_WiFi(); // need to reinitialize WiFi & OTA due to Deep Sleep resets | ||
init_OTA(); // since we didn't do it in setup() because of the first test | ||
} | ||
if (resetLoop == 1) { // second reset loop since power on | ||
resetLoop = 2; // advance to the next Deep Sleep test after the reset | ||
if (resetCount == 1) { // second reset loop since power on | ||
resetCount = 2; // advance to the next Deep Sleep test after the reset | ||
updateRTC(); // save the current test state in RTC memory | ||
Serial.println(F("\n7th test - in RF_DEFAULT, Deep Sleep for 10 seconds, wake with RFCAL")); | ||
float volts = ESP.getVcc(); | ||
|
@@ -212,8 +212,8 @@ void loop() { | |
} | ||
|
||
// 8th test - Deep Sleep Instant for 10 seconds, wake with NO_RFCAL | ||
if (resetLoop == 2) { // third reset loop since power on | ||
resetLoop = 3; // advance to the next Deep Sleep test after the reset | ||
if (resetCount == 2) { // third reset loop since power on | ||
resetCount = 3; // advance to the next Deep Sleep test after the reset | ||
updateRTC(); // save the current test state in RTC memory | ||
Serial.println(F("\n8th test - in RFCAL, Deep Sleep Instant for 10 seconds, wake with NO_RFCAL")); | ||
float volts = ESP.getVcc(); | ||
|
@@ -228,8 +228,8 @@ void loop() { | |
} | ||
|
||
// 9th test - Deep Sleep Instant for 10 seconds, wake with RF_DISABLED | ||
if (resetLoop == 3) { // fourth reset loop since power on | ||
resetLoop = 4; // advance to the next Deep Sleep test after the reset | ||
if (resetCount == 3) { // fourth reset loop since power on | ||
resetCount = 4; // advance to the next Deep Sleep test after the reset | ||
updateRTC(); // save the current test state in RTC memory | ||
Serial.println(F("\n9th test - in NO_RFCAL, Deep Sleep Instant for 10 seconds, wake with RF_DISABLED")); | ||
float volts = ESP.getVcc(); | ||
|
@@ -243,8 +243,8 @@ void loop() { | |
Serial.println(F("What... I'm not asleep?!?")); // it will never get here | ||
} | ||
|
||
if (resetLoop == 4) { | ||
resetLoop = 5; // start all over | ||
if (resetCount == 4) { | ||
resetCount = 5; // start all over | ||
updateRTC(); // save the current test state in RTC memory | ||
float volts = ESP.getVcc(); | ||
Serial.printf("The internal VCC reads %1.3f volts\n", volts / 1000 ); | ||
|
@@ -299,10 +299,10 @@ uint32_t calculateCRC32(const uint8_t *data, size_t length) { | |
} | ||
|
||
void updateRTC() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would get replaced by the RTCData::writeToRTC() method, declared and defined within the class at the start of the sketch. |
||
rtcData.data[3] = resetLoop; // save the loop count for the next reset | ||
rtcData.data[3] = resetCount; // save the loop count for the next reset | ||
// Update CRC32 of data | ||
rtcData.crc32 = calculateCRC32((uint8_t*) &rtcData.data[0], sizeof(rtcData.data)); | ||
if (resetLoop == 5) // wipe the CRC in RTC memory when we're done with all tests | ||
if (resetCount == 5) // wipe the CRC in RTC memory when we're done with all tests | ||
rtcData.crc32 = 0; | ||
// Write struct to RTC memory | ||
ESP.rtcUserMemoryWrite(64, (uint32_t*) &rtcData, sizeof(rtcData)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This resetCause isn't needed, the line should be removed. You are declaring it inside setup(), and using it only there, so that local declaration is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I'd forgotten I moved that whole thing inside of setup(). Removed.
For whatever reason, I got exceptions if I tried to do multiple reads of ESP.getResetReason() like this:
I didn't try to hunt it down, as it was a very long stack dump. I've never seen a stack dump that long. That's why I read it once into a string.