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 ☕

Thursday, April 27, 2023

PDFJoint

 PDFJoint

I am glad to share with you a quick app I assembled from older efforts and with drag&drop interface, to join two or more PDF files together, for a particular environment where other free/open/commercial solutions are prohibited (btw I use Ghostscript under AGPL for the joining job).

Also PDFJoint is able to extract pages from a PDF.


Just put it on your desktop

Download it clickin' on the icon:

Download!

Friday, December 31, 2021

Map Flooder

I was searching for a way to highlight zones (regions, provinces, counties, etc) on a map, and I don't need super precise maps so I wrote this AutoIT script, based on picking up black and white maps (2 colors BW .png or .gif tested) and filling them with colors, writing down a sqlite database to associate zones with names (and possibly other data as well), and reuse the map and the DB to display data, in my example reading a simple .txt file.


So you can forget about multi gigabytes frameworks, with complex web based environments to be patched every 15 minutes and prone to vulnerabilities ๐Ÿ˜‰, I love having an easy stand alone map showing tool in one (1 boys...) megabyte and without dependencies ๐Ÿ˜.


Let's have a look at this 2 minutes video:




So I have two modes:
  1. The Map "creation mode" : you provide a map image and you start to pick up colors, set "upper level" region/state, and by clicking on a region you fill it and you name it, and all the data are saved on a sqlite DB (auto-created by the script).
  2. when you have the map image and a DB with the correct associations, you can switch the "mode" to "show" (as by .ini file) and the script tries to read a "datafile" showing the zone names listed in datafile.

And feel free to evolve, calling the executable passing the data to show, maybe assigning weighted colors based on values for zones.


The code is here (link)

But you can start to play immediately with this second link, there is the already compiled executable and some files to try:

Link to all the demo files




Sunday, April 25, 2021

Computer Plucker


Computer Plucker is an utility for retrieving a lot of info about your windows pc and your win OS installation, plus it has a lot of shortcuts to various system tools, and to some useful sites.

It's intended for PC technicians and for every geek guy.



It can be used as a standalone program, launched by the user, or it can act as a simple PC inventory solution, sending data to an online DB or via text files, ready to be collected. 

Setup:

It's a standalone executable, very small (< 6 Megabytes) so you have only to


Download
Now you have the file, you can launch it, it will install itself in "c:\autoit\computerplucker\" and it will put a shortcut on your desktop.
The windows registry is untouched, no mess no tricks, only some files copied, and in 'Tools' menu you have also the "uninstall" option.

Use:

Launch the shortcut and  explore the GUI, the icons in the leftside vertical band will show you various data about your system.



Also you have some drop down menus, with various utilities.



Use as a remote inventory system:

The idea is to export the essential data of the machine, and to collect them.
You can do it manually "one shot" producing a text data file to manage yourself, (copying or sending via mail wherever you want), or writing a data record to an online DB, to be recovered at a later time.




From the "Tools"dropdown menu you can:
  • write ".INI" text data file: a file in "ini" format with 30 fields is written in the install folder of Computer Plucker, my choice is the INI format because is very human readable but also easily to parse with an automated system; Here you can download an example text file.
  • Send a crypted or non crypted data record to an online DB
  • Schedule a task to periodically create the .ini data file
  • Schedule a task to periodically send a crypted record to the online DB.

The "online DB" is a free MySql instance , this DB is not intended as the main repository for the data, but is only a sort of data cache to later retrieve and organize the data of the various machines.

As today the account of this DB is embedded and encrypted in code.

The version you are downloading from here is using these parameters:

    Local $mysqlhost = "sql11.freemysqlhosting.net"

    Local $mysqlport = "3306"

    Local $mysqldb = "sql11403701"

    Local $mysqluser = "sql11403701"

    Local $mysqlpsw = "QtL7T9U5GV"

You can browse it here: 

The DB is one table of 30 mysql tinytext fields... very simple indeed... ; you can find crypted and decrypted data.

You can try to upload data to this DB and access (phpmyadmin or a random mysql browser app) to see the results.

PRIVACY warning: you are uploading data of your PC account and PC data, test as your risk !

Or you can use my companion app ComputerPluckerDBbrowser (see link at the end of this post) an app to manage (basically collect and view) the data, but adaptable for exporting and managing data in production.


A schema of the possibilities:




So the left part is managed by ComputerPlucker.exe, and all the activities on the right side can be done with ComputerPluckerDBbrowser.exe.

The version you can download here is very simple (browsing the online MySQL db):




But is available a more advanced version capable to manage all the possibilities from the previous schema, contact me for this version:


This is only a working proof of concept, in production I connect the system to other apps.

You can consider to modify and adapt this system to your needs, feel free to contact me for the source code, advices and tips.



ComputerPlucker.EXE is downloadable >HERE<


ComputerPluckerDBbrowser.EXE is downloadable >HERE<

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