[adrotate banner=”7″]

There are some other boards made by other manufacturers that have it on there. I’M gon na use the maker 1000 in this example, because it is less I’ll, say components around the sand chip, so it doesn’t those components are going to suck some of the current out. So the 0 has a lot of those components, so we’ll be working with the maker 1000, but everything we we show here will work on the 0 as well anyway. Let’S get started. Ok. What would we cover in part? 1. So part 1 we’ll do an overview of the different power save modes or sleep modes of whatever you want to call them. Then we’ll show an example, and this is you know, 80 or 70 percent. If you, if you want to save power, this is probably the best way putting it to sleep and how to wake it up. So if we can put it to sleep, it draws very little current and then we can wake it up. We can use a timer to wake it up from an alarm using the real time clock or we can use an external pin. You know a digital signal or rising edge on an external pin to wake it up and we’ll show both of those examples. In this video now you can wake it up a bunch of other ways too as well, but those are the two examples we’re going to use in this video what’s. Nice, too, is those features are supported by Arduino libraries, so you don’t have to get down to the register level, for these features that I’m going to show you, but I will do a little peek under the hood and kind of show you how we change a Certain clock we’re, using in the the current real time, clock library.

We can actually save a little more power. Ok, sam d, 21, sleep modes, so basically there’s four of them. I mean there’s two, but one of them has three levels, so you have standby mode. This is the biggest power saving mode, so we can’t it turns everything off, except for a low power. Internal 32 point something something kilohertz clock so that’s. The only thing that stays on it also keeps it’s an internal later on, but it goes into low power mode. The standby modes, what we’re gon na show in our example this is the best way to save power. Now, like I said it turns everything off. So if you want a certain module to stay on and you want that module to wake the chip up, you have to specify you have to tell that module to stay on and standby mode. So once again, standby mode turns everything off, but you can choose which modules to leave on by specifying that before you go to sleep, then the idle mode. Basically, doesn’t, you know save as much power and it keeps certain things on depending on what idle mode you use. You know, that’ll depend on what it keeps on so I’m, not gon na go too much in the idle modes. Here now I might talk to talk about them in a later video, okay. Here I pulled this from an application note that shows some of the different peripherals while they’re in standby or sleep mode, and if you keep them on this, is the current bill draw.

So remember how I said: standby mode turns everything off. Well, you can specify things to leave on and typically you specify something to leave on that’s gon na trigger the chip to wake up when it needs to that might be a navy seal ‘evil. It might be spy communication, it might be an external interrupt that’s, what a IC stands for and what they’re doing here is there so it’s saying if you keep this module on or this peripheral here’s, how much current the Sam d 21 will draw when it’s asleep. So notice this is in micro AB, so these are pre small, current levels. Now, when we look at the example with the maker 1000, we won’t see this lower levels and the reason is is because you have other chips and pull up resistors and things like that. Around the Sam D 21, but these are essentially if we were just looking at the current for the Sam D 21. These would be the current levels. We would expect now notice this caveat. So if you know I’m used to working with the AVR chips in the past, I’ve been ramping up more and more with the Sam D 21, and this is so much more flexible and a lot more feature risk than the AVR chip. So this is one example. Is it has all these different built in clocks? So you have the external clock. You have an external 32 kilohertz clock, you have an internal 32 kilohertz.

You have internal eight megahertz clock, so you have all these clocks and you can pick where which module you want to use for that clock. So what they’re saying here is these: are the clocks used for these measurements, and one thing to point out: is some of these clocks use more power than others? So, for instance, when we look in an example, the library uses this the external 32 kilohertz clock for the real time clock timing, we’re gon na actually show an example where we switch it to this one. This is the internal 32 kilohertz clock, that’s, actually lower power. Now, what you’re, sacrificing, though, is accuracy, but the the important thing I want you to remember is you can route these clocks to any peripheral you want and the clocks themselves draw different levels of power. Okay, now let’s look at the code for the examples we’re gon na show and so we’re looking at code on how to wake up Arduino from real time from the real time clock and also how to wake it up from an external event, using an interrupt on An external pin, okay: here we are with our code. First thing we want to do is call in the real time, clock, library notice. It says zero, but it’ll work on any of the Sam D chips, like the maker 1000 notice that I have this one commented out. This is was a local version. I made with the slight change that I’ll show in a second and by the way, I’ll put this code on my blog, so you can access it.

I create my real time clock object. These variables basically are variables to set up the real time clock. So you have day month year and you have times I’m just using 0 seconds, because I don’t really care what I set the time to in my setup code. I delay for a thousands one thing I want to say with the maker 1000, then this isn’t as big a problem with the zero, but with the maker 1000, be careful that you don’t put it to sleep right away and have no way to wake it up, Because if you do that, you’re gon na have trouble programming that board later on, because it will not wake up from from the serial programmer. So if you put it to sleep and you have no way to wake it up, you may have to reprogram it. So if you’re playing with sleep modes that end up putting the chip to sleep or you’re worried, might put the chip to sleep without a way to wake it up, make sure you have a long delay in the beginning. So you can use that delay to get the chip programmed, so I set up the digital LED pin for low, so the LEDs off will turn it on later. I start up the real time clock I set the time as well as the day month year. I then set the alarm so notice that I set the time to zero zero, zero, zero, zero here I’m setting the second part to 10 seconds, so basically it’s gon na go off if, after 10 seconds of going to sleep or after 10 seconds of the real Time, clock starting a then enable the alarm, so I have to actually enable the alarm and then I attached the interrupt.

So I enable the alarm attach the interrupts and, if you’re not familiar with interrupts, I have the videos on interrupts, but basically the function. That’S gon na get called, I called ISR for interrupt service routine. So once the inter up happens, this function, which is down below I’ll, show it in a second will be called, and once the interrupts happens, of course, it’ll wake. The chip up from sleep notice. This function right here, I have it great a commented out. This is, if you want to use an external interrupts. So, instead of using the alarm, you want to use an external pin to wake it up. You’Ll call this function and I have it commented out now, but if you wanted to use an external interrupt, you would comment this out. These two lines, like I note up here in the comments and you would uncomment this line – to use the external, interrupt and notice I’m feeding in a 1 to that so I’m, using a 1 as the external interrupts and will show an example of that. Then this is where we’re actually put to sleep as when we call the real time clock standby mode that puts it to sleep now. I have another function here commented out. This actually shows what’s going on under the hood for the standby mode, which I’ll show in a second. So what happens? Is we set up the real time clock if we’re using it as our wakeup source? We then set the alarm and attach the interrupts if we’re, using the external pin as our interrupts source.

We then use this function. We then go to sleep and then in the we do nothing. So once we go to sleep, the code stops here until we wake up from the interrupts. After that we stay awake and we just loop in the function. Now, if we go further down here’s our interrupt service routine, so is our. This is called once the alarm goes off or for using the external pin, the external pin level goes low, this is called, and what this does is just just turns on the LED here is the external interrupt function, so you feed in the pin and what’s nice About the Sam D, 21 is compared to some of the AVR chips. Is you can use almost any pin as an interrupt pin I’m gon na use pin a1? So here with pin mode I set to an internal pull up. So that means, if the pin is floating it’ll be pulled high. I then attach interrupts, and this is a standard Arduino interrupts function. I say the pin, which is a 1. I feed in there, like all the same, interrupt service routine function that I do with the alarm. So it’ll turn the LED on. I then say you know trigger the interrupts once a low level is felt on the the external pin a1. Now you know if you’re familiar with the attach interrupts function. If you go to the Arduino page for this, you can do hi.

You could do rising edge, falling Ed’s or change in level, so there’s different ways you can choose to trigger the interrupts, then I’m, not using this function, but I just put it here just for your reference, so this is what’s actually happening underneath the hood. When will they call? The standby mode? Function basically, is using. You know, lower level stuff from the Atmel software framework library, which you can look up, and then it calls this function right here. Wait for interrupts. So here I should say we set it to standby mode, which is deep sleep here. This is where we actually put it to sleep with this wfi, which stands for wait for interrupt certain note on that function. That is actually an ARM architecture function. So you won’t find this function in the Atmel documentation, or at least it’ll be buried in the Atmel back. But if you go to the armed community, you know this is a function that that arm uses for a lot of its architecture. Microcontrollers. Okay, that was a mouthful to explain. The code were not quite done. I do want to show you this thing and we’ll see the example in power draw. But what I did was I went into the real time, clock, zero library and saw that they were using the the little higher power but more accurate, 32k external clock, and they did that once again to get better accuracy. But I changed it in my own local version of the library to the lower power internal 32k clock so I’m, just gon na show you the library file that I did and where I did the changes.

Now. If you don’t want to worry about this, you don’t have to you just use this this one and you’ll you’ll call the real time clock library, but if you want to look a little under the hood, we go here. So this is the dot CPP file. So this is C and the changes that I made was they call this begin function. So this is what you call to start the real time clock and it does some initial set ups. Once again, this is using registers to turn on the real time clock. Then there’s this configure 32k oscillator. I commented this out so in the real library it’s not commented out, and this is what configures the clock that that’s default, but I didn’t want to use it. So I don’t need that anymore and I don’t really need to configure the clock. I want to use because it’s always on so if we go down here, here’s the other change I made so here, we’re, basically using this generic clock control, and I think I show this in other another. My videos, like my pulse width, modulation, one, but basically you have to set up a clock to feed to the real time clock peripheral here they specify they did have this clock specified the external 32 k1. I changed it to this. The low power 32 K internal clock, so those are the two changes I made. I just commented out the configure for for the external clock and then I changed this long to the low power clock versus the the other one.

So next, what we’re going to look at is a comparison of the power save from the two different clocks and then later on. We’Ll. Look an example of the sleep in action: okay, here’s, two screenshots from my great keysight power supply; the n6705b DC power; analyzer what’s nice about this, as I showed this in other videos, but it’s a power supply, but it has very accurate measurement capabilities to measure its Output voltage and current so I’m going to use this to show the difference in power savings between the external 32k and the internal one and so here’s using the external one. This is the default one, the real time clock library uses and once again it uses that one because it’s more accurate but we’re, drawing about 580 micro amps. Now, once again, a lot of this hundreds of micro amps is due to other stuff around the Sam D chip. So don’t take this as the lowest power you can get. But what I want to show is: this: is 580 micro amps the eat, the chips asleep? So what happened is you know it turned on? We went through the timer, we set the alarm and then it went to sleep and that’s the current you’re seeing right here then, with the low power clock, two seam setup, the same code we’re getting about 10 micro amps less. So if you think about you, the chip itself, if we’re able to get down to 5 or 20 micro amps or something like that, 10 micro amps difference – is a big deal.

If you’re trying to run a battery powered device for a long period of time. But once again, the trade off is accuracy versus power, but I just wanted to show that all right next, I want to show using the inner external interrupt pin in action while measuring the current okay. What you’re seeing is my maker 1000 and empowering it? This is the DC power analyzer that I mentioned earlier. That can basically can output power from these channels. You know, based on whatever you set the voltage to be, but it also measures that output – and I have these wires going straight to VCC the reason I’m doing that is, I don’t want to measure the loss due to the power conversion, so I have it routed Right to VCC this other green wire is gon na serve as my interrupts wire, so pin. A1 is somewhere over here I’m gon na use this, which is tied to ground, to bring pin a1 low. When I want to trigger the interrupts once again, it’s simulating some kind of external event, so we’re zooming in I’m, just gon na show the maker 1000 and what I’m gon na do is I’m actually going to turn this on. So I probably should have mentioned this earlier, but the the power supply is configured to log the measurement so it’s gon na log, a measurement every millisecond and we’ll be able to see on the screen that the current go up then go down.

When we go to sleep and then go back up when the interrupt is triggered, so what I’m doing is I’m starting to data logger, i press this more on stop button. Then I turn on the power. So now we can see the voltage and the current ramp up and go high, so what happened here is once I turn this on. This started: recording the output voltage and current from that from those output terminals that’s going to the Sam D chip, where I should say to make er 1000 board. So once I press power on the voltage ramped up and then the current ramped up and I believe, we’re looking at about 5 millet millet amps per division. So this is time on the x axis and amplitude on the y axis. So each one of these is about 5 milliamps, so we see the current ramp up and remember there’s a five second delay, so we should expect to see normal current draw for 5 seconds. Then here is where we went to sleep. So the voltage is the same. We’Re, in normal mode, for about 5 seconds, we went to sleep so now, here’s our sleep current, so we’re, drawing very little current now I’m going to trigger the interrupts. So I’ve got this. I bring pin a1 to ground notice right here. This light turned on which would we expect because that’s what happens once the interrupts is triggered, the interrupt service routine is called and it turns on the LED.

Now. If we look at the current draw where you can see what we expect to see. Basically, the current ramp back up, and so we were normal current. We went to sleep notice, though the currents about five milliamps higher that’s, because we turned on the LED, so the LED is drawing about five milliamps, but I just want to kind of show you the profile, so you can kind of see what’s happening internally that you Know I’m not making this up. We actually are gaining these. These current advantages, when we, when we go to sleep, okay, that’s it for part one. I do want to mention that I sell maker 1000 boards at Forester, onyx comm, so check that out.


[adrotate banner=”1″]

arduino zero power consumption Video

[mam_video id=wmWqkJ97Zsc]



[adrotate banner=”2″]


[mam_tag id=4557]



[adrotate banner=”3″]


arduino zero power consumption news






[adrotate banner=”4″]



arduino zero power consumption Social



[adrotate banner=”5″]




👋 Want to bring Tony Stark-like gesture control to your projects? Learn how with the BLE-enabled MKR WiFi 1010 and Nano 33 BLE Sense boards using the ArduinoBLE library.

Arduin-yo ho ho! A fairground favorite, the pirate ship is a fun way to explore the oscillation of a pendulum. How much fun, you ask? Access our Science Kit Physics Lab preview and see for yourself: http://bit.ly/2oC6L0Q

🔬 Now that you’ve gotten your feet wet, dive into the kit and enjoy all nine experiments. Order yours today: http://bit.ly/2MnQ7fr


[adrotate banner=”6″]