Library 2050: A Raspberry Pi Smart Library Robot

Library 2050: A Raspberry Pi Smart Library Robot | MakeMindz
RASPBERRY PI ROBOTICS PROJECT

Library 2050 📚✨

A miniature library from the future — it finds your book, lights up the right shelf, listens to your voice, recommends your next great read, and even sorts returned books all on its own.

🔍 Book-Finding Carriage 💡 Smart Shelves 🪪 RFID Borrowing 🧠 AI Recommendations 🎙️ Voice Assistant ♻️ Auto Return & Sorting

🧠 What Are We Building?

Library 2050 is a miniature model library powered entirely by a Raspberry Pi 4. Ask it to find a book out loud, and a motorized carriage slides along the shelf rail while an addressable LED lights up exactly where that book sits. Scan a library card and a book tag at the desk to borrow it — the Pi logs it and speaks a recommendation for what to read next. Drop a book back into the return chute, and it automatically identifies the book and sorts it into the correct bin with a servo-controlled flap.

This is our biggest MakeMindz build yet — combining RFID identification, addressable LEDs, motor and servo control, speech recognition, text-to-speech, and simple AI-style recommendation logic into one working miniature system.

🗺️ System Architecture

Four connected modules, all controlled by one Raspberry Pi 4

🔍 Book-Finding Carriage

A small motorized carriage slides along a rail in front of the shelf, guided by limit switches, stopping exactly at the requested book's position.

💡 Smart Shelf LEDs

A WS2812 addressable LED strip runs along the shelf front — one LED per book slot — glowing to highlight the exact book you asked for.

🪪 RFID Borrow & Return Stations

One RFID reader at the checkout desk logs borrowing; a second at the return chute identifies returned books automatically.

🎙️ Voice + AI Brain

The Raspberry Pi listens for spoken commands, matches them to its book database, and speaks back recommendations using simple category-matching logic.

🧰 Components Required

Everything you need, with approximate India pricing

ComponentQuantityApprox. Price (INR)
Raspberry Pi 4 Model B (2GB/4GB)1₹4500
MFRC522 RFID Reader Module2₹180
RFID Tags/Cards (books + library cards)10₹150
WS2812 Addressable LED Strip (30 LEDs)1₹350
L298N Motor Driver + 12V DC Geared Motor1 set₹350
Micro Limit Switch (carriage end-stops)2₹30
SG90 Micro Servo (return sorting flap)1₹150
USB Microphone (mini)1₹300
USB or 3.5mm Mini Speaker1₹250
16x2 I2C LCD Display1₹220
MicroSD Card (32GB, Raspberry Pi OS)1₹400
5V 3A USB-C Power Supply1₹450
Breadboard + Jumper Wires (M-M, M-F, F-F)1 set₹200
Aluminum/Wood Rail + Belt (carriage track)1 set₹200
Cardboard, Wood or Acrylic (mini shelf model)1 set₹400

💡 Source the Raspberry Pi and electronics from Robocraze, Flyrobo, or Robu.in. Rail, belt, and shelf materials are available at hardware or craft stores.

🔌 Circuit Diagram

How everything connects to the Raspberry Pi 4 GPIO header

Raspberry Pi 4 RFID Reader 1 (Checkout) SDA GPIO8 · RST GPIO25 RFID Reader 2 (Return) SDA GPIO7 · RST GPIO24 Shared: SCK GPIO11, MOSI GPIO10, MISO GPIO9 WS2812 LED Strip Data → GPIO18 L298N Motor Driver IN1 GPIO23 · IN2 GPIO27 ENA GPIO13 (carriage motor) Limit Switches (2) Left GPIO20 · Right GPIO21 SG90 Sorting Servo Signal → GPIO12 16x2 I2C LCD SDA GPIO2 · SCL GPIO3 USB Microphone via USB port Speaker via USB or 3.5mm jack RFID readers run on 3.3V. LED strip and motor need a separate 5V/12V supply — never power them from the Pi's 5V pin directly. Share a common GND across every module for reliable signals.

📌 Pin Connection Table

ComponentPin on ComponentRaspberry Pi GPIO (BCM)
RFID Reader 1 (Checkout)SDA (CE0)GPIO8
RFID Reader 1 (Checkout)RSTGPIO25
RFID Reader 2 (Return)SDA (CE1)GPIO7
RFID Reader 2 (Return)RSTGPIO24
Both RFID ReadersSCK / MOSI / MISOGPIO11 / GPIO10 / GPIO9 (shared bus)
WS2812 LED StripData InGPIO18 (PWM0)
L298N Motor DriverIN1 / IN2GPIO23 / GPIO27
L298N Motor DriverENA (speed)GPIO13
Carriage Limit SwitchesLeft / RightGPIO20 / GPIO21
SG90 Sorting ServoSignalGPIO12
16x2 I2C LCDSDA / SCLGPIO2 / GPIO3
USB Microphone & SpeakerVia USB ports (no GPIO)

🛠️ Step-by-Step Build Guide

1

Build the Mini Shelf & Rail

Construct a small bookshelf model from cardboard, wood, or acrylic, about 3-4 book slots wide. Mount a straight rail or rod along the front for the carriage to slide on.

2

Mount the Smart Shelf LEDs

Run the WS2812 LED strip along the shelf edge, positioning one LED per book slot so each can glow individually when that book is requested.

3

Build the Book-Finding Carriage

Attach a small carriage (a block with a bright indicator LED or small laser pointer) to a belt driven by the DC motor. Fix limit switches at both ends of the rail to mark the carriage's boundaries.

4

Set Up the RFID Checkout Desk

Mount RFID Reader 1 at a small "desk" area where users tap their library card, then tap the book they want to borrow.

5

Build the Return Chute

Create a small slot where returned books slide past RFID Reader 2, landing on a servo-controlled flap that tips left or right into "Fiction" and "Non-Fiction" bins.

6

Wire Everything to the Raspberry Pi

Connect both RFID readers, the LED strip, motor driver, limit switches, servo, and LCD to the Pi's GPIO header exactly as shown in the circuit diagram and pin table above. Plug in the USB microphone and speaker.

7

Install the Software

Set up Raspberry Pi OS on your microSD card, then install the required Python libraries: mfrc522, rpi_ws281x, gpiozero, speechrecognition, pyttsx3, and RPLCD.

8

Run the Code & Test

Run the Library 2050 script below. Say "find [book name]" to watch the carriage move and the LED glow, tap RFID tags to borrow and hear a recommendation, and drop a book in the return chute to see it sorted automatically!

💻 Python Code (Raspberry Pi)

Run this script with Python 3 after installing the required libraries

# Library 2050 - MakeMindz Robotics Project
import time
import threading
import speech_recognition as sr
import pyttsx3
from gpiozero import Motor, Servo, Button
from rpi_ws281x import PixelStrip, Color
from mfrc522 import SimpleMFRC522
from RPLCD.i2c import CharLCD

# ---- Hardware setup ----
carriage_motor = Motor(forward=23, backward=27, enable=13)
left_limit = Button(20)
right_limit = Button(21)
sorting_servo = Servo(12)
strip = PixelStrip(30, 18)
strip.begin()

checkout_reader = SimpleMFRC522()   # RFID Reader 1 on CE0
lcd = CharLCD('PCF8574', 0x27)
speaker = pyttsx3.init()
recognizer = sr.Recognizer()

# ---- Book database: title -> (led_index, carriage_position, category) ----
books = {
    "harry potter": {"led": 2, "pos": 1, "category": "fantasy"},
    "percy jackson":  {"led": 6, "pos": 2, "category": "fantasy"},
    "panchatantra":   {"led": 10, "pos": 3, "category": "folktales"},
}
recommend_map = {
    "fantasy": ["percy jackson", "harry potter"],
    "folktales": ["panchatantra"],
}

def speak(text):
    print(text)
    speaker.say(text)
    speaker.runAndWait()

def light_shelf(index):
    strip.setPixelColor(index, Color(0, 200, 255))
    strip.show()
    time.sleep(4)
    strip.setPixelColor(index, Color(0, 0, 0))
    strip.show()

def move_carriage_to(position):
    # Simplified: drive toward the correct end, timed per shelf position
    carriage_motor.forward(0.6)
    time.sleep(0.4 * position)
    carriage_motor.stop()

def find_book(title):
    title = title.lower()
    if title in books:
        info = books[title]
        speak(f"Found it! Moving to {title}")
        move_carriage_to(info["pos"])
        light_shelf(info["led"])
        lcd.clear()
        lcd.write_string(title[:16])
    else:
        speak("Sorry, I could not find that book")

def recommend_book(category):
    options = recommend_map.get(category, [])
    if options:
        speak(f"You might also enjoy {options[0]}")

def handle_borrow():
    speak("Scan your library card")
    card_id, card_text = checkout_reader.read()
    speak("Now scan the book")
    book_id, book_text = checkout_reader.read()
    title = book_text.strip().lower()
    if title in books:
        speak(f"You have borrowed {title}. Enjoy!")
        recommend_book(books[title]["category"])

def handle_return(book_text):
    title = book_text.strip().lower()
    if title in books:
        category = books[title]["category"]
        if category == "fantasy":
            sorting_servo.max()   # tip toward Fiction bin
        else:
            sorting_servo.min()   # tip toward Non-Fiction bin
        time.sleep(1.5)
        sorting_servo.mid()
        speak(f"Thanks for returning {title}!")

def listen_for_commands():
    with sr.Microphone() as source:
        while True:
            try:
                audio = recognizer.listen(source, timeout=5)
                command = recognizer.recognize_google(audio).lower()
                print("Heard:", command)
                if "find" in command:
                    book_name = command.replace("find", "").strip()
                    find_book(book_name)
                elif "borrow" in command:
                    handle_borrow()
                elif "recommend" in command:
                    recommend_book("fantasy")
            except Exception:
                pass

# ---- Run voice assistant and return-chute scanning together ----
if __name__ == "__main__":
    speak("Library 2050 is ready. Ask me to find a book!")
    threading.Thread(target=listen_for_commands, daemon=True).start()

    return_reader = SimpleMFRC522()   # RFID Reader 2 on CE1 (return chute)
    while True:
        try:
            book_id, book_text = return_reader.read()
            handle_return(book_text)
        except KeyboardInterrupt:
            break

⚙️ How It Works

When you speak a command like "find Percy Jackson," the Raspberry Pi's microphone captures your voice, converts it to text, and matches it against the book database. The carriage motor drives toward that book's position, guided by the limit switches, while the matching LED on the smart shelf strip glows. At the checkout desk, tapping your library card and then a book's RFID tag logs the borrow event and triggers a spoken recommendation based on that book's category. When a book is dropped into the return chute, the second RFID reader identifies it, and the sorting servo tips the flap to route it into the correct bin — fully automated, from finding to borrowing to returning.

❓ Frequently Asked Questions

Do I need internet access for the voice assistant? +

The example code uses Google's speech recognition, which needs internet. For an offline version, you can swap in a library like Vosk, which runs speech recognition entirely on the Raspberry Pi.

How does the carriage know exactly where to stop? +

This miniature version uses simple timed movement calibrated to each shelf position. For more precision, you can add a rotary encoder to the motor for exact position tracking.

Why do we need two RFID readers? +

One reader handles borrowing at the checkout desk, while the second sits at the return chute so books can be identified automatically as they're dropped off — no manual scanning needed for returns.

How "smart" are the AI recommendations really? +

This miniature version uses simple category matching — books tagged with the same genre are suggested to each other. It's a great introduction to recommendation logic before exploring more advanced machine learning techniques.

Can I add more books and shelves? +

Yes! Just add more entries to the books dictionary with their own LED index, carriage position, and category, and extend your physical shelf and LED strip to match.

🚀 Upgrade Ideas

🧠 Real Machine Learning

Replace the simple category map with a collaborative-filtering model trained on real borrowing history for smarter recommendations.

📷 Camera-Based Book Detection

Add a Raspberry Pi Camera and basic image recognition to confirm the right book was actually picked up from the shelf.

📱 Web Dashboard

Build a small Flask web app showing which books are borrowed, overdue, or available in real time.

🔄 Encoder-Based Precision

Add a rotary encoder to the carriage motor for pixel-perfect stopping at each shelf position, instead of timed movement.

Educational Robotics & Coding for Young Innovators

📍 Chennai, India

✉️ hello@makemindz.in

© 2026 MakeMindz. All rights reserved.

Comments

Product Cards
Buddy Bot eBook
⭐ New 2026 Release
Build Your
Own Robot!
3D design, wiring &
Arduino coding.
Young inventors love it!
🖨️
3D Print
All parts
Wire it
Circuit guide
💻
Code it
Arduino IDE
🤖
Watch it
Walk & react
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Website Offer
₹499 300
🌍 International: $5 USD
One-time · Instant digital delivery
🔒 Secured by Razorpay · Your data is safe
📄 Download Free Sample Copy
🔒 Secured by Razorpay · Your data is safe
🍓
Raspberry Pi Pico Mastery
21 Projects
⚡ Launch Price — 80% OFF
Learn Pico
Build 21 Projects!
MicroPython · Wokwi
IoT · Certificate
Perfect for beginners!
🖥️
Wokwi
No hardware
🐍
MicroPy
From zero
🔨
21 Projects
IoT + sensors
📄
Certificate
Verified cert
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Launch Offer
₹999 200 80% OFF
🌍 International: $5 USD
One-time · Lifetime access · No subscription
🔒 Secured by Razorpay · UPI · Cards · NetBanking
🎉

You're in!

Payment successful! Your Buddy Bot eBook is ready. Time to build!

📖 Access Your eBook Now
🎉

Enrolled!

Payment successful! Lifetime access to all 21 Pico Projects is yours!

🍓 Go to My Course