-
Notifications
You must be signed in to change notification settings - Fork 26
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
Ultra Low Power deepsleep #15
base: master
Are you sure you want to change the base?
Conversation
hallard
commented
Mar 1, 2018
•
edited
Loading
edited
- Added Ultra Low Power mode (30uA sleep mode)
- Wake by LoRa module, avoid watchdog wake every 8s
- Added new method to read battery voltage, needed if VCC<2.5V
- Updated documentation
- Bug fix with button wake
- Press button more than 2s to enable 1minute window to upload new sketch when in deepsleep
- Added Hardware Reset of lora module at startup - Fixed push button duration bug - Set IRQ var to be volatile
Moved #include definition here Added wakeStatus to wakeCallback to get what waked us Added pointer to TheThingsNetwork object to enable Lora module sleep/wake up
removed #include definition (in .h now) Added wakeStatus bit field to wakeCallback to get what waked us Added pointer to TheThingsNetwork object to enable Lora module sleep/wake up Added IRQ for INT2 (Lora Serial Module) Added new configInterval method Optimized Light Sensor Changed deepSleep to support wake by lora module
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.
Nice, thanks very much! Mostly code style issues.
Also looping in @laurensslats for testing
docs/TheThingsNode.md
Outdated
void wake() { | ||
node->setColor(TTN_GREEN); | ||
void wake(uint8_t wakeReason) { | ||
debugSerial.print(F("Wake Reason:0x")); |
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.
Spacing; Reason: 0x
docs/TheThingsNode.md
Outdated
debugSerial.print(F("Wake Reason:0x")); | ||
debugSerial.println(wakeReason,HEX); | ||
|
||
if (wakeReason&TTN_WAKE_WATCHDOG) { |
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.
Spacing; wakeReason & TTN_WAKE_WATCHDOG
docs/TheThingsNode.md
Outdated
node->setColor(TTN_GREEN); | ||
void wake(uint8_t wakeReason) { | ||
debugSerial.print(F("Wake Reason:0x")); | ||
debugSerial.println(wakeReason,HEX); |
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.
Spacing; wakeReason, HEX
docs/TheThingsNode.md
Outdated
``` | ||
|
||
- `bool enabled`: Enable or disable the interval callback. Enabled automatically by `onInterval()`, but you can use this method to temporarily disable it. Defaults to `false`. | ||
- `TheThingsNetwork * pttn`: This enable the interval callback but in this mode, the interval is passed to RN2483 or RN2903 module (this is why we need to pass pointer to object) with the command `sys sleep ms` and then it's the LoRa module that wake up the node. This is the most advanced Low Power Mode. In this mode, the watchdog is disabled and consuption again reduced. |
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.
consuMption
debugSerial.print(timepressed); | ||
debugSerial.println(F(" ms")); | ||
snprintf_P(buf, sizeof(buf), PSTR("-- SEND: BUTTON %d ms"), timepressed); | ||
debugSerial.println(buf); |
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.
Build the string here with print/println calls for consistency
src/TheThingsNode.cpp
Outdated
value = readADCLowNoise(true); | ||
|
||
// Vcc reference in millivolts | ||
vcc = ( 1023L * 1100L) / value ; |
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.
Spacing
src/TheThingsNode.cpp
Outdated
|
||
// Operating range of ATMega | ||
if (vcc < 1800 ) vcc = 1800 ; | ||
if (vcc > 5500 ) vcc = 5500 ; |
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.
Spacing and indentation
src/TheThingsNode.cpp
Outdated
if (vcc > 5500 ) vcc = 5500 ; | ||
|
||
// Vcc in millivolts | ||
return ( vcc ); |
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.
Why parentheses?
src/TheThingsNode.cpp
Outdated
@@ -748,14 +903,13 @@ TheThingsNode::TheThingsNode() | |||
pinMode(TTN_BLUE_LED, OUTPUT); | |||
setColor(TTN_BLACK); | |||
|
|||
// hardware reset of LoRa module, so module is reset on sketch upload | |||
#ifdef TTN_LORA_RESET | |||
// reset RN2483 module, this allow to reset module on sketch upload also |
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.
RN2xx3
src/TheThingsNode.cpp
Outdated
cli(); | ||
bitSet(EIFR,INTF2); // clear any pending interrupts for serial RX pin (INT2 D0) | ||
sei(); | ||
|
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.
Remove empty line
@johanstokking you want me to remove any use of printf, sprintf and snprintf, correct? |
Requested changes are done |
@hallard we try to keep dynamic memory allocations to a minimum, at least that's a goal! |
removing printf is not a bad idea, I think it also save same pgm space (as soon as it's not used anywhere else in any lib) |