Introduction: Low Power Arduino Temperature Monitor
In this Instructable we build yet another temperature monitor using a DS18B20 temperature sensor. But this project is different. It can last on batteries for almost 1.5 years! Yes! Using the Arduino low power library, we can have this project running for a long time. Keep reading in order to find out more!
Step 1: Get the Parts
The parts needed in order to build this project are these:
Nokia 5110 LCD: http://bit.ly/NOKIA5110
16MHz crystal: http://goo.gl/bdZibi
Multimeter Mastech 8268: http://goo.gl/osD2bH
The total cost of the project at the time I write this Instructable is less than 10$!
Step 2: Connect All the Parts
Now that you have all the parts let's connect them all together acording to the schematic diagram.
The key to this project's low power consumption is the usage of a bare ATMEGA chip instead of an Arduino Board. Since Arduino boards use a voltage regulator in order to work with many different voltage levels, they need more power. We don't need this regulator since we are powering our project from 3AA batteries!
In this project I am using the Nokia 5110 LCD display which is a great display and it needs only 0.2mA of current when the backlight is off. Impressive!
We also use a photoresistor in order to detect light. So, if it is night we disable the LCD display in order to conserve power.
Another little secret is the LowPower library. When we are not measuring the temperature we put Arduino to sleep using the LowPower library. When a bare ATMEGA chip is sleeping it requires only 0.06mA of current! That means that you can have an ATMEGA chip sleeping for over 4 years on 3 AA batteries!
So with a clever software design we achieve a good battery life. The ATMEGA chip need around 10mA of current when it is awake. So, our goal is to have it sleeping most of the time. For that reason, we only wake it up when we need to measure the temperature, every two minutes. When we wake the ATMEGA chip up, we do everything as quickly as possible, and we go immediately to sleep again.
The project wakes up every two minutes. The first thing it does is to enable the photoresistor by writing HIGH to digital pin 6. It reads the value from the photoresistor and it determins if it is day or night. Then it writes LOW to digital pin 6 in order to disable the photoresistor and conserve porer. If it is night we disable the LCD display if it is ON and we go immediately to sleep for two minutes without reading the temperature. There is no need to do so, since the display is off. This way we conserve even more power. If there is enough light, we enable the LCD display if it was disabled, we read the temperature, we display it on the screen and we go to sleep for two minutes. That loop goes on for ever.
Step 3: Measurements
As you can see from the pictures, when the project is sleeping and the display is ON, it needs 0.26mA of current which is very low if you consider the fact that we have a display!
When the project measures the temperature and updates the display needs around 11.5mA.
Lastly, when it is dark and the ldr has disabled the Nokia 5110 LCD display, we only need 0.07mA which is great!
In order to calculate the battery life of the project I created a simple Excel file. I entered the measurements from the multimeter and as you can see we get a battery life of more than 500 days if we measure the temperarure every 2 minutes! That's with the use of 3AA batteries of a capacity of 2.500mAs. Of course if you use better batteries like a Li-Ion 3.400 mAh battery you can have your project up and running for more than 2 years!
You can download the Excel file from this link.
Step 4: The Code of the Project
The code of the project is very simple. We use some libraries in this piece of code. The libraries we use are the following:
- Low Power Library: https://github.com/rocketscream/Low-Power
DS18B20 temperature sensor library: https://github.com/milesburton/Arduino-Temperature-Control-Library
The Nokia 5110 LCD library: http://www.rinkydinkelectronics.com/library.php?id=47
The project code consists of two files. In the first file there is the code that runs on Arduino. The next file contains some binary data for the icons the main program displays. You need to put both file in the project folder in order to code to compile correctly.
The code is very simple. You can find it below. All the magic happens at the sleepForTwoMinutes function. At this function we put Arduino to deep sleep. The problem is using the watchdog timer the maximum amount of time that we can put Arduino to sleep is 8sec. So, we insert that in a loop for 15 times and we get the two minutes interval we want
I hope you enjoyed this project. See you soon!