Introduction: Smart Bookshelf at Home

Welcome to my amazing project.
This project is for people who read a lot of books from the library. It serves as a way to have a better overview of how long you have left before you need to return your book.

How it works:
When you put a new book on the bookshelf the shelf detects it and its position. Then it calculates, through a time you need to give in through the website, how long you have left before you need to hand it in. At the top of the shelf, there is also a neopixel strip, which shows how long you have left.

Step 1: Supplies/Materials

Main components:

  • Raspberry pi + T-connector piece + power supply for Rpi
  • Arduino Uno + power supply

Sensors:

  • 5 LDR (light dependent resistors) + MCP 3008 (for analog communication) + 5 10kΩ resistors
  • Infrared sensor (HC-SR501)
  • RFID-RC522 + RFID cards

Actuators:

  • 1602 LCD + PCF8574 8-bit (optional)
  • WS2812B (led strip)

Extra:

  • Level shifter (for communication between Arduino and raspberry pi)
  • potentiometer
  • lots of cables
  • 16GB mini sd card

For more precise information, prices, and were to find them see the BOM (Bill of Materials) below:

Attachments

Step 2: The Wiring

We will start with the most important part, the wiring of everything.

To make it easier for you I provided the general schematics and the breadboard schematics below.

Step 3: Wiring the LCD

PCF8574 (I2C expander)

Just like on the datasheet the top of the PCF8574 is marked with a little notch.
Tip: Make sure that the I2C bus of your Pi is enabled

  • Connect A0, A1, A2 and GND to the ground
  • Connect VCC to the 3.3V of your power supply
  • Connect SDA to GPIO 2 / SDA1 I2C and SCL to GPIO3 / SCL1 I2C

LCD

  • Connect VSS, K and R/W to the ground
  • Connect VDD and A to the 5V side of your raspberry pi
  • Connect the potentiometer to 5V on one side and the ground on the other.
  • Connect the middle pin to the V0 of your LCD. This variable resistor can be used to adjust the contrast of the display.
  • Connect RS to GPIO 17
  • Connect E to GPIO 27
  • Now link all DB pins to the corresponding P pins on the PCF6574

(since we won't be reading anything from the display we might as well put it on the ground instead so it's always on write mode)

Step 4: Wiring the Light Sensors

MCP3008

Again the top of the chip is marked with a little notch.

  • Connect the Vdd and Vref pins to the 3.3V side of your raspberry pi
  • Connect AGND and DGND to the ground
  • Connect CLK to GPIO 11 / SPI0_SCLK
  • Connect Dout to GPIO 9 / SPI0_MISO and Din to GPIO 10 / SPI0_MOSI
  • Connect CS to GPIO 8 / SPI0_CE0_N

LDR

  • connect the 5 10kΩ resistors to the 3,3V of your raspberry pi
  • connect the other end of the resistors to the LDR and to a channel of the MCP3008 (from CH0 to CH4)
  • connect the other side of the LDR to the ground

Step 5: Wiring the Infrared Sensor

I also included a picture with some extra information for this one because the normal one is a bit confusing.

  • connect the 5V power off your raspberry pi to the VSS (the right pin)
  • connect the middle pin to GPIO21 on your raspberry pi
  • connect the ground to the ground

I keep the jumper set to single trigger (the bottom one)
My sensitivity is adjusted in the middle and the time delay is turned almost completely to the right, but that is more a personal choice.

Step 6: Wiring the Arduino

WS2812B (led strip)

I used a led strip with less than 30 LEDs. If you are planning on using a bigger one then you will need to get an
external power supply for it.

  • Connect the 5V from the Arduino with the VSS of the LED strip
  • Connect the Din with D7 of your Arduino
  • Connect the ground to the ground of your Arduino

RFID-RC522

  • Connect the 3,3V from the RFID scanner with the 3,3V of the Arduino
  • Connect the RST with D9 PWM
  • Connect the MISO with D12
  • Connect the MOSI with D11
  • Connect the SCK with D13 SCK
  • Connect the SDA with D10 PWM
  • Connect the ground of the RFID reader to the ground of your Arduino

Step 7: Wiring Connection Between Arduino and Raspberry Pi

Level shifter

  • Connect the LV (low voltage) to the 3,3 of your raspberry pi
  • Connect the GRD next to it to the ground of your raspberry pi
  • Connect the HV (high voltage) to the Vin or 5V of your Arduino
  • Connect the GRD next to it to the ground of your Arduino
  • Connect the GPIO15/RXDO of your raspberry pi to the LV1
  • Connect the GPIO14/TXDO of your raspberry pi to the LV2
  • Connect the TX of your Arduino to the HV1
  • Connect the RX of your Arduino to the HV2

Step 8: The Case

This is the part where you have the most creativity. I made something simple and with very limited tools, so I would actually advise trying to make something on your own.

The outside:

The Bottom plate:

  • 15cm - 28,5cm

The front plate:

  • 30cm - 32cm
  • cut out 9cm - 24cm
  • place LCD: 8cm - 3cm
  • place Infrared sensor: 2cm diameter circle

Right plate:

  • 17cm - 32cm
  • A cut that is 1cm large and goes 0,5cm (around half the plate) into the plate (to slide in the bottom plate).
  • Place RFID: 4,5cm - 6cm
  • 2 Dovetail cuts to connect with the backplate

Left plate:

  • Same as right except without the hole for the RFID sensor

Top plate:

  • 30cm - 17cm
  • Also, a cut that is like the one from the Right and left plate to put the neopixel strip in

Backplate:

  • 33cm - 30cm
  • cut out the parts for making the dovetail connections with the left and right plates

The Shelf:

Bottom shelf:

  • 25cm - 16cm
  • every 5 cm drill a small hole to fit the light sensors in.

The sides of the shelf:

  • 24cm - 16cm

Glue the outside together except the bottom and backplate. Then place the led strip in and then place the inside shelf in.

Also, drill some holes where the power of your raspberry pi and Arduino are


Step 9: The Code

The code you need to download is posted in this GitHub repository.

Raspberry pi

Download the code on GitHub and put it on the micro sd card.

Connect raspberry pi to the internet

Put the sd card in your raspberry pi.
To connect your raspberry pi to the internet you need to make an ssh connection to your raspberry pi, I recommend using the putty application for this.
Connect through a cable to the address 192.168.168.168. The user is student and the password is W8w00rd.
Once logged in use "wpa_passphrase "your_SSID@Home" "your_wifi-password" >> /etc/wpa_supplicant/wpa_supplicant.conf" to add your wifi.
Then type "wpa_cli -i wlan0 reconfigure" to start on your wifi.

Code Arduino

Download the code for the Arduino on GitHub and run it.

Now everything should be working. Curious what you guys made out of it. Enjoy.