The aim of this tutorial is to predict and rationalize Croduino's consumption. We will specify the consumption of individual components and the controller itself, and in a few examples make an estimation for consumption. In the end we will present a few libraries which allow you to put the controller in sleep mode and try to make some conclusions out of everything mentioned.
We will check the microcontroller's consumption in several examples, and using datasheet we will predict the consumption under certain conditions. For starters, we have measured the Croduino Basic and Croduino Dambo board's consumption. The results, at 5V and room temperature are the following:
Croduino Basic 46.43 mA
Croduino Damba 2.61 mA
Let's start with Basic. Basic uses Atmega328 which runs at a 5V voltage and 16MHz external oscillator. The manufacturer's recommendation for low power consumption is to adjust the internal oscillator to 1MHz and the voltage to 1.8V at the temperature of 25C, which would ultimately give the consumption of 0.2mA in active use. Therefore we can conclude which parameters affect the consumption, so let's check the consumption in several combinations:
When choosing the frequency we will use, we have to keep in mind the voltage too. The maximum frequency we can use depends on it, as shown in the following diagram:
Let us proceed and upgrade the Atmega328 with the external oscillator, The consumption is shown in the table:
As for the temperature, the differences are not that drastic, we can only remark that the lower temperature means lower consumption - up to a certain limit. Of all the other components whose consumption is important to mention are definitely LED diodes. 0805 Blue LED diode consumpts 10mA, depending on the color or type of diode, the consumption can multiply. So, the good idea would be to to unsolder the LED diode, or if you are making your own Arduino board using Atmega or resonator, not to connect them.
If we are connecting the controller to a battery which has an output voltage higher than 5.5V we have to connect it through a voltage regulator which has certain losses. For that, you need to use VIN(Voltage input) and gnd for the negative pole. Croduino Basic uses STMs 78M05 voltage regulators, you can find the power consumption and efficiency of the regulators in terms of voltage and temperature in the datasheet.
The 78M05 voltage regulator itself is known as inefficient. Its efficiency ranges from 60% to 90%, depending on the voltage and electricity on its input. You will notice that the more voltage you connect to its input and the more power it needs, the more it will heat. This means that, e.g. in the example of the 80% efficiency, 80% of energy coming to the input(higher) voltage will turn to lower voltage, while the 20% will fall out on the heat and the regulator will heat up. In a way Croduino Basic is set up(without specific heatsink), it is not adviseable to pull the maximum of what it can give. It is intentionally made so, for several reasons. If, by any chance, you need a more efficient voltage regulator, we recommend something as LM317 or LM2596 whose efficiency can reach up to 95%.
Damba, i.e. Attiny85, is powered by an internal 8MHz oscillator and 3V voltage from the CR1220 battery. The measured consumption under these conditions is: 2.61mA. The manufacturer's recommendation for low power consumption is setting the internal oscillator to 1MHz and the voltage to 1.8V at the temperature of 25C, which would ultimately give the consumption of 300 uA in active use, or 0.1 uA in power down mode, but we will tell you more about it later. Let's study some characteristics provided by the official datasheet:
Damba, other than Attiny85 microcontroller, has no additional components. Do not let the LED diode on the board puzzle you. It is located on the D0 pin, so it is not necessarily active.
The manufacturer's recommendation is to put the microcontroller into sleep mode whenever it is not used, which leads to great savings. For example, if we want to read off the temperature using DHT sensor every 10 seconds, we will put the microcontroller into sleep mode and "wake it up" at 250ms as much does the DHT sensor need to register the temperature. Such control can result in the consumption of only 100nA for Atmega328, which is less even than the most batteries' self-discharge. This can be seen from the datasheet:
There are several libraries that allow such access to the controller - be sure to use library, delay() function does not save electricity! Some of the more famous ones are Sleep, JeeLib, Lightweight low power i Enerlib.
It is understood that in each use/application you will not be able to apply some of these optimizations. The more, the merrier! One of the easiest and most successful optimizations is to use some of the libraries for sleep.
Also, some things can not be done through Arduino, but need to be done in an assembler (let's say Atmel studio) which allows access to every part of the microcontroller individually, and that is a thing for advanced developers.
The above processed data will be presented in a short list of recommendations:
- Lower the frequency of the microcontroller
- Lower the microcontroller's input voltage
- Shut the internal modules that are not used in software down (SPI, I2C, Serial, ADC, and so on)
- Do not use LED diodes
- Do not use voltage regulators
- Use library which puts the microcontroller into sleep mode when we do not use it
- "Wake" the microcontroller only when necessary
- Disable external devices using MOSFET (all kinds of sensors and modules, e.g. temperature sensor or SD card) when we do not use them