11 min read

📖 Das Buch

A Not-So-Lighthearted Intro

By the numbers, our society has never had it better. Worldwide poverty is declining, more and more people can read and write, and violence and crime continue to drop. Yet, the daily news remains dominated by unsettling headlines: fear of excessive migration, fear of unemployment, fear of the next stock market crash, the war in Ukraine and the escalating conflict with Russia, increasingly strident voices from extremists on both the left and the right that grow louder in political debates and on the streets, and over everything looms the threat of climate change. The globalized world keeps spinning ever faster, and the desire to simplify is immense. The temptation is strong to follow those who promise quick fixes to complex problems. But unfortunately, simple solutions are rare—if they existed, we would have solved most of our global issues by now.

A Book Which Finds You

Thankfully, there’s a vast amount of literature exploring the challenges of our time, offering fresh perspectives, deeper insights, and potential ways forward. Books have preserved the wisdom of experts, historians, and entire civilizations, allowing us to learn from their successes and failures. By turning the pages of a thoughtful work, we can find new angles on old problems and better understand the complexities of our modern world. Yet how do we pick the perfect book from such an overwhelming selection? And what if we didn’t have to choose at all—what if the right book found us?

Enter “Das Buch” (in English, “The Book”), which plays with precisely that idea. Imagine a volume that automatically checks the day’s news, hunts down a relevant title, summarizes it, and then displays this information on its own cover. That’s exactly what “Das Buch” does.

Please note that “Das Buch” is an art project, not meant to solve any of the pressing issues we face. It’s my humble way of commenting on the swirl of daily news and the search for deeper insight by creating something tangible. I’m not claiming to have the answers, but I hope it sparks reflection, curiosity, and conversation.

title

Sitting on the shelf, it looks like any other book—except the spine is blank, and the cover is stark white, hinting that it could be about absolutely nothing or, perhaps, absolutely everything.

title

Pick it up, and you realize it’s actually quite different. Its pages mirror whatever’s in the headlines, presenting a real book’s theme, title, and author—just when you need them most. In a world that’s increasingly hard to navigate, “Das Buch” extends a friendly hand: “Hey, want to learn more? Here’s a suggestion.” It offers guidance and a bit of stability amid the chaos of the daily news.

title

Laid open, “Das Buch” becomes a window onto current global events. It invites you to investigate the news item it references and delivers literary context to go with it.

A Look Inside The Book

You can probably guess how it works from the description: hidden inside the cover is a microcontroller that checks current headlines via the API of a news outlet (in this prototype, Germany’s “Tagesschau”). One news item is randomly selected, then forwarded to OpenAI. OpenAI replies with an author, a title, and a summary of a book that deals with the news topic. These details are displayed on an e-paper screen embedded in the cover. And there you have it—a book that keeps its finger on the pulse of the world, nudging you toward deeper understanding and fresh ideas, one headline at a time.

String prompt = "Research existing, real books related to the topic [" + message + "]. Return exactly one result in this format: { 'author': 'author of the book', 'title': 'title of the book', 'description': 'Summary of the book, not longer than 3 sentences.' }";

Basic Program Flow

  1. Wake up
  2. Connect to Wifi
  3. Fetch the latest news from the german “Tagesschau” API
  4. Select a random headline from the JSON data
  5. Query OpenAI with the headline to find a related book
  6. Display the book’s author, title and a short summary on the e-paper
  7. Go back to deep sleep

Like many of my other projects, this one uses an ESP32 microcontroller. It’s inexpensive, has built-in Wi-Fi, and can operate on battery power thanks to its low energy consumption. The battery is connected to the ESP32 via a battery shield that regulates power and prevents overcharging.

title I had to solder the battery’s power wires directly because it had the wrong JST connector.

Getting the microcontroller to connect to Wi-Fi and exchange data with an API was fairly straightforward. I’d already tackled this task in several previous projects (for instance, my Flower Power plant). If you’re curious about the details, take a look at the source code on GitHub.

Waveshare E-Paper

Getting the e-paper display up and running was much more challenging. There really wasn’t an alternative, though, because e-paper only consumes power when it refreshes—and in my setup, that happens just once every 12 hours. Besides, the idea of using digital paper for a book seemed too fitting to pass up.

I used the GxEPD2 library from GitHub, which was a huge help. It lets you display images and text, and thankfully text was all I needed. However, aligning and wrapping that text properly was quite a headache—there’s no built-in line wrapping or centering functionality. In the end, I wrote my own text wrap and align functions (with substantial help from GPT).

title Left-aligned text was the easiest to implement, but it didn’t quite capture the “book cover feel” I was aiming for.

The code for adding line breaks and centering text

/**
 * @brief Inserts line breaks into a String at a defined interval or at the last space.
 * 
 * This function searches for a space within the next 'number' characters
 * and inserts a newline. If no space is found, it forces a newline at the 'number'
 * character. This helps in nicely wrapping text for display.
 * 
 * @param text   The original String in which to insert line breaks
 * @param number The maximum number of characters before wrapping
 * @return String The modified String with inserted line breaks
 */
String addLineBreaks(String text, int number) {
  int length = text.length();
  int currentIndex = 0;

  while (currentIndex < length) {
    // Find the last space character within the next 'number' characters
    int breakIndex = text.lastIndexOf(' ', currentIndex + number);

    // If no space is found, or it's out of range, use the exact 'number' position
    if (breakIndex == -1 || breakIndex <= currentIndex) {
      breakIndex = currentIndex + number;
      if (breakIndex >= length) break; // Avoid out-of-bounds
    }

    // Insert a newline at the break index
    text = text.substring(0, breakIndex) + "\n" + text.substring(breakIndex + 1);

    // Move currentIndex past the inserted newline
    currentIndex = breakIndex + 1;

    // Update the length of the text due to the insertion of the newline
    length = text.length();
  }

  return text;
}

/**
 * @brief Draws a single line of text centered horizontally on the display.
 * 
 * @param text                  The text to display
 * @param characterLengthOffset horizontal offset based on character length
 * @param y                     The vertical position to place the text
 */
void displayCenteredLine(const char* text, int16_t characterLengthOffset, int16_t y)
{
  int16_t tbx, tby; 
  uint16_t tbw, tbh;

  // Calculate text bounds for centering
  display.getTextBounds(text, 0, 0, &tbx, &tby, &tbw, &tbh);
  
  // Center the line with offset
  int16_t x = ((display.width() - tbw) / 2) + characterLengthOffset - tbx / 2;
  u8g2_for_adafruit_gfx.setCursor(x, y);
  u8g2_for_adafruit_gfx.print(text);
}

title The result looks ‘okay-ish’, at least much more ‘book-like’. You can see all eletronics and their basic wiring in this picture, too.

3D-Printed Book Case

3D printing is fantastic for prototyping. If you happen to be a whiz at 3D modeling (which I very much am not), you can transform a hand-drawn sketch into a physical object—complete with the exact specs you need—in anywhere from a few minutes to a few hours. The catch is that 3D prints rarely end up looking or feeling one-of-a-kind. There’s always that slight plastic vibe that screams, “I was 3D printed!” Plus, the ease of 3D printing can tempt you into taking shortcuts too often, which might keep you from exploring more challenging (but possibly superior) design paths.

For this project, though, speed was key. I wanted to test the concept quickly, and white PLA filament blended nicely with the e-paper display—so it felt like a decent compromise. But if I’m being honest, the result is a bit less magical than it might have been if it weren’t made of plastic.

title Slightly bent plastic isn’t usually a good look—unless you’re trying to fake a book cover, in which case it actually helps sell the illusion.

title The back of the book is removable. At first, I tried using a small tab-and-slot mechanism (see the square block), but later switched to magnets. They work almost too well; it’s surprisingly tough to separate the cover from the main body now.

title The inside of the book with all the electronics. I initially secured everything with duct tape, planning to add 3D-printed brackets later. I guess nothing is more permanent than a temporary solution…

The book is fully assembled now. I glued the e-paper display to the plastic front cover, measured the case carefully so it would mimic a real bound book, and left a tiny notch on the left side for the display’s flat cable to pass through. With just two refreshes per day, the battery can last for weeks. And even once it’s drained, the e-paper display still shows the last recommended book on the cover—which is the kind of magic only digital ink can pull off.

title Little Magnifier Man is absolutely horrified by today’s news…

Bill Of Materials

The Waveshare e-paper is by far the priciest component in this entire build. I really didn’t have a choice, though—I absolutely and desperately had to play around with it. Actually, make that “them,” since I ordered two. Everything else was just spare parts I already had lying around.

Pro Tip: Always order more than you need. Then, when you’re asked about the cost, you can say, “I only used spare parts I had lying around,” which greatly reduces the official project expenses (and keeps your significant other off your case).

PartInfoWhere to getCost
Waveshare e-paperThese are quite expensiveAliExpress66 EUR
ESP32 MiniThese have Wifi & Bluetooth onboardAmazon11 EUR
ESP32 Mini Battery ShieldYou’ll get three of themAmazon9 EUR
2000mA LiPo BatteryI used a spare one I already hadAmazon11 EUR
PLA FilamentIt took me several tries to get it right enoughAmazon4 EUR
Some magnetsStole them from the fridgeMy fridge (still have plenty)free
Total cost101 EUR

Final Thoughts

Das Buch’ is probably at about 80% of what I originally envisioned, but it’s close enough to convey the core idea. Polishing or expanding it further would be a battle against my limited free time—and right now, a bunch of other fun ideas and shiny new hardware are piling up on my desk. So I think I’ll leave it as it is.

If I were to iterate on it, here’s what I might do:

  • Reuse a real old book as the case
  • Extend the reset button to the outside so I can easily refresh it with a new recommendation
  • Use a different API with clearer declarations of top news
  • Add a button to send a reading sample from Amazon to a Kindle device
  • Improve checks for hallucinations (they do happen, but only occasionally)
  • Enhance error handling in general

That’s it! Thanks for reading—feel free to share any comments or feedback. I’d love to hear your thoughts.

title Notice the subtle red glow from the ESP32 LED. It’s much cooler in the dark, but I was too lazy to take a photo at night.