8000 add Low-Power demo by Tech-TX · Pull Request #6989 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

add Low-Power demo #6989

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

Merged
merged 69 commits into from
Feb 2, 2020
Merged
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 Jan 6, 2020
fd1c366
add Low-Power demo
Tech-TX Jan 6, 2020
b912664
add Low-Power demo, remove OTA and add WiFi timeout
Tech-TX Jan 9, 2020
287bc2d
add Low-Power demo
Tech-TX Jan 6, 2020
7ea68d8
add Low-Power demo
Tech-TX Jan 6, 2020
f77a2c5
add Low-Power demo, remove OTA and add WiFi timeout
Tech-TX Jan 9, 2020
387e30d
add Low-Power demo, remove OTA and add WiFi timeout
Tech-TX Jan 9, 2020
0db9254
Merge branch 'master' into add_Low-Power_demo
Tech-TX Jan 9, 2020
3f3ab30
Merge branch 'add_Low-Power_demo' of https://github.com/Tech-TX/Ardui…
Tech-TX Jan 10, 2020
df75200
add Low-Power demo
Tech-TX Jan 10, 2020
ab30950
Merge branch 'master' into add_Low-Power_demo
Tech-TX Jan 10, 2020
11f1931
add Low-Power demo
Tech-TX Jan 10, 2020
7d6a03b
Merge branch 'add_Low-Power_demo' of https://github.com/Tech-TX/Ardui…
Tech-TX Jan 10, 2020
2003ef4
add Low-Power demo
8000 Tech-TX Jan 10, 2020
acf3cec
add Low-Power demo
Tech-TX Jan 10, 2020
2f2c508
add Low-Power demo
Tech-TX Jan 11, 2020
47b73a2
add Low-Power demo
Tech-TX Jan 11, 2020
36a8dbb
add Low-Power demo
Tech-TX Jan 11, 2020
7178362
Merge branch 'master' into add_Low-Power_demo
Tech-TX Jan 11, 2020
5d16fca
add Low-Power demo
Tech-TX Jan 12, 2020
7a74da2
Merge branch 'add_Low-Power_demo' of https://github.com/Tech-TX/Ardui…
Tech-TX Jan 12, 2020
aa4feb2
add Low-Power demo
Tech-TX Jan 12, 2020
8f4448d
add Low-Power demo
Tech-TX Jan 12, 2020
b8e42e4
add Low-Power demo
Tech-TX Jan 12, 2020
068f4bd
add Low-Power demo
Tech-TX Jan 12, 2020
3118de5
add Low-Power demo
Tech-TX Jan 12, 2020
ac40b6e
add Low-Power demo
Tech-TX Jan 12, 2020
662b1f2
add Low-Power demo
Tech-TX Jan 13, 2020
5695626
add Low-Power demo
Tech-TX Jan 16, 2020
7627080
Merge branch 'master' into add_Low-Power_demo
Tech-TX Jan 17, 2020
7b0e515
add Low-Power demo
Tech-TX Jan 17, 2020
a41c381
Merge branch 'add_Low-Power_demo' of https://github.com/Tech-TX/Ardui…
Tech-TX Jan 17, 2020
b93c2e3
add Low-Power demo
Tech-TX Jan 17, 2020
f4d00c6
add Low-Power demo
Tech-TX Jan 18, 2020
841fa1b
add Low-Power demo
Tech-TX Jan 18, 2020
efe55a0
Merge branch 'master' into add_Low-Power_demo
Tech-TX Jan 18, 2020
ebc2b0a
add Low-Power demo
Tech-TX Jan 22, 2020
c9c073a
Merge branch 'add_Low-Power_demo' of https://github.com/Tech-TX/Ardui…
Tech-TX Jan 22, 2020
222b9e8
add Low-Power demo
Tech-TX Jan 25, 2020
9ef40f8
Merge branch 'master' into add_Low-Power_demo
Tech-TX Jan 25, 2020
3ffb8ec
add Low-Power demo
Tech-TX Jan 26, 2020
b902ed2
Merge branch 'add_Low-Power_demo' of https://github.com/Tech-TX/Ardui…
Tech-TX Jan 26, 2020
6ff566d
Merge branch 'master' into add_Low-Power_demo
Tech-TX Jan 26, 2020
c8a5955
add Low-Power demo
Tech-TX Jan 26, 2020
d9ea100
Merge branch 'add_Low-Power_demo' of https://github.com/Tech-TX/Ardui…
Tech-TX Jan 26, 2020
431f5dc
add Low-Power demo
Tech-TX Jan 28, 2020
9597a12
Merge branch 'master' into add_Low-Power_demo
Tech-TX Jan 28, 2020
7d3ee8d
add Low-Power demo
Tech-TX Jan 28, 2020
701634e
Merge branch 'add_Low-Power_demo' of https://github.com/Tech-TX/Ardui…
Tech-TX Jan 28, 2020
b618e6c
add Low-Power demo
Tech-TX Jan 29, 2020
3292f9b
add Low-Power demo
Tech-TX Jan 29, 2020
1e80279
add Low-Power demo
Tech-TX Jan 29, 2020
93a527b
add Low-Power demo
Tech-TX Jan 29, 2020
6018d0b
add Low-Power demo
Tech-TX Jan 30, 2020
55d95e2
Merge branch 'master' into add_Low-Power_demo
Tech-TX Jan 30, 2020
b990e59
add Low-Power demo
Tech-TX Jan 31, 2020
c107c43
add Low-Power demo
Tech-TX Jan 31, 2020
fecacfd
add Low-Power demo
Tech-TX Jan 31, 2020
601a5ae
add Low-Power demo
Tech-TX Jan 31, 2020
a3ddde1
add Low-Power demo
Tech-TX Jan 31, 2020
535d483
add Low-Power demo
Tech-TX Jan 31, 2020
3775b1b
add Low-Power demo
Tech-TX Feb 1, 2020
56cb239
add Low-Power demo
Tech-TX Feb 1, 2020
c26ce4a
add Low-Power demo
Tech-TX Feb 1, 2020
a76ec12
add Low-Power demo
Tech-TX Feb 1, 2020
a79f48c
add Low-Power demo
Tech-TX Feb 1, 2020
ee4c701
add Low-Power demo
Tech-TX Feb 1, 2020
d378102
add Low-Power demo
Tech-TX Feb 1, 2020
df1a494
Merge branch 'master' into add_Low-Power_demo
Tech-TX Feb 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add Low-Power demo
  • Loading branch information
Tech-TX committed Jan 31, 2020
commit 535d4832bfd91d4cf4de1617fa4ed61fd5a2dcc3
24 changes: 12 additions & 12 deletions libraries/esp8266/examples/LowPowerDemo/LowPowerDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

This test series requires an active WiFi connection to illustrate two tests. If you
have problems with WiFi, uncomment the #define DEBUG for additional WiFi error messages.
The test requires a pushbutton switch connected between D3 and GND to advance the tests.
The test needs a pushbutton switch connected between D3/GPIO0 and GND to advance the tests.
You'll also need to connect D0/GPIO16 to RST for the Deep Sleep tests. If you forget to
connect D0 to RST it will hang after the first Deep Sleep test. D0 is driven high during
Deep Sleep, so you should use a Schottky diode between D0 and RST if you want to use a
Expand All @@ -21,7 +21,7 @@
continuously it's connecting WiFi, and when it's off the CPU is asleep. The LED blinks
slowly when the tests are complete. Test progress can also be shown on the serial monitor.

WiFi connections will be made over twice as fast if you can use a static IP address.
WiFi connections will be made over twice as fast if you use a static IP address.

This example is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand All @@ -38,9 +38,9 @@
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#include <ESP8266WiFi.h>
#include <coredecls.h> // crc32()
#include <coredecls.h> // crc32()
#include <PolledTimeout.h>
#include <include/WiFiState.h> // WiFiState structure details
#include <include/WiFiState.h> // WiFiState structure details

//#define DEBUG // prints WiFi connection info to serial, uncomment if you want WiFi messages
#ifdef DEBUG
Expand All @@ -65,14 +65,14 @@ ADC_MODE(ADC_VCC); // allows you to monitor the internal VCC level; it varies w
// enter your WiFi configuration below
const char* AP_SSID = "SSID"; // your router's SSID here
const char* AP_PASS = "password"; // your router's password here
IPAddress staticIP(0, 0, 0, 0); // parameters below are for your static IP address, if used
IPAddress staticIP(0, 0, 0, 0); // parameters below are for your static IP address, if used
IPAddress gateway(0, 0, 0, 0);
IPAddress subnet(0, 0, 0, 0);
IPAddress dns1(0, 0, 0, 0);
IPAddress dns2(0, 0, 0, 0);
uint32_t wifiTimeout = 30E3; // 30 second timeout on the WiFi connection

//#define TESTPOINT // used to track the timing of several test cycles (optional)
//#define TESTPOINT // used to track the timing of several test cycles (optional)
#ifdef TESTPOINT
#define testPointPin 4 // D2/GPIO4, you can use any pin that supports interrupts
#define testPoint_HIGH digitalWrite(testPointPin, HIGH)
Expand All @@ -85,7 +85,7 @@ uint32_t wifiTimeout = 30E3; // 30 second timeout on the WiFi connection
// This structure is stored in RTC memory to save the WiFi state and reset count (number of Deep Sleeps),
// and it reconnects twice as fast as the first connection; it's used extensively in this demo
struct nv_s {
WiFiState wss; // core's WiFi save state
WiFiState wss; // core's WiFi save state

struct {
uint32_t crc32;
Expand All @@ -94,11 +94,11 @@ struct nv_s {
} rtcData;
};

static nv_s* nv = (nv_s*)RTC_USER_MEM; // user RTC RAM area
static nv_s* nv = (nv_s*)RTC_USER_MEM; // user RTC RAM area

uint32_t resetCount = 0; // keeps track of the number of Deep Sleep tests / resets

const uint32_t blinkDelay = 100; // fast blink rate for the LED when waiting for the user
const uint32_t blinkDelay = 100; // fast blink rate for the LED when waiting for the user
esp8266::polledTimeout::periodicMs blinkLED(blinkDelay); // LED blink delay without delay()
esp8266::polledTimeout::oneShotFastMs altDelay(blinkDelay); // tight loop to simulate user code
// use fully qualified type and avoid importing all ::esp8266 namespace to the global namespace
Expand Down Expand Up @@ -133,7 +133,7 @@ void setup() {
resetCount = nv->rtcData.rstCount; // read the previous reset count
resetCount++;
}
nv->rtcData.rstCount = resetCount; // update the reset count & CRC
nv->rtcData.rstCount = resetCount; // update the reset count & CRC
updateRTCcrc();

if (resetCount == 1) { // show that millis() is cleared across the Deep Sleep reset
Expand Down Expand Up @@ -163,7 +163,7 @@ void loop() {
} else if (resetCount == 4) {
resetTests();
}
} //end of loop()
} //end of loop()

void runTest1() {
Serial.println(F("\n1st test - running with WiFi unconfigured"));
Expand Down Expand Up @@ -253,7 +253,7 @@ void runTest5() {
// with the callback the sleep time is only 10 seconds total, no extra delay() afterward
wifi_fpm_open();
wifi_fpm_do_sleep(10E6); // Sleep range = 10000 ~ 268,435,454 uS (0xFFFFFFE, 2^28-1)
delay(10e3 + 1); // delay needs to be 1 mS longer than sleep or it only goes into Modem Sleep
delay(10e3 + 1); // delay needs to be 1 mS longer than sleep or it only goes into Modem Sleep
Serial.println(F("Woke up!")); // the interrupt callback hits before this is executed
}

Expand Down
0