Arduino E-Paper Clock & Calendar

Apr 30, 2022 · 1379 words · 7 minute read

E-Paper makes a nice, unobtrusive display, that is great for displaying slowly refreshing information in a low power and flexible way. I wanted to create a little clock/calendar that would display the day of the week for the children, but that doesn't look like a glowing digital display.

Previously I'd managed to get an e-paper display to work with an Arduino, and a real time clock so it could keep time between being powered off without the need for any network connection. If you want to build your own e-paper clock, it's probably best to read those two posts first, as this post will build on those.

Another advantage of the e-paper screen is that the resolution is high enough that you can use normal text fonts, and customise the display in almost any way you want. I created two versions of almost the same code, each creating a different display, with one focusing on having the day of the week being the most obvious piece of information, while the other focuses on the time.

Parts & Wiring

If you want to build this like I did, you will need the following parts:

  • Arduino Nano or Uno
  • DS3231 real-time-clock module, plus button battery if your module uses one
  • Waveshare 2.9" e-paper screen
  • Some wires to connect them, and probably a bread-board to do it via.
  • Computer with Arduino IDE, and USB cable
  • The code to run the clock

The Arduino, the DS3231 real-time clock and the screen are connected as follows:

DS3231 RTCColourArduino Nano
SCLA5
SDAA4
VCC3.3V
GNDGND
SQWD2, For interrupt alarm, set with wakeUpPin()
E-Paper Screen
BUSYPurpleD7
DCGreenD8
RSTWhiteD9
CSOrangeD10
DINBlueD11
CLKYellowD13
VCCGrey3.3V
GNDBrownGND
Arduino GNDD4, Connect to add 1 hour for daylight savings

The last connection, between the ground and pin D4 can be ignored initially, we'll get to that later.

The Program

The sketch epaper_clock.ino uses the real time clock to get the current time, and then displays this, along with the date, on the e-paper screen. It is really just a combination of sleep_wake_with_rtc.ino and GxEPD2_with_two_fonts.ino, with one main difference: a change to the library used to create the text.

Instead of the Adafruit GFX library we use the U8g2 for Adafruit GFX library for drawing the fonts. The main reason is that the plain GFX library has a relatively limited number of fonts, and all of them contain all possible characters, making each font a very large file, especially if you're using two of them.

Once all the other code was added to the clock sketch, the Arduino's memory was almost full - this is even more critical if we move from an Arduino Uno to a Nano. Notionally both have 32kB of flash memory, but on the Nano this also contains the bootloader, so practically you have slightly less to work with than on the Uno.

The U8g2 library allows you to use any of the U8g2 fonts that available, of which there are hundreds, but crucially there are variants of many fonts which contain a limited number of characters, so you can reduce the amount of memory used. You can choose a font that only contains letters, uppercase letters, or perhaps only numbers and symbols needed to display the time. The exact naming and meaning is explained in a table at the top of each font list.

That's why in epaper_clock.ino I used the font "u8g2_font_logisoso50_tn" for the time display, as it only contains numbers and a few symbols, and for a large size of font this saves a lot of space.

As a result of the change of library there are a few changes in methods as well, for example to get the size of a string, as written in a particular font, changing to u8g2Fonts.getUTF8Width() from display.getTextBounds(), which also works slightly differently.

To save even more memory I also don't use the relativity large snprintf() function; it is much more convenient, but compared to manually creating the strings using strcpy() and strcat(), also much larger.

One last addition is the ability to 'simply' adjust for daylight savings time. To do this you have to connect pin D4 to ground. If this is connected, when calling the time, the function getDstTime() will add 1 hour onto the time. This doesn't actually change the time that the real time clock thinks it is, only the time that it displays. If you change the code to set an alarm for midnight, it will do so at midnight winter time, even in the summer, which will then happen at 1 am (assuming summer time is 1 hour ahead of your local winter time). If you wanted to be fancy you could even build in a switch to do this instead of just jumpering two pins.

Housing

This is the aspect of most of my home build projects I find the most frustrating - creating an acceptable container to house it in. It doesn't matter if it's guitar pedals or other electronics projects, the electronics are relatively easy to assemble, but putting them in something with a nice finish that doesn't look out of place takes a surprisingly large amount of effort.

I wanted some kind of small box that would hold the screen, and the Arduino board, while somehow matching the 'natural' look of the e-paper screen. The best solution ended up being cardboard; while perhaps not glamorous, it does have a number of advantages over other options like wood, metal, plastic or perhaps 3D-printing something (assuming I had a 3D printer). First, it's cheap, or in my case free, as I re-used a frozen pizza box. Next, cardboard comes in many shades of natural looking browns1, so finding something that complemented the e-paper screen was relatively easy. Cardboard is also easy to work with, all you need is a metal ruler, sharp knife and some glue, then you can get pretty precise results.

insides.jpg

The more professional approach would have been to solder the Arduino Nano to some stripboard, rather than what I did, which was just to use a spare breadboard and glue that into the box.

I could then have made the box smaller, but it would have left me with another problem: tipping. The e-paper screen, with the glass, is quite a bit heavier than the Arduino and the RTC module, so if I wanted it to stand vertically to put on a shelf, it could easily tip forward without some extra weight holding it back, so the breadboard also solved that problem.

screen-frame.jpg

The e-paper module was a bit of a pain in more ways that one. First, it's not symmetrical horizontally, so I created a little cardboard frame that it could be screwed into, and that in turn could be glued into the front of the box to line up with the cut-out for the screen. Secondly the header cables come out on the long side, and are hard to bend in a tight radius, so it probably couldn't bend behind the module within its own width.

With a bit of faffing I managed to double-sided tape the frame inside the front of the box and lined up with the window for the screen, and currently the housing looks as follows. It could be neater, but as a first version is acceptable.

outside.jpg

Future Plans

Apart from finding a nicer housing for the clock, the other improvement would be to reduce the power consumption so it could be run for extended periods by a battery. Then it could be placed almost anywhere, unlike now where it requires a cable and plug socket. At the moment it uses around 20mW when running, and 35mW when refreshing the screen. There are number of things that could be done to try and reduce this (especially if for the weekday calendar you only show the day and date, so need to update only once per day).


1

First, I'm sure you're judging me for the brand and type of pizza use to make this. Judge away, that's your problem, it was delicious. You could of course choose other colours, if brown isn't your thing, to make the box look prettier.