๐ฎ 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
๐ 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!
๐ฏ 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!
๐ง 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
- Scanner - Knight Rider style horizontal sweep (
>>>>) - Matrix Rain - Falling characters (
| : . |) - Wave - Animated sine wave (
~ ^ ~ -) - Spinner - Rotating cursor (
| / - \) - Loading Bar - Progress bar animation
- Borders - Expanding/contracting frames
- Binary Rain - Falling 1s and 0s
- 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
.envfile (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:
- ๐ GitHub Repository (replace with your actual repo)
- ๐ค DeepSeek-V3 on HuggingFace
- ๐ค️ wttr.in - Weather API
- ๐ค Telegram Bot API Documentation
- ๐ Flask Web Framework
- ๐ LiquidCrystal_I2C Library
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 ☕