Sunday, February 1, 2026

Building an AI Oracle with LCD Display - A Raspberry Pi Project

๐Ÿ”ฎ Building an AI Oracle with LCD Display: A Journey into Retro-Futuristic Computing

How I transformed a Raspberry Pi, an Arduino, and a vintage LCD into a mystical AI-powered oracle accessible via Telegram and web browser

N.S.C. Oracle Console - Web Interface

๐Ÿ“– What is This Project? (For Non-Technical Readers)

Imagine having a mystical oracle sitting on your desk that can:

  • ๐Ÿ’ฌ Answer your questions using artificial intelligence
  • ๐Ÿ“ฑ Respond to messages you send via Telegram (your phone!)
  • ๐ŸŒ Be controlled from any web browser on your network
  • ๐Ÿ“บ Display everything on a retro LCD screen (like old calculators!)
  • ๐ŸŒค️ Show weather updates automatically
  • ✨ Play cool cyberpunk-style animations when idle
  • ⏰ Tell you the time in a natural, human way (like "almost 3 o'clock in the afternoon")

Think of it as a digital fortune teller that lives in a small box on your desk, always ready to chat, inform, and entertain!

Telegram bot conversation with the Oracle

๐ŸŽฏ How Does It Work? (Simple Version)

You ask a question (via phone or computer) → The oracle thinks (using AI) → It shows the answer on the LCD screen!

For example:

  • You: "What's the meaning of life?"
  • Oracle: "Wisdom is a journey, not a destination."

The answer appears both on your phone/browser and on the physical LCD display!

LCD Display showing Oracle response

๐Ÿ”ง Technical Overview (For the Curious)

Now let's dive into how this actually works under the hood!

๐Ÿ“Š System Architecture

The project consists of four main components working together:

┌─────────────────────────────────────────────────────────────────┐
│                    SYSTEM TOPOLOGY                              │
└─────────────────────────────────────────────────────────────────┘

                    ┌──────────────────┐
                    │  HuggingFace AI  │
                    │  (Cloud/Remote)  │
                    │   DeepSeek V3    │
                    └────────┬─────────┘
                             │ HTTPS API
                             │
                    ┌────────▼─────────┐
                    │  Raspberry Pi 1B │
    ┌───────────────┤   Python Script  ├───────────────┐
    │               │   Flask + AI     │               │
    │               └────────┬─────────┘               │
    │                        │ USB Serial              │
    │                        │                         │
    │               ┌────────▼─────────┐               │
    │               │     Arduino      │               │
    │               │  (Display Driver)│               │
    │               └────────┬─────────┘               │
    │                        │ I2C                     │
    │                        │                         │
    │               ┌────────▼─────────┐               │
    │               │   LCD 16x2       │               │
    │               │ (Visual Output)  │               │
    │               └──────────────────┘               │
    │                                                  │
    │  HTTP (Port 5050)           Telegram Bot API    │
    │         │                          │             │
 ┌──▼─────────▼──┐              ┌────────▼──────┐    │
 │  Web Browser  │              │  Telegram App │    │
 │ (Local Network)│              │ (Smartphone)  │    │
 └───────────────┘              └───────────────┘    │

๐ŸŽฎ The Components

1. Raspberry Pi 1 Model B (The Brain)

This tiny computer runs the entire system:

  • Hosts a Flask web server for the browser interface
  • Manages a Telegram bot for mobile access
  • Communicates with HuggingFace AI for intelligent responses
  • Controls the Arduino via USB serial connection
  • Fetches weather data from wttr.in

2. Arduino (The Display Driver)

A microcontroller that acts as a bridge between the Raspberry Pi and the LCD:

  • Receives text via USB serial from the Raspberry Pi
  • Converts it to I2C protocol for the LCD
  • Manages display updates and cursor positioning
  • Handles the LCD backlight

3. LCD Display 16×2 (The Interface)

A classic character LCD (2 lines × 16 characters per line):

  • Shows AI responses, weather, time, and animations
  • Blue backlight for that retro-futuristic aesthetic
  • No emojis or special characters (pure ASCII art!)

4. Remote Services

  • HuggingFace AI - DeepSeek-V3 model for intelligent responses
  • Telegram Bot API - For mobile messaging
  • wttr.in - Weather data provider

๐Ÿ“ก Communication Flow

Here's how a typical interaction works:

┌────────────────────────────────────────────────────────────────┐
│                   MESSAGE FLOW DIAGRAM                         │
└────────────────────────────────────────────────────────────────┘

USER SENDS MESSAGE VIA TELEGRAM:
─────────────────────────────────

Telegram App  ──[1]──> Telegram API  ──[2]──> Raspberry Pi
(Smartphone)            (Cloud)                (Bot Handler)
                                                     │
                                                     │[3] Parse message
                                                     │    Check for commands
                                                     │    (#T#, #M#, #E#)
                                                     │
                                    ┌────────────────▼──────────────┐
                                    │   Is it a command?            │
                                    │   (#M30# / #E3# / #T60#)     │
                                    └────┬─────────────────┬────────┘
                                         │ YES             │ NO
                    ┌────────────────────▼──┐         ┌───▼──────────────┐
                    │  Execute Command:     │         │  Query AI:       │
                    │  - Show weather       │         │  Send to         │
                    │  - Run animation      │         │  HuggingFace  ──[4]──> AI Model
                    │  - Timed message      │         └───┬──────────────┘    (Cloud)
                    └────────────┬──────────┘             │                      │
                                 │                         │              [5] AI Response
                                 │                         │                      │
                                 │                         └──────────────────────┘
                                 │                                  │
                            [6]  └──────────────────┬───────────────┘
                                                    │
                                         ┌──────────▼──────────┐
                                         │  Format Response    │
                                         │  (max 80 chars)     │
                                         └──────────┬──────────┘
                                                    │
                          ┌─────────────────────────┼─────────────────────────┐
                          │                         │                         │
                     [7]  ▼                    [8]  ▼                    [9]  ▼
                 ┌────────────────┐       ┌────────────────┐       ┌───────────────┐
                 │ Send to        │       │ Send via USB   │       │ Display on    │
                 │ Telegram       │       │ Serial to      │       │ LCD Screen    │
                 │ (User's phone) │       │ Arduino        │       │ (16x2 chars)  │
                 └────────────────┘       └────────┬───────┘       └───────────────┘
                                                   │
                                              [10] ▼
                                         ┌────────────────┐
                                         │ Arduino parses │
                                         │ 32 characters  │
                                         │ and updates    │
                                         │ LCD via I2C    │
                                         └────────────────┘

๐ŸŽจ Key Features Explained

1. Special Command Prefixes

I created a unique command system using prefixes that can be placed anywhere in your message:

Command Effect Example
#T300# Message alternates with clock every 7 seconds for 300 seconds #T120# Call Mario at 3pm
#TF300# Fixed message for 300 seconds (no clock alternation) #TF60# Welcome guests!
#M30# Show weather for 30 seconds #M45#
#E3# Run animation #3 (Wave effect) #E1# (Scanner animation)

2. Fuzzy Clock

Instead of showing exact time like "14:37", the clock displays natural Italian expressions:

  • "le 2 precise" (exactly 2 o'clock)
  • "le 2 e un quarto" (quarter past 2)
  • "verso le 3 e mezza" (around half past 3)
  • "quasi le 4" (almost 4)

Second line shows the time of day: "del mattino" (morning), "del pomeriggio" (afternoon), "di sera" (evening), etc.

3. Eight Retro-Futuristic Animations

  1. Scanner - Knight Rider style horizontal sweep (>>>>)
  2. Matrix Rain - Falling characters (| : . |)
  3. Wave - Animated sine wave (~ ^ ~ -)
  4. Spinner - Rotating cursor (| / - \)
  5. Loading Bar - Progress bar animation
  6. Borders - Expanding/contracting frames
  7. Binary Rain - Falling 1s and 0s
  8. Vertical Scan - CRT-style scanning

These appear randomly every 1-3 minutes when the display is idle!

4. Real-Time Weather

Weather data for Forlรฌ, Italy (my location) displays automatically:

Forli: +12°C
Umidita: 68%
Vento: 15 km/h
Meteo: Nuvoloso

Scrolls through all info over 20 seconds, then returns to the clock.


๐Ÿ’ป The Arduino Code

The Arduino acts as a simple serial-to-I2C bridge. Here's how it works:


// Arduino Display Driver for N.S.C. Oracle
// Receives 32 characters via USB Serial → Displays on 16x2 LCD via I2C

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);  // I2C address 0x27, 16 cols, 2 rows
char inKey;
uint8_t Cursor = 0;

void setup() {
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
  lcd.print("---> NSC Display");
  lcd.setCursor(0, 1);
  lcd.print("Started -------<");
}

void loop() {
  if (Serial.available()) {
    delay(50);  // Wait for complete message
    lcd.clear();
    Cursor = 0;
    
    while (Serial.available() > 0) {
      inKey = Serial.read();
      
      // Special commands for LED control (future use)
      if (inKey == 'j') digitalWrite(13, HIGH);
      if (inKey == 'y') digitalWrite(13, LOW);
      
      // Display regular characters
      if (inKey != 'j' && inKey != 'y') {
        LCDDisplay(inKey);
      }
    }
  }
}

void LCDDisplay(char character) {
  int currentRow = Cursor / 16;  // Calculate row (0 or 1)
  lcd.setCursor(Cursor % 16, currentRow);  // Set position
  lcd.write(character);  // Write character
  Cursor++;
}

Key Points:

  • Listens on Serial at 9600 baud
  • Automatically wraps text after 16 characters (switches to second row)
  • Clears display before each new message
  • Simple and reliable - no complex logic needed!

๐Ÿ Python Script Architecture

The Raspberry Pi runs a single Python script with multiple concurrent threads:

┌────────────────────────────────────────────────────────────┐
│              PYTHON THREAD ARCHITECTURE                    │
└────────────────────────────────────────────────────────────┘

MAIN THREAD (Flask Web Server)
│
├─> Handles HTTP requests on port 5050
├─> Serves web interface with retro terminal aesthetic
├─> Processes form submissions
└─> Sends commands to Arduino via serial

THREAD 1: Clock Loop
│
├─> Updates fuzzy clock every 5 minutes
├─> Calculates natural time expressions
└─> Only updates when display is not busy

THREAD 2: Screensaver Loop
│
├─> Waits random 60-180 seconds
├─> 30% chance: Show weather (20 seconds)
├─> 70% chance: Random animation (5-10 seconds)
└─> Respects display_occupato flag

THREAD 3: Telegram Bot
│
├─> Runs async event loop
├─> Polls Telegram API for messages
├─> Parses commands (#T#, #M#, #E#)
├─> Queries AI when needed
└─> Sends responses back to user

SHARED RESOURCES:
├─> display_occupato (global flag)
├─> temp_message_active (global flag)
└─> Serial connection to Arduino (thread-safe)

๐Ÿ”’ Security Features

  • Environment Variables - All API keys stored in .env file (never in code!)
  • Telegram User ID Whitelist - Bot only responds to authorized user
  • Time-Based Web Passcode - Login requires current time in HHMM format (e.g., 1430 for 2:30 PM)
  • Message Deduplication - Prevents duplicate processing of Telegram messages

๐ŸŽญ Use Cases & Examples

๐Ÿ“… Reminders

Telegram: #T600# Meeting at 2:30 PM on Zoom

→ Display alternates message with clock for 10 minutes

๐ŸŽ‰ Event Announcements

Web: #TF180# Welcome to the party!

→ Fixed message for 3 minutes

⏰ Kitchen Timer

Telegram: #T300# PASTA TIMER!

→ 5-minute countdown with alternating display

๐Ÿค– AI Wisdom

Telegram: How can I be more productive?

→ AI responds with personalized advice

๐ŸŒค️ Weather Check

Telegram: #M30#

→ Shows current weather for 30 seconds

✨ Animation Demo

Web: #E2#

→ Runs Matrix Rain animation


๐Ÿ“š Technologies Used

Component Technology Purpose
Hardware Raspberry Pi 1 Model B Main computer running the system
Hardware Arduino Uno (or compatible) LCD display driver
Hardware 16×2 LCD with I2C backpack Visual output device
Language Python 3 Main application logic
Language C++ (Arduino) Display driver firmware
Web Framework Flask Local web server
Bot Framework python-telegram-bot Telegram integration
AI Model DeepSeek-V3 (via HuggingFace) Natural language responses
Serial Communication pyserial Raspberry Pi ↔ Arduino
Weather API wttr.in Real-time weather data
Configuration python-dotenv Secure credential management

๐Ÿš€ How to Build Your Own

Hardware Requirements

  • Raspberry Pi (any model with USB)
  • Arduino Uno or compatible
  • 16×2 LCD display with I2C interface
  • USB cable (Raspberry Pi → Arduino)
  • MicroSD card (8GB+) for Raspberry Pi
  • Power supplies for both boards

Software Setup

1. Arduino Setup:

# Install LiquidCrystal_I2C library
# Upload the display driver code
# Note the USB serial port (e.g., /dev/ttyACM0)

2. Raspberry Pi Setup:

# Install dependencies
pip install pyserial flask huggingface-hub python-telegram-bot requests python-dotenv

# Create .env file with your credentials
HF_TOKEN=your_huggingface_token
TELEGRAM_TOKEN=your_bot_token
TELEGRAM_USER_ID=your_numeric_id
SERIAL_PORT=/dev/ttyACM0

3. Run the Oracle:

python ArduinoOracle_Refactored.py

You'll see:

==================================================
๐Ÿ”ฎ ARDUINO ORACLE - SYSTEM CHECK
==================================================
Serial: ✅ Connected
AI: ✅ Ready
Telegram: ✅ Ready
Web: ✅ Starting on port 5050
==================================================

๐ŸŽ“ What I Learned

This project taught me:

  • Multi-threaded Programming - Managing concurrent processes in Python without conflicts
  • Serial Communication - Raspberry Pi ↔ Arduino data exchange via USB
  • I2C Protocol - Arduino controlling LCD displays
  • Modern AI Integration - Connecting to cloud-based language models
  • Bot Development - Creating responsive Telegram bots with async/await
  • Web Development for IoT - Building lightweight Flask servers on limited hardware
  • Retro Computing Aesthetics - Designing with constraints (16×2 characters!)
  • System Architecture - Designing modular, maintainable code

๐Ÿ”ฎ Future Enhancements

Ideas for expanding the project:

  • ๐Ÿ”Š Audio Feedback - Add speaker for voice responses or alert sounds
  • ๐Ÿ“ธ Camera Integration - Raspberry Pi Camera for image analysis with AI
  • ๐Ÿ  Home Automation - Integration with Home Assistant
  • ๐Ÿ“Š Analytics Dashboard - Track most common queries
  • ๐ŸŒ Multi-Language Support - English, Spanish, French responses
  • ๐ŸŽฒ Divination Modes - I-Ching, Tarot card readings
  • ๐ŸŒ™ Night Mode - Automatic backlight control (needs Arduino code update)
  • ⚙️ Plugin System - Easy extension with custom skills
  • ๐Ÿ”‹ Battery Power - Make it portable!

๐Ÿ’ก The Philosophy Behind It

This project is more than just blinking LEDs and API calls. It's about:

Bridging Past and Future - Using modern AI technology with vintage display aesthetics creates a unique nostalgic-futuristic experience.
Making AI Tangible - Abstract cloud services become real when displayed on a physical device you can touch.
Everyday Magic - Technology becomes delightful when it surprises you with random animations or wise responses.

๐Ÿ“Š System Statistics

Metric Value
Total Lines of Code (Python) ~1,000
Total Lines of Code (Arduino) ~60
Number of Concurrent Threads 4
Display Update Speed ~50ms
AI Response Time 2-5 seconds
Weather Update Interval Random 60-180s
Animation Count 8 unique effects
Power Consumption ~5W total

๐ŸŽฌ Conclusion

The N.S.C. Oracle project demonstrates how combining old and new technologies can create something greater than the sum of its parts. A Raspberry Pi from 2012, an Arduino, and a simple LCD display become a window into the world of artificial intelligence.

What started as "let's make an AI talk to an LCD" evolved into a full-featured system with:

  • Multiple input methods (Telegram, Web)
  • Intelligent command parsing
  • Real-time weather integration
  • Artistic animations
  • Natural language time display

The most satisfying part? Watching that blue LCD glow in the dark, scrolling AI responses interspersed with cyberpunk animations, all controlled from my smartphone via Telegram. It feels like living in a 1980s vision of the future – and I love it! ๐Ÿš€


๐Ÿ“Œ Resources & Links:

If you build your own version or have questions, feel free to leave a comment below! ๐Ÿ’ฌ

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
๐Ÿ”ฎ THE ORACLE HAS SPOKEN ๐Ÿ”ฎ
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Built with ❤️, a Raspberry Pi, and way too much coffee ☕

Building an AI Oracle with LCD Display - A Raspberry Pi Project ๐Ÿ”ฎ Building an AI Oracle with LCD Display: A Journey into Re...