GithubHelp home page GithubHelp logo

low-power's Introduction

Low-Power

Lightweight low power library for Arduino.

Version: 1.81

Date: 21-01-2020

Devices Supported:

  • ATMega88
  • ATMega168
  • ATMega168P
  • ATMega328P
  • ATMega32U4
  • ATMega644P
  • ATMega1284P
  • ATMega2560
  • ATMega256RFR2
  • ATSAMD21G18A

####Notes: External interrupt during standby on ATSAMD21G18A requires a patch to the Arduino SAMD Core in order for it to work. Fix is provided by this particular pull request.

low-power's People

Contributors

alexreinert avatar mrguen avatar rocketscream avatar rodmg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

low-power's Issues

LowPower.powerDown not realiable over extended periods of time (ATmega328)

Im using this snippet to make an Arduíno pro mini sleep for one hour by setting sleepTime = 3600, it works fine for about 28 days and then it starts to to bypass the function altogether, after a couple of hours it disables the ADC and keeps going

`
void loop() {
for(int j = 0; j < (sleepTime/8); j++) {
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
}
resetFunc();
}

void(*resetFunc) (void) = 0;
`

Example code not working

Hey. I am using a neewly bought arduino micro, and I tried the testexample where you can suspend it for 8 seconds. I imported the libary included the headerfile and tried to execute it and to print out a text every 8 seconds. But after the first iteration it just stops. Any idea what I could have done wrong? Do i need to import more libaries? Or is a serial connection just not possible right after suspension?

nRF52 support

I gave up on the hope to get ESP32 support.
Now I have chosen another option and try to get nRF52 support within this library.
I have chosen the nRF52832 which has great power saving features and I think it bevaves better than the ESP32 (does no restart after wakeup).
I have enough source to use the nRF52 sleep featues like I know it for the ESP32, however, many projects rely on the LowPower.h sleep functions and thus it would be great to have the abstraction of the sleep functions through this lib.
Any chance to get it?

usb is closed ............?

Hello

i have uploaded the idleWakePeriodic example on my BlueDuino . which has a ATMega32U4 processor.
i have commented the line for ATMega32U4 in the example and uploaded the sketch. the sketch was uploaded successfully. But after that my pc is not recognizing the board. Which shows usb device not recognized . i think the usb close command is closed the usb function of board . so now how can i get back to my previous stage. now i cant upload any sketch...........?

Overwrites memory in my sketch

With the library included, and this line:
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
my sketch compiles and starts to run, but displays garbage characters in my debugging messages
(e.g., Serial.print("into fwd run of"); Serial.println(fwd_run_length); displays as
"into fwd run of 6ô" ) and other misbehaviors.

if instead I use
Delay(8000);
then my sketch runs perfectly.

Pro Mini still consuming 5-10ma?

Hi, I need help - my pro mini setup uses 5-10ma in sleep mode with the Lowpower lib, and I don’t know why. Maybe someone spots an error. I'm using a sample from TTN (Lora Network).

This is my setup:

Arduino Pro Mini (without LED) 8mhz/3.3v
Directly connected RFM95

Controlled through transistor (Pin 7 in the sketch)
Voltage Regulator + Level Converter + HC-SR04

This is the sketch:

https://gist.github.com/solars/edfa9a7faf8ffad35bb6b5914ee5f04b
Am I doing it wrong?

Cannot use radio transmitter after switching to LowPower library

My Arduino Mini board has DHT22 temperature sensor and 433MHz radio transmitter modules. I'm using DHT and RCswitch libraries to make use of them. Code looks like this:

void setup() {
  tempSwitch.enableTransmit(RADIO_PIN);
  dht.begin();
}

void loop() {
  float temp = dht.readTemperature();

  unsigned long message = createTemperatureMessage(SENSOR_ID, temp);
  tempSwitch.send(message, 32);

#ifdef MY_DEBUG
  unsigned int sleepCount = 1; 
#else
  // 3600s / 2 / 8s == 225
  unsigned int sleepCount = 225;
#endif
  for (; sleepCount > 0; sleepCount--) {
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
  }
}

So I'm reading temperature and sending it using RCswitch library. Initially I just had delay(1000); instead of fancy LowPower sleep loop but I wanted to make my "device" more battery-friendly so I switched to low-power sleep.

The problem is that now Arduino is only sending data first time and after sleeping 30 minutes (in "release" mode) it does not send anything anymore. If I reduce 30 minutes to 8 seconds it is capable of sending data as well as if I replace sleep with delay(30*60*1000);.

From beyond it looks like something is not caching up after the sleep. Do I need to "wake" Arduino in any special way? How to fix that?

Thanks

Watchdog timer clash with other libs using ISR(WDT_vect)

When using this library in conjunction with any other library, which somehow seems to interact with
watchdog timers, the compile fails.

`libraries\Low-Power-master\LowPower.cpp.o (symbol from plugin): In function 'LowPowerClass::idle(period_t, adc_t, timer2_t, timer1_t, timer0_t, spi_t, usart0_t, twi_t)':

(.text+0x0): multiple definition of '__vector_6'

libraries\Crypto\RNG.cpp.o (symbol from plugin):(.text+0x0): first defined here

collect2.exe: error: ld returned 1 exit status`

I narrowed it down to be a problem with calling ISR(WDT_vect) in multiple contexts.

This lib:
https://github.com/rocketscream/Low-Power/blob/master/LowPower.cpp#L1131
libcrypto:
https://github.com/rweather/arduinolibs/blob/master/libraries/Crypto/RNG.cpp#L228

Is the use of ISR(wdt_) necessary to work? (I guess so).
If so, is there any way to avoid this clash?

Feature request

Hi and thank you for the great work

I want to wakeup on analog comparator interrupt - is that possible to implement?
at the moment iam using powerDown(500ms) and than I check if there is a interrupt.
Can I check permanent and kill all other stuff?

ACSR = B01011000;
.....
ISR(ANALOG_COMP_vect)
{
//interrupt !
ACSR = ACSR & 0b11110111 ; //toggle Interrupt Flag
//Flag toggleed
}

something wrong with Serial.print

//the serial.print would be failed without a delay() followed, the test code as follows.

include "LowPower.h"

void setup()
{
Serial.begin(9600);
}

void loop()
{
Serial.println("waked");
delay(10);//the serial.print would be failed without this line
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
}

it happened to be uncompatible with FlexiTimer2 or MsTimer2

I'v tried to wake the lowpower sleep of arduino with the timer2 interrupt.
Unfortunately, the FlexiTimer2 doesn't work and the arduino can't run into sleep mode, the same as MsTimer2.
However, while a out interrupt as the int0 was used to instead of the timer2 interrupt, it works fun without any problem.
The codes tested as follows.

include "LowPower.h"

include <FlexiTimer2.h>

void flash() {
static boolean output = HIGH;
digitalWrite(13, output);
output = !output;
}
void setup()
{
Serial.begin(9600);
FlexiTimer2::set(2000, flash); // 2000ms period
FlexiTimer2::start();
}

void loop()
{
Serial.println("waked");
delay(500);
//attachInterrupt(0,flash, RISING);
LowPower.powerSave(SLEEP_FOREVER, ADC_OFF, BOD_OFF, TIMER2_ON);
//detachInterrupt(0);
}

ESP32 support

Is anybody capable and willing to support the ESP32 family?
It has a RTC and ULP CPU so the prerequisites should be there.
I would urgently need a Lowpower library so that I can complete my AskSinPP (Homematic) port for ESP32.

ATMega2560 - power_usart3_disable' was not declared in this scope

Hello

#include "LowPower.h"
void setup()
{
  Serial.begin(115200);
}

void loop()
{
  Serial.println("Bye for 2s");Serial.flush();
  LowPower.powerDown(SLEEP_2S, ADC_OFF, BOD_OFF);
  Serial.println("Hi");Serial.flush();
}

compiles fine with an Arduino Uno in Version 1.6.12 of the IDE.

But moving this simple code to an Arduino Mega 2560 and trying to compile gets me an error:

.../Arduino/libraries/Low-Power/LowPower.cpp: In member function 'void LowPowerClass::idle(period_t, adc_t, timer5_t, timer4_t, timer3_t, timer2_t, timer1_t, timer0_t, spi_t, usart3_t, usart2_t, usart1_t, usart0_t, twi_t)':
.../Arduino/libraries/Low-Power/LowPower.cpp:440:49: error: 'power_usart3_disable' was not declared in this scope
  if (usart3 == USART3_OFF) power_usart3_disable();
                                                 ^

seems this was already reported https://github.com/arduino/Arduino/issues/5286

Feature Request: Custom WDT handler

Hello,
I need to do some more stuff inside the WDT ISR handler, but want to avoid modifying the library directly.
Can you please add and ifdef for CustomWDThandler or some other way to allow external function to be called. Something like below?

#ifdef CustomWDThandler
 CustomWDThandler;
#else
 wdt_disable();
#endif

SLEEP_MODE_EXT_STANDBY not declared on ATMega168

When I try to compile a sketch with #include <LowPower.h> in it (even if there's no other code) and I specify the ATMega168, I get this error:

In file included from /Users/gfk/Documents/Arduino/libraries/Low-Power-master/LowPower.cpp:27:0:
/Users/gfk/Documents/Arduino/libraries/Low-Power-master/LowPower.cpp: In member function 'void LowPowerClass::powerExtStandby(period_t, adc_t, bod_t, timer2_t)':
/Users/gfk/Documents/Arduino/libraries/Low-Power-master/LowPower.cpp:823:18: error: 'SLEEP_MODE_EXT_STANDBY' was not declared in this scope
    lowPowerBodOn(SLEEP_MODE_EXT_STANDBY);
                  ^
/Users/gfk/Documents/Arduino/libraries/Low-Power-master/LowPower.cpp:823:4: note: in expansion of macro 'lowPowerBodOn'
    lowPowerBodOn(SLEEP_MODE_EXT_STANDBY);
    ^
/Users/gfk/Documents/Arduino/libraries/Low-Power-master/LowPower.cpp:828:17: error: 'SLEEP_MODE_EXT_STANDBY' was not declared in this scope
   lowPowerBodOn(SLEEP_MODE_EXT_STANDBY);
                 ^
/Users/gfk/Documents/Arduino/libraries/Low-Power-master/LowPower.cpp:828:3: note: in expansion of macro 'lowPowerBodOn'
   lowPowerBodOn(SLEEP_MODE_EXT_STANDBY);
   ^
Erreur lors de la compilation.

Interupts FALLING, RISING CHANGE not working when in sleep

Hi,
I had my SAMD21 working whilst awake using the FALLING, RISING CHANGE interrupt mode.
When the device went to sleep however, the interrupt would not work and wake up the device.
I added this to my setup routine:

	SYSCTRL->VREG.bit.RUNSTDBY = 1;
	SYSCTRL->DFLLCTRL.bit.RUNSTDBY = 1;

And it all works now.
Not sure if you can implement this into Low-Power?
Thanks

TinyGPS seems to break this library

Hello,
I have a GPS in my setup and I'm using TinyGPS for it.
When I use the GPS, the following function does not work:
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

This function does not put my arduino nano in powerdown mode for 8sec. It simply skips over this line without executing it.

Thank you for the help!

-Vincent

SLEEP_MODE_EXT_STANDBY not declared on ATMega168

When compiling with LowPower.h using Arduino Pro Mini 168 there is still an error present. Same error was reported in July 30 2015 (issue #14).

[code]

In file included from C:\Users\Mysafety\Google Drive\documents\Arduino\libraries\Low-Power\LowPower.cpp:32:0:

C:\Users\Mysafety\Google Drive\documents\Arduino\libraries\Low-Power\LowPower.cpp: In member function 'void LowPowerClass::powerExtStandby(period_t, adc_t, bod_t, timer2_t)':

C:\Users\Mysafety\Google Drive\documents\Arduino\libraries\Low-Power\LowPower.cpp:980:18: error: 'SLEEP_MODE_EXT_STANDBY' was not declared in this scope

lowPowerBodOn(SLEEP_MODE_EXT_STANDBY);

              ^

C:\Users\Mysafety\Google Drive\documents\Arduino\libraries\Low-Power\LowPower.cpp:980:4: note: in expansion of macro 'lowPowerBodOn'

lowPowerBodOn(SLEEP_MODE_EXT_STANDBY);

^

C:\Users\Mysafety\Google Drive\documents\Arduino\libraries\Low-Power\LowPower.cpp:985:17: error: 'SLEEP_MODE_EXT_STANDBY' was not declared in this scope

lowPowerBodOn(SLEEP_MODE_EXT_STANDBY);

             ^

C:\Users\Mysafety\Google Drive\documents\Arduino\libraries\Low-Power\LowPower.cpp:985:3: note: in expansion of macro 'lowPowerBodOn'

lowPowerBodOn(SLEEP_MODE_EXT_STANDBY);

^

Bibliotheek Wire op versie 1.0 in map: C:\Users\Mysafety\Google Drive\documents\Arduino\libraries\Wire wordt gebruikt
Bibliotheek RTClibExtended op versie 1.0.0 in map: C:\Users\Mysafety\Google Drive\documents\Arduino\libraries\RTClibExtended wordt gebruikt
Bibliotheek Low-Power op versie 1.6 in map: C:\Users\Mysafety\Google Drive\documents\Arduino\libraries\Low-Power wordt gebruikt
exit status 1
Fout bij het compileren van board Arduino Pro or Pro Mini

[/code]

ISRs - Does the code run when waking up?

Device: Adafruit Feather 32u4

I want to use this library to not only wake up the device, but I wanted the ISR to actually do something when triggered. The example provided has the ISR as a no-op.

I just want to set a volatile boolean as true when the ISR is triggered. Is this possible? Or does the interrupt just wake the MCU up and return control to the loop() function?

Support for ATmega 328 non-P?

Hi, is there a reason why the library does not support the non-P version of ATmega328?

With board selected as "ATmega328", sketches will not compile. To overcome this, I amended line 112 of LowPower.h as follows:
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega328__) || defined (__AVR_ATmega168__)

The sketch below now compiles and uploads fine.

// **** INCLUDES *****
#include "LowPower.h"

void setup()
{
    Serial.begin(115200);
}

void loop() 
{
    Serial.println("Sleeping...");
    Serial.flush();
    // Enter power down state for 4 s with ADC and BOD module disabled
    LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF);  
    
    Serial.println("Woke up...");
    Serial.flush();
    delay(4000);
}

I measure the current consumption during the sleeping periods at around 20-25uA vs. around 3.6mA when awake (8MHz internal clock, 3.3V). Not as low as a 328P, but not too bad at all!

"candidate expects 10 arguments, 8 provided"

Hey,

I copied this line from your example code:

  LowPower.idle(SLEEP_8S, ADC_OFF, TIMER2_OFF, TIMER1_OFF, TIMER0_OFF, 
                SPI_OFF, USART0_OFF, TWI_OFF);

but it fails with the following error:

Arduino: 1.6.7 (Linux), Board: "Arduino Leonardo"

...
/home/paul/repo/arduino/hack-the-hive/hack-the-hive.ino: In function 'void wait_5_minutes()':
hack-the-hive:146: error: no matching function for call to 'LowPowerClass::idle(period_t, adc_t, timer2_t, timer1_t, timer0_t, spi_t, usart0_t, twi_t)'
                 SPI_OFF, USART0_OFF, TWI_OFF);
                                             ^
/home/paul/repo/arduino/hack-the-hive/hack-the-hive.ino:146:45: note: candidate is:
In file included from /home/paul/repo/arduino/hack-the-hive/hack-the-hive.ino:21:0:
/home/paul/repo/arduino/libraries/Low-Power-master/LowPower.h:134:10: note: void LowPowerClass::idle(period_t, adc_t, timer4_t, timer3_t, timer1_t, timer0_t, spi_t, usart1_t, twi_t, usb_t)
     void idle(period_t period, adc_t adc, timer4_t timer4, 
          ^
/home/paul/repo/arduino/libraries/Low-Power-master/LowPower.h:134:10: note:   candidate expects 10 arguments, 8 provided
exit status 1
no matching function for call to 'LowPowerClass::idle(period_t, adc_t, timer2_t, timer1_t, timer0_t, spi_t, usart0_t, twi_t)'

I can see from the code that there are some preprocessor conditionals:

#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168__)

... etc...

How do I know which function signature I should be using? It would be super helpful if the README could give a hint on this.

Thanks!

Closed issue "'power_usart3_enable' was not declared in this scope" not fixed

Hi there
The Arduino Mega 2560 issue still not fixed.

In Arduino Compiler 1.8.5 we get this error:
LowPower.cpp:597: error: 'power_usart3_enable' was not declared in this scope
if (usart3 == USART3_OFF) power_usart3_enable();
exit status 1
'power_usart3_disable' was not declared in this scope

For your information, its working with Nano, and Uno.

Br Tvix

Support ATmega644P

Hi,

I would like to know how is different between ATmega328P and ATmega 644P. I try to rename to accept the library but look like turn off ADC and BOD doesn't help to save more power. Lowpower still work but it drains about 313.9 µA

Thank you very much

TX Led

I am wondering why when I use LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
on board TX Led is turn on and exiting this function is turn off? I use Arduino Nano 3.0 clone.

Feature Request: ESP8266 Support

Hi!

First of all, this library is great! It greatly reduces power consumption without any real effort.
That's why I'm interested in something similar for the now very popular ESP8266 which is seriously power hungry. I think you'd make a lot of people very happy.

Thanks for considering and keep up the good work!
Brent

idle mode with timer0_ON

Hi,
I am trying to put arduino pro mini to sleep in idle mode with timer0 enabled. Arduino does not seem to sleep at all. The following code reproduces the problem.

unsigned long t1 = millis();

Serial.println(t1);

delay(10);

LowPower.idle(SLEEP_8S, ADC_OFF, TIMER2_OFF, TIMER1_OFF, TIMER0_ON,
SPI_OFF, USART0_OFF, TWI_OFF);

delay(10);

unsigned long t2 = millis();
Serial.println(t2);`

I am using atmega328p with optiboot bootloader
Any ideas?
Thanks

Current consumption on SAMD board?

Has anyone done the power calculations on the ATSAMD21G18A processor for each of the examples? Can we hit 4.4uA as it says in the datasheet? How much current is drawn when using external interrupt, using WDT timer, etc?

I wish the community adopted the SAML21 series which is geared towards lower sleep current.

Thanks!

Sleep for 4 hours

Congrats for this great library!
I'd like to sleep the 328p for 4 hours. How to do that in order to use the least power possible ( < 0.01 mA) ?

Conditions in which powerDown current is measured.

Hi,
I am using this library with my own controller board and I am doing power down with ADC and BOD off but not getting anywhere close to 1.7uA I am still at minimun 500uA,... and Have nothing on IO port for this reading my voltage is 3.3 volts and also its is running at internal 1Mhz with 8Mhz/8 internal.
So I am want to know exactly at what conditions this 1.7uA was measured... I am expecting to go below 100uA.

request for improvement

For the wrong running of timer2 interrupt, is it be able to revise lowpower to achieve the similar function of a interrupt?
such as call for LowPower.powerSave(SLEEP_8S, [func_name], ADC_OFF, BOD_OFF, TIMER2_ON);
when time is up, the arduino would be waked and the [func_name] would be called.

ADD ATMEGA8/8A support

hey there
as the library already contain the atmega328 support
i want add atmega8 support to the library.

can i add it by add or editing some codes? how? :D

'SLEEP_MODE_EXT_STANDBY'

C:\users\xxxxx.platformio\lib\Low_Power_ID38\LowPower.cpp:985:17: error: 'SLEEP_MODE_EXT_STANDBY' was not declared in this scope`

C:\users\xxxxx.platformio\lib\Low_Power_ID38\LowPower.cpp:985:3: note: in expansion of macro 'lowPowerBodOn'
lowPowerBodOn(SLEEP_MODE_EXT_STANDBY);

Running on:
platform = atmelavr
board = pro16MHzatmega168
framework = arduino

compatible with the mini ultra pro?

I saw that this library was compatible for the mini ultra pro board, but it seems that they were written for the Arduino ATmega boards and the mini ultra pro board is compatible with the Arduino Zero boards?

How

Dear...
I try t use your sketch..
Only no luck...
Please do now/have a YouTube how to for me...

Or do you have a sample sketch for mysensors?

Perhaps that can help me forward..
Thanks

Low Power external interrupt error porting between 328p and 32u4

Hi,
I am using the Low Power example library as directed by you in the externalinterrupt example.

I used it on the Arduino UNO (328P) and it worked perfectly with my pushbutton w/ resistor and capacitor pulldown pair for the RISING interrupt configuration. (i.e. when OFF, the interrupt was pulled down to GND and then with the button pushed it rose to 5V.) This worked perfectly on the UNO when using digital pin 2 (i.e. attachinterrupt(0))

when I try to port this logic to the Arduino Micro (32U4), the same configuration but this time at the external interrupt at digital pin 7 on the Micro, it fails to wake the arduino micro up. I have checked and re-checked to be sure that I'm not using anything else on that pin and also don't have anything changed between the set-ups other than the pin number.

I could really use the help, am I missing some critical difference between the 32u4 and 328P that is not the different pins that allow for external interrupts.

P.S.
-I have also tried to use the different trigger modes and none of them seem to work.

-I have put an indicator LED to make sure that the voltage actually does go up when I press the button.

Arduino 1.6 support (?)

Hi!

We have based our HW design on your Arduino Ultra for a couple of years now.

We are producing a new board upgrade, So I am currently testing low power.

I noticed that the maximum low power mode (1.7 uA) can be achieved with Arduino 1.0.

However, with Arduino 1.6, with the same sketch, library and HW it measures 20.5 uA instead.

For testing I use the external interrupt example provided with the library. Slightly modified by enabling the internal pull-up resistor on the wakeup pin, or the Interrupt routing keeps getting called.

On my board, I only have the ATMEGA 328P, Resonator, Regulator, and the few passives required.

I would say some flag is not getting passed or ignored in Arduino 1.6? I thought I would ask before looking into it...

Have you noticed this? or is it just me?

Rafael

Feature Request: Add Support for ATMega1284P

ATMega1284P is not currently supported. It's quite similar to the ATmega328P though looking at the respective datasheets section 10.1 Sleep Modes. Happy to help test using my WildFire ATmega128P-based platform if you can give me some direction. /cc @vicatcu

Please rename 'Examples' to 'examples'

Having 'Examples' instead of 'examples' on case-sensitive file systems causes Arduino fail to properly detect. Extra menu level is then inserted - File / Examples / Low-Power / Examples.

Screenshot at bug

Thanks

flush problem with the modem serial

Hi, I need some help with finding the issue. I want to put my board to sleep for a bigger amount of time so I've created a function which repeats 8sec sleep command. In the example code below everything is working but in my complex project the problem occurs. First 9 cycles doesn't sleep and after that 10th call is working. Any clue what can affect this? Thanks.

#include <LowPower.h>

void lowPower(uint16_t len){
    for (uint8_t i = 1; i<=round(len/8+0.5); i++) {
      Serial.print(i);
      Serial.flush();
      LowPower.idle(SLEEP_8S, ADC_OFF, TIMER2_OFF, TIMER1_OFF, TIMER0_OFF, SPI_OFF, USART0_OFF, TWI_OFF);
      Serial.print("/");
      Serial.flush();
    }
}

void setup() {
  Serial.begin(38400);
  lowPower(30);
}

void loop() {
}

Nrf24l01 not working after sleep

I have multi pir (4) with nano atmega128p, nrf24l01.the pit will trigger the onboard led but not the radio. I have tried every lib I can find to no avail. All I want is to save changing 4aaa batteries every few days. I tried the code at start , end of void(loop). Any help?
#include <SPI.h>

#include <nRF24L01.h>

#include <RF24.h>

#include <LowPower.h>
int transmitterId;

// Set up nRF24L01 radio on SPI bus plus pins 9 & 10
//Contacts from the radio to connect NRF24L01 pinamnam -> Arduino

//SCK -> 13
//MISO -> 12
//MOSI -> 11
//CSN -> 10
//CE -> 9

RF24 radio(9, 10);

// this is not the channel address, but the transmitter address
const uint64_t pipe = 0xE8E8F0F0E1LL;

//button connected to these pins

int buttonPin1 = 2;

void setup() {

// CHANGE THIS PER EACH TRANSMITTER, from 0 to 4
transmitterId = 1;

radio.begin();

// the following statements improve transmission range
radio.setPayloadSize(2); // setting the payload size to the needed value
radio.setDataRate(RF24_250KBPS); // reducing bandwidth

radio.openWritingPipe(pipe); // set the transmitter address

}

void loop() {

LowPower.powerDown(SLEEP_2S, ADC_OFF, BOD_OFF);

//until the button (buttonPin1) pressed send the package (id) to receiver Arduino
if (digitalRead(buttonPin1) == HIGH) {

	// some implementations automatically shut down the radio after a transmission: this
	// ensures the radio is powered up before sending data
	radio.powerUp();

	// read and write expect a reference to the payload (& symbol)
	// second argument is the packet length in bytes (sizeof(int) == 2)
	radio.write(&transmitterId, 2);
}

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.