Skip to content
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

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open

Conversation

hallard
Copy link
Contributor

@hallard hallard commented Mar 1, 2018

  • 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
Copy link
Member

@johanstokking johanstokking left a 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

void wake() {
node->setColor(TTN_GREEN);
void wake(uint8_t wakeReason) {
debugSerial.print(F("Wake Reason:0x"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing; Reason: 0x

debugSerial.print(F("Wake Reason:0x"));
debugSerial.println(wakeReason,HEX);

if (wakeReason&TTN_WAKE_WATCHDOG) {
Copy link
Member

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

node->setColor(TTN_GREEN);
void wake(uint8_t wakeReason) {
debugSerial.print(F("Wake Reason:0x"));
debugSerial.println(wakeReason,HEX);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing; wakeReason, HEX

```

- `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.
Copy link
Member

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);
Copy link
Member

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

value = readADCLowNoise(true);

// Vcc reference in millivolts
vcc = ( 1023L * 1100L) / value ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing


// Operating range of ATMega
if (vcc < 1800 ) vcc = 1800 ;
if (vcc > 5500 ) vcc = 5500 ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing and indentation

if (vcc > 5500 ) vcc = 5500 ;

// Vcc in millivolts
return ( vcc );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why parentheses?

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RN2xx3

cli();
bitSet(EIFR,INTF2); // clear any pending interrupts for serial RX pin (INT2 D0)
sei();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty line

@hallard
Copy link
Contributor Author

hallard commented Mar 2, 2018

@johanstokking you want me to remove any use of printf, sprintf and snprintf, correct?

@hallard
Copy link
Contributor Author

hallard commented Mar 4, 2018

Requested changes are done

@johanstokking
Copy link
Member

@hallard we try to keep dynamic memory allocations to a minimum, at least that's a goal!

@hallard
Copy link
Contributor Author

hallard commented Mar 4, 2018

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)

@CLAassistant
Copy link

CLAassistant commented Jul 23, 2019

CLA assistant check
All committers have signed the CLA.

@jpmeijers jpmeijers mentioned this pull request May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants