arduino nano power consumption


The red LED switch is on for a second and then switches off for a second now I’ve put some meter probes into the ground line. It could have been the VCC line, but the ground line was just easier because I want to measure how much current listings, drawing and on the sino meter it’s kind of around 16 milliamps. Now it keeps flicking backwards and forwards and that’s because of course, we’re. Turning. The little red LED on and off so what I’m going to do in order to stop it doing that, instead of the blink program, which is there I’m going to actually open the bare minimum sketch so there’s, the sketch called bare minimum. It contains no code in the setup function and no code in the loop function, so it’ll do nothing. Okay, let’s, send that to the board, so it’s compiling on my little FTDI board, wait for the red and green lights to flicker. I think that was it and now the LED won’t be flashing on and off, but it is running the code, the sort of Arduino overhead code it’s, just not doing anything let’s see how much current it consumes to not do anything so it’s about 14 milliamps. Now, that’s a lot 14. Millions is a lot of current, and what made me want to do this is that my little OLED project with the OLED, the 3.3 volt Arduino they’re running from a little tiny lithium polymer battery.

I really wanted to run for as long as possible and not to run the battery down too quickly and when I let this run just until the battery did go flat, it only ran for about two hours now the battery wasn’t fully charged. So I might get four hours out of it, but even so it would be nice if I could do something to get a bit more time and turning the display off after a period of time would be one way, but also reducing the amount of current that The Arduino draws would be another aim, another goal so here’s the data sheet for the AVR microcontroller 80 mega 328p, which is the chip on that nickle pro mini. Now. This is a beast of a datasheet. This is four hundred and forty pages of stuff. Now I was reading all about the system clock and in section 811 system, clock prescaler. It says this feature can be used to decrease the system, clock frequency and the power consumption when the requirement for processing power is low. So what it means is that we can slow the clock down using this system, clock prescaler and the chip should use less power. Now there’s a register called clock PR. The clock, pre scale register and bits 7, 3, 2, 1 and 0 are relevant in here. If you scroll down a bit, you can see the pre scale factors for bits: 3, 2, 1 and 0. If you have all zeros the top line, then the pre scale ratio is 1 to 1, so it will run at the full crystal speed, but you can then divide by 2, 4, 8, 16, 32, 64, 128 or 256.

Now the pro mini uses a 16 megahertz ceramic oscillator, ceramic resonator is called, and so if we have a one to one pre scale, then the internal workings of the chip will also run a 16 megahertz. But if we had a two to one pre scale where you could get the internal workings of the chip to run a 8 megahertz and we might find that the power consumption drops from that 14 millions let’s give it a try now there’s a locking mechanism to Stop unintentional changes of clock frequency. A special right procedure must be followed to change the clock. Ps bits we have to do is you have to set bits 7 and put all the other bits to zeros that’s number one there and then on number 2 within 4 cycles, so fairly quickly. Afterwards, you’ve got to write the value you want to the lower four bits in clock PS with bit 7 reset so into the bare minimum. Sketch I’ve. Just put these two lines: clock P: R equals hexadecimal 80 clock P R equals hexadecimal 0 1. So the second line down there zero zero zero one that’s, oh one and the clock division factor will be 2, so the internal workings of the chip will now be running at 8. Megahertz so let’s send that to the chip, and it goes wait for the FTDI LEDs to come on there. They go and the 14 milliamps now drops to about 10 milliamps let’s go a little bit further, so I’ve now got the second line as hexadecimal.

Oh two: that will divide the clock by 4 that should result in 4, megahertz internal, so currently 10 milliamps waiting for the FTDI there. It goes and although the initial current is hard because, of course, the chip when reset goes to its initial frequencies, that’s now dropping to 8 milli amps, so we’ve gone for 14 to about 10 to about 8 let’s, see how much further we can take this let’s. Take the fifth line down that’s: Oh 100, 16 division factor, so that will divide the 16 megahertz clock down to a 1 megahertz. Oh 100 is 4, so the second line there hexadecimal Oh 4, and that expecting that eight milliamps to drop FTDI there goes the program. We got that’s going down towards 6 milliamps. Now we could take this further. We could divide the internal clock in total by a division factor of 256 and that would actually take the internal workings of the chip down to about sixty kilohertz, which is very slow but actually there’s a bit of diminishing returns. Here you can keep going and you only get down to about five milliamps that’s, the the lowest current that you can get this chip to take just by reducing the clock frequency now. Just for a moment, I’ve gone back to the blink program and I’ve added those two lines of code: clock, P R is a T, hex and clock P R is four hex into blink and we’ve got the thousand millisecond delay for LED, high and or so thousand Milliseconds for low, but it does have an implication on the operation of the delay routine, and you can see there that the LED is off and off for quite some time and I’m gon na have to hold it here for a little while before that comes back On and there it is on now it’s fairly obvious that that is not coming on for a second and going off for a second, in fact, it’s coming on for 16 seconds and going off for 16 seconds, we do have our lower current value.

Now that eight point, nine or nine milli amps dropped to six at the point where the LED went off but because the clock is running 16 times slower than the Arduino is expecting the delay routine. The delay function is operating sixteen times slower as well, so let’s compensate for that by changing those delays so that they are 116 of a thousand. Now what’s, the sixteenth of a thousand 116 of a thousand is actually 62 and a half so I’ve put 62 milliseconds into the two delays. Now 62 milliseconds would be quite a short delay if the chip were running at the normal speed. But we can see that it’s not running at the normal speed, and that has given us that one second on one second off delay, because it’s sixteen times as long as the delay routine is being told to delay it. Actually, one thing I didn’t say – and I should have done, is that I took the resistor out from the power LED just there next to the three terminal regulator, because I wanted to remove that LED, which is just on all the time to get a fair assessment Of how much current this thing is taking so slowing down the clock, prescaler has given us a lower current consumption, 14 milliamps down to 6 milliamps, but it does have implications for the delay function. It will also affect the operation of the Milly’s function and because it’s slowing all the synchronous registers in the chip down, it will also affect pulse width, modulation, frequencies, so they’re, normally 490 Hertz and something over a kilohertz.

I confirm what it is. They would be scaled down by a factor of 16 as well. If you slow the clock prescaler, but 6 milliamps is still a fair amount, and I wanted to take this a bit further. So in section 9 power management and sleep modes, if you come down to nine point, nine at 9.10 minimizing power consumption. We have this minimizing power consumption. There are several possibilities to consider when trying to minimize the power consumption in an AVR control system. In general, sleep modes should be used as much as possible and the sleep mode should be selected so that it’s blah blah blah. So what it’s saying is we need to look at putting the microcontroller to sleep, to get the power to go even lower. Let’S have a look at how that’s done so. We’Ve got the sleep mode, control register smcr, and we can write to the lower four bits of that three term. One are the sleep mode according to this table here, and there are eight sleep modes: the lowest power. One is power down the third one down and then bit zero up. There is sleep enable which is there, so we need to set that to a logic, one, but then right at the bottom there. It says the sleep instruction and that’s, where we’ve got a bit of a problem to actually make the microcontroller go to sleep. We have to issue this assembly language instruction, sleep instantly I’m in section 31.

Now now I can’t just write sleep in to the C code because it won’t have it, so this has to be done a slightly different way, so I’ve had to bring in a library it’s that line that says hash include: AVR sleep, dot, H now, it’s a Built in library it’s, not anything you have to install, so you can just write that line of code in and it will pull it in and then there are three instructions: further down set the sleep mode and I’ve gone for power down because it’s, the lowest power Of all the modes sleep enable – and this is another one of those two step processes – to prevent accidentally, putting your microcontroller to sleep when you don’t want to, and then that last instruction sleep CPU is the C function which contains the assembly. Language command sleep, and this should, if I compile it, put the microcontroller to sleep let’s, see if it works, send that compiling see if it gets transferred there. It goes so that should now be asleep and there we are so no longer have we got any milliamps we’ve got naught 0.23 milliamps, so that’s, two hundred and thirty micro amps. So finally, we’ve got the Arduino compatible Pro Mini to use a tiny amount of power. Now, coming out of sleep requires the use of interrupts and that’s a little bit more complicated. But I was thinking on this data display project. The unit could display data on the OLED for say, 10 or 15 seconds blank, the OLED and then just go to sleep, and that would mean that the chip would be using very little power and then to display the data.

Again. You just press reset. The program restarts from the beginning and it would display the data for another 10 seconds and as we approach spring. My thoughts, of course, are turning once again to the MPPT solar charge, controller project, and I was just thinking if we could use some of those techniques.


arduino nano power consumption Video







arduino nano power consumption news








arduino nano power consumption Social






See the world through the eyes of this camera-equipped, snake-like robot.
safe image.php?d=AQB2kdm3zOD71KQX&w=720&h=720& content%2Fuploads%2F2019%2F09%2FUntitled 2 3 - arduino nano power consumption

This 3D-printed prosthesis uses computer vision to adjust its grip depending on the object.
safe image.php?d=AQD dQbotzfS6mLl&w=720&h=720&url=fbstaging%3A%2F%2Fgraph.facebook - arduino nano power consumption



Originally posted 2015-11-17 04:37:27.

(Visited 99 times, 2 visits today)

About The Author

You might be interested in

Comment (24)

  1. 4:24 Oh my a pro like you using an old maplin knock off ? Mind you I have the same one – it must be around 15 years old now and is still working

  2. Hi Julian, thanks for the detailed info. I did the same as you described with the clock dividing. code is running well but serial monitor on pc always has only special chars and not the ones it should. Is there a trick to let the serial monitor work correct after clock speed changing?

  3. Firstly: Thanks for the vid.
    Secondly: Did you notice a current reduction when in deep sleep and reducing the clock? Because I was testing with an arduino nano, and without sleep mode the current goes down quite a bit with clock reduction (from about 15 mA at 16mHz to about 5.8 mA at 1 mHz). However, in deep sleep (using the low power library, ADC_OFF, BOD_OFF) the clock frecuency doesn’t seem to have any influence (1.90 mA for ALL frecuencies). I suspect that those 1.9 mA are due to the USB port (arduino gets powered throught the 5V pin)

  4. Your are converting 5v pro mini into 3.3 volt 8mhz that is already available in market . Two versions 5v and 3.3 volt pro mini !!????

  5. Before watching your excellent video, I attempted to cut the clock frequency in half by selecting the 3.3V , 8 mHz option in the Arduino IDE before loading my program. The code I loaded was originally written to run at the standard 16 mHz, and it generates various tones separated by delays. I’m using a 5V, 16mHz Arduino Pro Mini, but (except when programming) I’m bringing in battery power on Vcc (bypassing the 5 Volt regulator), on the assumption that the 328P won’t care about the voltage as long as I stay within the voltage limits of the 328P. To my surprise, this actually made the delays shorter and the tones were a higher pitch, as though the clock was running at a higher frequency than 16 mHz. Then, I added your two lines of code to Setup, to change the clock frequency to 8 mHz, and I reloaded the program using the 5V, 16mHz option in the IDE. Now the delays are twice as long and the tones are lower in pitch than they are at 16 mHz, which is what I expected. I’m still trying to figure out why using the IDE to change the clock frequency to 8 mHz seemed to cause the 328P to act as if the clock frequency had been doubled, instead of cut in half. What am I overlooking?

    1. You need to read datasheet section CLKPR register. This section explains that CLKPR register setup clock prescale system and it’s has 7 bits < (bit7-bit6-bit5-bit4-bit3-bit2-bit1-bit0)> for read/write register. So the <7 bits> is”CLKPCE” sub-register on CLKPR and allow you enable a change over clock system before you setup clock prescale value with the bit 3 to 0 on CLKPR. The BIT7 CLKPCE register is only “OK “setup, if you simultaneosly written to zero the bits6 to bits0 on register general CLKPR. So this is bit7[1]-bit6[0]-bit5[0]-bit4[0]-bit3[0]-bit2[0]-bit1[0]-bit0[0] = 1 0 0 0 0 0 0 0 and if you take bits in two group of 4 bits you obtain [1000]-[0000] that is [8]-[0] in hexadecimal value. So you can use CLKPR = 0b10000000 or CLKPR=0x80 when index “b” is binary value and “x” is binary value register setup.

    1. no but the sleep modes on a wemos d1 mini use about 1/10th of the power as this arduino. I use a wemos d1 mini in a weather station and can get over a week out of a 400mah lithium battery if i disconnect the solar panel.

  6. hello Julian i have tried this many times and one problem i have is that when in sleep mode i can not get below 2.06 ma no matter what i do.

  7. Great video – is there a way to sleep for a duration (eg. if you wanted to wake up and do something every 5 minutes)?

  8. I also disabled the ADC and Brown-Out and got the board down to 22uA.
    I had trouble with the onboard Linear Regulator. Mine was a SOT23 L05 (3 Legs), yours is a SOT23-5 LG50. (5 Legs)
    It was drawing 2.2mA at start, but current draw kept increasing as time went by.
    I tried powering the board from 12V initially, but then I powered everything from 5V and I got the same 2.2mA current draw.
    So I started removing components from the board (Crystal, Linear Regulator, Resistors, Capacitors)
    I started looking into 7805 datasheets and I saw a Typical Quiescent Current of 3.2mA.
    So be aware of cheap Chinese boards if your are looking into Low Power stuff.


Your email address will not be published. Required fields are marked *