Introduction: Book Conservation Chamber Using Raspberry Pi

About: Hello my name is Freya De Muynck. I am currently studying MCT at Howest (Kortrijk, Belgium).

Hello everyone!

For a school project at MCT Howest Kortrijk, I made a Book Conservation Chamber. This is a climate controlled box in which you can store books.

The reason why I choose to make this is because a lot of people put their old books in the basement or in the attic. However, most basements are too humid to store books in while the temperature in the attic can be too high, especially during the summer.

In this instructable you can find the step by step process to recreate this project.

All the code can be found in my github repo: https://github.com/DeMuynckFreya/BookConservationChamber

Step 1: Supplies

Electronics

  • Raspberry Pi 4 model b
  • Raspberry Pi USB-C power supply
  • 16GB micro SD card
  • Ethernet cable
  • ESP32
  • USB-A to Micro USB-B data cable
  • Breadboard power supply
  • AC/DC power adapter
  • Solderless breadboard 830 points
  • 3x Solderless breadboard 170 points (if you solder things together, you might not need these)
  • Raspberry Pi breakout expansion board + ribbon cable
  • Dupont wires (various sizes and types)
  • 5x 470Ω resistors
  • 1x 10kΩ resistor
  • LDR (light dependent resistor)
  • 3x4 keyboard membrane matrix
  • RFID-RC522 module
  • RFID stickers
  • 2x button
  • LCD display
  • Potentiometer
  • PCF8574
  • DHT11 module
  • Servo motor
  • 5V brushless fan
  • NPN transistor 2n2222a
  • Diode

Casing

  • MDF 15mm 200x122cm
  • MDF 5 mm 50x100cm
  • Transparen PS sheet 100x50cm
  • Wooden plank 15x15mm 270cm
  • Piano hinges
  • Screws
  • Doorknob
  • Hook
  • Metal chain (optional)
  • Floral wire (optional)
  • Paint (optional)

Tools

  • Saw
  • Drill
  • Sanding paper
  • Painting roll
  • Milling machine
  • Superglue

The cost of this is around 200 €. This could be lowered by choosing smaller wooden boards, there just weren't any available at the stores that I went to.

Step 2: Schematic and Wiring

To make my schematics I used Fritzing.

On the electrical view I used orange for 3.3V and red for 5V.
With the DHT11 module you will need to check if you have the sensor or the module. If you have the sensor, connect it as seen in the electrical view. If you have the module, connect it as seen in the breadboard view.

Step 3: Database Design

A lot of data will be collected while using this project. All the sensor and actuator is stored in the History table. The sensors and actuators are stored in the Component table.

Considering that there are books used in my project, that table exists as well. To make it all more accessible I separated the books from the authors and the language.

Step 4: Setup ESP32

Install ESP32 in Arduino IDE

  1. Open the preferences window from the Arduino IDE: File > Preferences.
  2. Towards the end you will find "Additional Boards Manager URLs", enter the following URL:
    <a href="https://dl.espressif.com/dl/package_esp32_index.js">https://dl.espressif.com/dl/package_esp32_index.js...</a>
    
  3. Open boards manager: Tools > Board > Board Manager, click the install button for "esp32 by Espressif Systems".

Uploading the code

  1. Connect the ESP32 module to the computer with the USB cable.
  2. Upload the code with the Arduino IDE. Remember to press the boot button on the ESP32 module while connecting.
    int ldr = 4;
    int servo = 22;
    const int PWMFreq = 50;
    const int PWMChannel = 0;
    const int PWMResolution = 8;
    int dutyCycle = 0;
    
    void setup() {
      Serial.begin(9600, SERIAL_8N1,16,17);
      ledcSetup(PWMChannel, PWMFreq, PWMResolution);
      ledcAttachPin(servo, PWMChannel);
      ledcWrite(PWMChannel, dutyCycle);
    }
    
    void loop() {
      if (Serial.available()) {
        String line = Serial.readStringUntil('\n');
        if (line == "LDR") {
          int value = analogRead(ldr);
          float convertedValue = convertldr(value);
          Serial.println(convertedValue);
        }
        if (line == "close") {
          dutyCycle = 16;
          ledcWrite(PWMChannel, dutyCycle);
          Serial.println("lock is closed");
        }
        if (line == "open") {
          dutyCycle = 5;
          ledcWrite(PWMChannel, dutyCycle);
          Serial.println("lock is open");
        }
      }
    }
    
    float convertldr(int value){
      return (value/4095.0)*100;
    }

Step 5: Setup Raspberry Pi

Configuring the SD card

  1. Download the latest Raspberry Pi OS.
  2. Download Win32 Disk Imager.
  3. Format the SD card using SD Card Formatter or a similar program.
  4. Write the Raspberry Pi OS on the SD card using Win32 Disk Imager
  5. Go to the SD card directory and open cmdline.txt.
    Add 'ip=169.254.10.1' at the end of the line.
    Save the file.
    Create a file named 'ssh' without content or extentions.
  6. Put the SD card in the Raspberry Pi and connect to your computer using the LAN port and an ethernet cable.
  7. Connect the power to the Raspberry Pi.

Configure the RPi

Use Putty software to configure the Raspberry Pi.

Connect to the pi using ip address 169.254.10.1 and port 22 with connection type SSH.
Login with the starter information -> User: pi & Password: raspberry
It is recommended to change this as soon as possible -> here is a guide to do this https://www.raspberrypi.org/documentation/linux/usage/users.md

Raspi-config

First we will have to enable different interfaces and to do that we have to type the following code:

sudo raspi-config 

Enable following interfaces:

  • One-wire
  • Serial
  • I2C
  • SPI

Connect to WIFI

First, type the following command to become root

sudo -i 

Once you're root, use the following command: (Replace SSID with your network name and password with your network password)

 wpa_passphrase "ssid" "password" >> /etc/wpa_supplicant/wpa_supplicant.conf 

Check if this is correct using

nano /etc/wpa_supplicant/wpa_supplicant.conf 

Now that the network is added, let's enter the WPA client interface

wpa_cli 

Select your interface

interface wlan0 

Reload the file

reconfigure 

And finally check if you are connected:

ip a


Updating the RPi + installing software

Update the RPi

sudo apt-get update<br>sudo apt-get upgrade

Now that the Pi is updated, install Apache

sudo apt install apache2 -y

Install MariaDB

sudo apt install mariadb-server mariadb-client -y

Install python packages

pip3 install flask-cors<br>pip3 install flask-socketio
pip3 install mysql-connector-python
pip3 install gevent
pip3 install gevent-websocket

Now that this is all done reboot the Pi.


Setup the database

Now that everything is installed, we will setup the database. Simply follow this guide https://pimylifeup.com/raspberry-pi-mysql/

Step 6: Building the Exterior

On the first picture you can find the estimated measurements. I would suggest to make the left part slightly bigger. That way it will be easier to attach the components.

Cutting the MDF boards and the PS sheet

  1. Saw the lid and the bottom using the 15mm MDF. These are 440x210mm.
  2. Saw a second bottom plate using the 5mm MDF that is slightly smaller.
  3. Now we have the front and back, cut these at a 45° angle. These are, on the outside (longest side) 470x240mm. This is with the 15mm MDF.
  4. The sides are also cut at a 45° angle. Again with the 15mm MDF 315x240mm.
  5. At last we have the false ceiling and wall. Using the 5mm MDF, cut a board of 241x290.5mm and a board of 241x249.5mm.
  6. Cut 4 pieces of the wooden plank (15x15mm) for the door at a 45° angle.
  7. Cut 2 pieces of the plank (15x15mm) for additional support of the lid.
  8. Check the measurements of the wood for the door and 7mm to the height and width. Use these measurements for the PS sheet.

Milling grooves in the wood

Now the boards are cut, it is time to mill some grooves of around 7mm. I started with the back (inside).

  1. Make a horizontal groove from the left side towards the middle. Use the first board (241x290.5mm) to measure where you need to stop. Shift this board 5mm to the left.
  2. To make the vertical groove, use the second board (241x249.5) and shift it 5mm downwards.
  3. For the front of the case, this process is repeated but measured from the right side.
  4. Take one of the sides and, using the the front and back, measure where the horizontal has to be milled.
  5. Last but not least mill a horizontal groove on the bottom of the bottom (15mm) plate.
  6. Mill some grooves in the wood for the door, this way the PS plate will be held in place.

Creating holes for the components/power supply

Next we will make the holes for the components. The location for these can be chosen depending on what you want it to look like.

  1. This first one is not really for a component. Saw a handle in the lid.
  2. Next drill a hole in the back for the power adapter cables. The size depends on the type of cables that are used.
  3. Drill a hole in the false ceiling for the fan.
  4. Cut a rectangle in the same board for the DHT11 module.
  5. Saw holes in the front for the LCD, keypad, RFID-reader and the buttons.
  6. Drill 2 holes in the bottom, one for the LDR (on one side of the groove) and another on the other side to connect the wires to the ESP32.
  7. Cut a rectangle in the front for the door.
  8. Cut a rectangle in the false wall for the servo arm.

Build the case

Now attach it all together using screws. Use the piano hinge, this can be cut to size, to attach the lid and the door. Attach the doorknob on the outside of the door and the hook on the inside. Beware, before attaching the thinner bottom board to the thicker one, you will need to wire the LDR.

Attaching the components

Attach the components to the casing using screws. Add some electrical tape where necessary to prevent the wires from detaching. Using floral wire, I attached a part of a popsicle stick to the servo arm to make it longer.

Finishing touches

At last, sand and paint the wood, according to the instruction on your paint can. This can be done before you attach everything. But if you only want to paint the outside, this can be done as the final step.