This tutorial is about how to use an e-ink display and Real-Time-Clock (RTC) with the Arduino mini pro, including a low power setup!
The Arduino platform is awesome to create small projects in only a few days. The problem I encountered several times is, that tutorials covered HOW to build a small demonstrator, but not HOW to use it in a productive setting. Projects either focused on some sensors/ displays or rather on the energy part, but not on both of them. But this is essential for any Arduino project running on batteries.
I will explain how I used the e-ink display from smart prototyping with a common RTC (DS3202) and how to get to a low power system which lasts over a year. This kind of system can be useful to many different projects. For me, it was a way to visualize the days of garbage removal. But it could be a platform for any kind of sensor like temperature, pressure, brightness ...
Step 1: Hardware
So what are the essential parts of this project?
- DS3231 RTC
- Battery 9V
What do we need to connect everything and get it to low power?
- Cables (Standard connecting cables)
- Transistor (any common one,2n2222)
- Resistor (3k, 10k)
- Transparent acryl glas
- Soldering iron and stuff
- Saw and drill for the box
- Hot glue gun
Step 2: Design of the Core System
So now we have the 4 essential parts together (Arduino, display, RTC, battery). If we manage to connect all of them together, we should already be able to-do cool stuff with it. But wait! We could just use ANY kind of Arduino, any kind of RTC and battery and it would work, but the battery might be empty in less than a day. So we want it to be low power. What does this mean? Well, the used battery should last for at least a year. Isn't that cool?
So let's get started. We want the Arduino to use as little power as possible. There is actually only 1 real choice for that and that's the Arduino mini pro. It consumes about 5-8 mA during usage. I did choose the 3.3V version, as it should use less power and can directly power the 3.3 V display. Our display should use very little power during change and no power during sleep. E-ink displays are perfect for that. I did choose the display from smart prototyping. It is compact, all necessary hardware is assembled and I found good tutorials about it. The DS1307 RTC is very common, but for our project not the best choice. We want a RTC which can be used to wake the Arduino up. The DS3231 can do that and is even much more precise. Last we have to think about the battery. There are a lot of different possibilities around. I did choose a common 9V Alkaline battery. The reason for it, is a low self discharge and the fact that it is a non-rechargeable battery. If I would use a Li rechargeable battery, I would need a good method for determine the battery voltage or the battery might be destroyed due to low voltage.
Step 3: Getting Started
Right, let's get started. Our first goal should be to connect the Arduino to the computer. As the Arduino mini pro does not have a serial to USB converter chip, this is more complicated as for other Arduinos. If you managed to do this, try uploading some examples. It works? Great!
Next, we need to connect the display to the Arduino. I recommend this tutorial:
I modified the library, so that the look-up table is not stored in ram, which frees most of the memory. You can use either the provided library or my adapted one (much more ram todo stuff with.)
After connecting everything and installing the library, try the string example.
If this works, lets get to the RTC:
Ignore the part about the voltage regular, just connect the RTC to the Arduino as indicated. Also install the library
RTClibExtended.zip and upload the example code to your Arduino. You should be able to see some results in the serial monitor. The external wake-up will not work yet! You will need to modify the RTC for this (Read the mod part).
So now only a power source is missing. We could just plug-in the 9V to the raw pin (voltage regulator) of our Arduino and our hardware design could be finished. But somethings missing... right the low power!
Step 4: Low Power
Here are some thoughts of me, how to get a system to low power:
1. Measure your system! It's no good to optimize when you don't even know how good your system already is. Every time you optimized something, be sure that now your system really needs considerable less power.
2. Disable power LEDs. It's ridiculous that every single board I came across has a power LED. If we want a system to be low power, we have to disable them. This could be achieved by dis-soldering or just destroying them with a metal tool.
3. Every sensor/ system which is not needed should be powered down.
4. The power delivery system might use the most power! So if we optimize our Arduino but use a common step-up/step-down converter, our whole goal might not be achieved. It is also worth mentioning, that most converters are efficient during medium/high loads, but very in-efficient during low current loads.
5. Every optimization makes the code and hardware design worse. Yep, you read correctly. So be careful about how much you optimize. Highly optimized code looks like crap and even the designer may not be able to understand it in a few weeks.
Step 5: Let's Mod Our System
The DS3231 is a common temperature controlled RTC with a precise clock. The used board from ebay is cheap but works fine. The chip has a sleep mode, in which the chip can not communicate with other devices, but still keeps the time. It even can set a signal at a pin at a pre-defined time! That is great for waking up our Arduino. The only thing is, that the sleep mode does not work out of the box. We have to dis-solder a resistor array to get rid of a pull-up resistor. As we are at it, we can also dis-solder the power LED and a resistor used for charging, which enables us to use a non-rechargeable battery. Please refer to this good tutorial: Mod cheap RTC
The Arduino has a power LED which needs to be dis-soldered or destroyed. After that the Arduino has a power consumption of about 4 mA during operation and 0.05 mA during sleep. That is already pretty good. If we would use a better regulator, we could get it even much lower. We could even use no regulator at all, if our power source is between 2.7V and 5.5V. Using no regulator is a pretty cool thing, but I am not sure how the display would react to that. So for now, let's use the on-board regulator. Here are more numbers: Low power Arduino mini pro.
Now let's get to the tricky part. The display is connected with 10(!) cables to the Arduino. It consumes are considerable amount of energy, even if is not changing! I measured about 0.7 mA. So that's not good. The first thing I figured out, was that BV and BS1 don't need to be connected. Next I connected the RESET pin of the display to a pin of the Arduino via a 10k resistor. In that way, we can shut down the display just by setting the Arduino pin to low. Although I got the power usage of the display down to maybe 0.06mA, I thought I could do better. It seems that the SPI interface of the Arduino needs to be shutdown manually before we can send the Arduino to sleep. I modified the library of the display and added a function for disabling the SPI interface. If we now call Eink.EndEink() after we used the display, the SPI pins are low during sleep, hurray!
Ok, now everything seemed to work, but the VCC pin of the display still drew some current... I tried using it directly on the Arduino, but the power consumption seemed to high. I therefore used a simple transistor as a switch. I used a 2.2k resistor to drive the transistor. With that in place, the total power consumption dropped to around 0.06 mA which is around the value for an Arduino without any additional hardware. So great, now we have a low power system during sleep!
Step 6: The Box
The box for the whole system is a common euro-norm box. I sawed a small window in it and glued a transparant acryl plate behind it. Any box should be fine.
Step 7: Final Setup
Ok, now everything is in place and should work. We can now use the low-power library to set out Arduino to sleep. As we have an external interrupt signal (the RTC), we can send him to sleep forever.
If we use an additional button, we can enable a second interrupt on the Arduino (pin2 and pin3). Now the Arduino can wake up from the RTC or if somone presses the button.
That concludes now this tutorial. If you really got this far, congratulation!! You have now a great platform for some small projects. It would be great if you could share your experiences.