Hot answers tagged

11

A board we make does this. The RX pin is wired to INT0 INT0 pin set to input or input pullup depending on how the RX line is driven On sleep, INT0 low level interrupt is enabled //Clear software flag for rx interrupt rx_interrupt_flag = 0; //Clear hardware flag for rx interrupt EIFR = _BV(INTF0); //Re-attach interrupt 0 attachInterrupt(INT_RX, ...


9

Yes, if you want to wake an ATMEGA (the chip in the Arduino) spontaneously (no outside trigger) from Power Down mode at periodic intervals, the you will need to rely on an interrupt generated by the watchdog timer, which has a maxim timeout of 8s. Your goal should be to wake, increment and check the timer, and get back to sleep as quickly as possible since ...


7

The code below achieves what you are asking: #include <avr/sleep.h> #include <avr/power.h> const byte AWAKE_LED = 8; const byte GREEN_LED = 9; const unsigned long WAIT_TIME = 5000; ISR (PCINT2_vect) { // handle pin change interrupt for D0 to D7 here } // end of PCINT2_vect void setup() { pinMode (GREEN_LED, OUTPUT); pinMode (AWAKE_LED,...


6

This is what I have managed to achieve ... Library IRLib - GitHub Version 1.51 March 2015 Copyright 2013-2015 by Chris Young http://tech.cyborg5.com/irlib/ This library is a major rewrite of IRemote by Ken Shirriff which was covered by GNU LESSER GENERAL PUBLIC LICENSE ... Code Modified code (from the demo IRrecord example): /* Example ...


6

This sketch is almost identical to the powerDownWakeExternalInterrupt.ino sketch that comes with the LowPower Library. I'm using INPUT_PULLUP and a N.O. push button switch to trigger it to wake up and turn an LED on. #include "LowPower.h" const byte wakeUpPin = 2; // Just a handler for the pin interrupt. void wakeUp(){} void setup(){ // Configure wake ...


5

2.9V doesn't sound too bad. See a datasheet for the CR2032 I found: It looks like slightly more than 2.9V would be the expected voltage for up to 600 hours. 3.2V looks like it is fully charged, and won't stay at that level for long. Having said that, 200 µA current sounds like a lot. You should be able to get it down to 6 µA. Perhaps post your schematic? ...


4

You need to first check the individual current consumption of all elements: pH sensor, temp sensor, water flow sensor xbee. Since many of these just have an output pin in addition to +V & GND, this means those have a permanent current consumption that, overall, may possibly drain your battery. You should then check the datasheets for all these ...


4

"sleep()" is not a function on arduino. The sleep.h file contains functions for the hardware sleep functionality used to reduce power consumption when processing isn't necessary. "delay()" is the right thing to use. AVR only has one thread, and so there is no meaning to pausing execution by deferring to another thread. Hardware interrupts will always ...


4

Have a read through the Jeelabs blog which documents the author's very successful attempt at making a very low power wireless sensor node that can run for months off coin cells. http://jeelabs.org There is also a library based on this project called Jeelib: http://jeelabs.net/pub/docs/jeelib/ Jeelib contains a class called Sleepy that allows for easy ...


4

The first and most smart solution is to use a switch between the batteries and everything else. This way, you slide the switch in the off position and the whole circuit is completely detached from the batteries: power consumption: 0. If you can't (because, for instance, you want it to automatically power off after a while) you can use a transistor (PMOS, ...


4

You won't manage it without external circuitry. The problem is the Arduino has to be awake to know you held the button for 3 seconds. You can only wake immediately you press the button. However you could then sleep again if the button is released within 3 seconds. For external circuitry, you would need to arrange to charge (or discharge) a capacitor ...


4

While it looks interesting as idea, IHMO you have keep in mind: Include some code for button denouncing logic. Actually you will receive couple of “resets” during ~20ms during button press. Without denouncing you may end up with reset signal right at the moment you write to the EPROM. While EPROMs are pretty “solid” nowadays, it many not be good practice. ...


3

The error you posted has nothing to do with an Arduino core. This is just plain avr-libc stuff. In order to use this kind of functionality, you need to #include <avr/io.h> In the Arduino core, it is common to have this done by default. But if this is not the case with your chosen core, just add the #include yourself in the program.


3

I tried your first sketch on my "bare-bones" board. With the sketch exactly as written, it used 197 µA. I wondered why it was that high, so I commented out this line: Serial.begin(9600); That reduced consumption to 122 nA. See Power saving techniques for microprocessors. You need to get rid of any "power" LEDs, and disconnect any voltage regulators. ...


3

Yes. Arduino's buffered serial output is interrupt-based, in that it uses interrupts to refill the UART transmit register when it runs empty, until the software-managed transmit buffer has been drained. You cannot put the ATmega back to "lasting" sleep until the last byte of the serial transmission has been written to the UART hardware. If the goal of ...


3

avr/sleep.h is part of the compiler. You don't need to download it. There are other libraries that act as a wrapper to it to make life easier: https://github.com/lowpowerlab/lowpower https://github.com/rocketscream/Low-Power


3

Rather than trying to update TCNT0, it might be better to track the number of cycles lost to ADC conversions, and in an intermediate routine – eg, omillis() – compensate for those cycles. [Edit: See better alternative, below] In more detail: • At each conversion, add about 128·13 cycles (or perhaps 128·13.5, to account for average prescaler delay) to a ...


3

Given the absence of clarity on the driving state of pins during sleep, consider connecting Pin 13 to an SR Latch or the gate of a MOSFET. An SR Latch will hold it's output high or low until a high is presented on the Set or Reset inputs, so connect Pin 13 to the Set input, with a pull-down resistor -- even if the MCU in sleep mode allows the voltage output ...


3

can a voltage be maintained on a pin for all/any of the sleep modes? yes.


3

Start by checking your calculation of time limits. I see you are mixing signed and unsigned arithmetics - not a very good idea. Check the blink-without-delay example for how to do that. The declaration of timer_start_time should be paid special attention. Good luck with your project!


3

Well, this code worked. In this code, MPU's INT PIN is Active Low so generates Ground on motion which is than connected to INT0 or arduino UNO pin 2 which generates interrupt and wakes UP the MCU #include <avr/sleep.h> #include <Wire.h> //Analog port 4 (A4) = SDA (serial data) //Analog port 5 (A5) = SCL (serial clock) #define SIGNAL_PATH_RESET ...


3

Yes, activating low power does disable the UART - but only while it's sleeping. To use serial you just need to ensure that you only use it while it's not sleeping - and due to the interrupt and buffered nature of the Serial driver it's not as easy as just printing. However, it's simple to achieve: just flush the serial before sleeping. This ensures that ...


3

All your music playing code is inside a interrupt. While an interrupt is running all other interrupts are disabled. It's advised to keeps interrupt routines as short as possible. You could have the interrupt routine set a boolean variable. Then in the loop function read that variable and call the play-music function. volatile boolean startPlayback = false;...


3

The example shows a Sparkfun Thing, which the article notes doesn't have extra peripherals. What you show is something different, like a NodeMCU dev board, which typically has a linear regulator, possibly a power LED (which the article notes can be removed). I see you're using a DHT11 or DHT22, which has a pull-up resistor. The pull-up resistor is ...


3

You're making it too hard on yourself. There is a method to re-start the USB, but it only works if the USB has been properly stopped - and the method that is supposed to do that is empty. This is a little sketch that works on my Leonardo: #include <LowPower.h> void setup() { } void loop() { USBCON = 0; LowPower.powerDown(SLEEP_8S, ...


3

In order to make the ultrasonic sensor work, the Arduino has to run some code to control it. So it won't do anything while the Arduino is asleep. What you can do is have the Arduino sleep for some reasonable amount of time, wake up and read the sensor, and then go back to sleep. Maybe wake it up once every few seconds. Do you really need to react to a ...


3

ATTINY's are designed to easily do this since they can wake from power down sleep mode by a pin change... Basically you want to... Connect a normally-open push button between an IO pin and ground. Enable the pull-up on the IO. Enable the pin change interrupt on the IO pin. Enable interrupts. Enter "power down" sleep mode. When the button is pushed, it ...


2

Question #1: Can a change on pin 7 wake from sleep? Yes. The lowest power mode for this chip is Power-down, and you can wake from this state with a pin change interrupt. Assuming that the soft-serial code you are using already enables interrupts on the pin for its own purposes, then you should just be able to sleep and the part will wake on the next pin ...


2

Only low level detect is possible with external interrupt pins (INT0/D2 and INT1/D3) in power down sleep mode. The signal must be low for a number of clock cycles to be detected and the interrupt will detected while the signal is low (and the interrupt is enabled). It is not a transition. A pin change interrupt could be used instead. For more details ...


2

The INT_GEN_CFG_XL 6-Direction detection interrupt apparently is aimed at detecting change of direction of travel, rather than an axis-combined acceleration level. See the LSM303 discussion at Polulu.com. That page includes a link to App Note CD00290365.pdf for the LIS3DH. Here is what that app note says, on page 27: There are two possible ...


Only top voted, non community-wiki answers of a minimum length are eligible