Introduction: RFID Based Wardrobe Managament System

It all started with a struggle that I had when I had to pack my suitcase. I had to go to my dorm but i didn't remember how many t-shirts or socks were still there. So I decided to make my life a little bit easier by making an RFID based storage system that keeps track of what clothing is in or out the closet.

I am a student at Howest Kortrijk who studies New Media and Communication Technology(NMCT)
For our module Project we had to make an Raspberry Pi or Arduino based prototype who collects data via sensors and stores this in a MySQL database. In this instructable I will guide you through each step so you can recreate this prototype for yourself.

Step 1: Materials

First and foremost, you will need a couple of components in order to recreate this project:

  • 1 x Raspberry Pi 3 Model B €37.95
  • 1 x Raspberry Pi Power Supply 5.1V/2.5A €9.95
  • 1 x 16 GB microSD €11.95
  • 1 x Socketbox header 2x20 straight male €3.90
  • 1 x RC522 rfid reader €1.44
  • 10 x RFID tags 125 Khz (buy how many you need) €1.72
  • 1 x LCD screen 5V 2x16 characters €1.62
  • 1 x Plus T cobbler €2.01
  • Cable connectors for soldering (I used these €0.87)
  • 1 x Printboard 8,5cm x 3.5cm or bigger €1.69
  • Passive buzzer €1.01
  • 10 x Cross screw
  • Velcro strips (optional)

Step 2: Tools

Tools you will need:

  • Soldering iron
  • Cross screwdriver
  • Scissor
  • 3d printer
  • Your computer

Step 3: Downloading and Installing Raspbian

You will need to install Raspbian on the Raspberry Pi. Once the operating system is on your microSD wait to put it in your Raspberry Pi. If you have, just plug out the power of your Pi and put the microSD back into your computer.

Step 4: Enable Ssh

To access your Pi remotely we will have to enable ssh.

  • Open explorer on your computer and look for the your microSD with the name "boot(E:)" or some other letter (picture above).
  • Open the file "cmdline.txt" with notepad.
  • Add "ip=" to the current content. Watch out everything must be on one line!
  • Save the file and on the image above is there an example how it should look like.
  • Now to enable ssh on your Pi just add an empty file in "boot(E:)" with the name "ssh" lowercase and no extension.
  • Safely remove your microSD and put it back in your Pi.
  • Connect your computer and your Raspberry Pi with an ethernet cable.
  • Now power your Pi and wait a minute or 3 for the Pi to power up.

Step 5: Install Putty

Now is your Pi ready to be accessed via ssh.

  • Install putty on your computer.
  • Open putty and make an ssh-connection with the Pi. The ip that you give in to connect with the Pi is the same as the one that we filled in cmdline.txt ( The port is 22 (example above of how it should look like).
  • Once you clicked on open you should get a warning once you connect for the first time. You can ignore this and just click on yes.
  • Log in now with these credentials:
    - username:pi
    - password: raspberry

If all done correct you should see the terminal (example above).

NOTE: If you want to use your numpad in the terminal chose in the putty configuration category terminal select "Features" and check "Disable application keypad mode" and select "Empty string" at the radio buttons (example above).

Step 6: Change Your Password and Hostname

    Do the following steps in the terminal:

    • Type in the terminal sudo raspi-config.
    • Go to option 1 (change user password) and give a new password. Write it down so you don't forget it.
    • Go to option 3 (boot options) and :
      - For Desktop/CLI select the first option "Console".
      - Disable "Wait for network at boot".
      - Chose "Splash screen" en disable this option.
    • Go to option 4 (Localistation Options) and:
      - Set the right timezone.
      - Select at "WiFi Country" for your country.
    • Close raspi-config
    • Use this command in the terminal to change your hostname sudo nano /etc/hostname. In the file change the name to something unique. Write it down so you don't forget it.
    • Save the file by doing ctrl-x and confirm if by hitting y
    • Reboot your Pi using the command sudo reboot.

    Step 7: Networkconfiguration

    The IP address that we have added in "cmdline.txt" is now set as static IP. However, we would rather mimic the operation of Windows. This means prefer DHCP and only configure an APIPA address if DHCP is not available.

    • Typ in the terminal sudo nano /etc/dhcpcd.conf.
    • Add the following lines (most of it should already be in it at the very bottom, you just have to get it out of comments and change the IP address.):
      # define static profile
      profile static_eth0
      static ip_address=
      # fallback to static profile on eth0
      interface eth0
      fallback static_eth0
    • Safe the file using ctrl-x and confirming it by hitting "y".
    • Use the command sudo nano /boot/cmdline.txt now delete the static IP in /boot/cmdline.txt and save the file.

    • Now restart the networking service networking restart.

    Step 8: Connect Your Pi to Wifi

    Via the ethernet port we can now connect to the Pi, but we do not get on the internet yet. For that we will now connect to the WiFi network. Raspbian uses wpa_supplicant to manage WiFi connections.

    • Give the command sudo -i to temporarily become root, the prompt should change to root @ host #.
    • Now we can add a network with the following command (fill in the password and the SSID of your wifi:
      echo "password" | wpa_passphrase "SSID" >> /etc/wpa_supplicant/wpa_supplicant.conf
    • sudo nano /etc/wpa_supplicant/wpa_supplicant.conf and verify that the network has been added. Double check also that the correct country is set (COUNTRY = INITIALS OF YOUR COUNTRY) and optionally remove the comment line with the password and save the file.
    • Typ following commands:
      - sudo wpa_cli
      - scan
      - reconfigure
      - status
      - quit
    • Check with ip addr show dev wlan0 whether you actually have a usable IP address and finally test the Internet connection with wget

    Step 9: Bonjour

    Now that we are connected to the wireless network, it would be useful if we could make an SSH connection over it and not always use a UTP cable to connect the Pi. However, we have a problem, because we do not know the IP address that our Pi is assigned via DHCP. Luckily we have Bonjour.

    Bonjour used to be downloadable separately from Apple, but the latest versions are only available as part of iTunes. However, we can do it with a trick: if you do not start the iTunes installation file but instead open it as a ZIP archive (eg with 7-zip), you will see that there is a separate file for Bonjour. Unzip this file and install it by double-clicking it.

    Then you should be able to connect to the hostname of your Pi by adding .local in the back. That is why it was also important to set up a unique hostname in raspi-config.

    NOTE: You have to be on the same network, just like with APIPA, to get started with Bonjour!

    Step 10: Make Your Own User

    • Create a variable with your desired username:
    • Add the user to specific groups:
      groups=$(id pi -Gn | sed 's/^pi //g' | sed 's/ /,/g')

      sudo useradd ${user} -s /bin/bash -m -G ${groups} sudo sed "s/^pi/${user}/" /etc/sudoers.d/010_pi-nopasswd | sudo tee "/etc/sudoers.d/011_${user}-nopasswd" sudo passwd ${user}

    • Now log in:
      su - me

    Step 11: Install Pycharm

    Download and install pycharm on your computer.

    Step 12: Preparation

    Installing packages

    • sudo apt update
    • sudo apt install -y python3-venv python3-pip python3-mysqldb mariadb-server uwsgi nginx uwsgi-plugin-python3

    Virtual environment

    • python3 -m pip install --upgrade pip setuptools wheel virtualenv
    • mkdir project1 && cd project1
    • python3 -m venv --system-site-packages env
    • source env/bin/activate
    • python -m pip install mysql-connector-python argon2-cffi Flask Flask-HTTPAuth Flask-MySQL mysql-connector-python passlib spidev RPi.GPIO

    Clone Mobile Closet project

    • Open pycharm
    • Go to VCS > Import from Version Control > GitHub and clone the start project.
    • Set up the deployment config for the directory you just created, eg /home /me/project1. Click Apply!
    • Go to the interpreter settings and configure / choose the virtual environment you just created, eg /home/me/project1/env/bin/python.
    • Check that the Path mapping field is filled in under the interpreter and refers to the correct directory.
    • Now upload the whole thing from PyCharm to the Pi and verify. It should look like the picture above.

    Step 13: Create Users + Database and Assign Rights

    Because there are currently no SQL users, you have to start the client once as root sudo mariadb.

    • sudo mariadb
    • sudo mariadb < sql/wardrobe.sql

    NOTE: If you want the model of the normalized database you can look above I included the file.

    Step 14: Connection Via Pycharm

    • Click on the Database tab on the right side (no tab? Menu View > Tool Windows > Database) and click on the green + to add a connection.
    • Choose Data Source > MySQL and click (if available) on the Download driver link below.
    • First go to the SSH / SSL tab and check SSH. Complete with the data (host / user / password) that you use normally for PuTTY. If port has not yet been entered you have to put 22. Check Remember password.
    • Return to General tab and complete the data for the database:
      • Host remains localhost (because connected via SSH) .
      • Database is wardrobe in this example. Use the project1-admin credentials and click Test Connection.
    • If the connection is OK, go to tab Schemas and make sure that only wardrobe is checked. You may have to refresh first.
    • Finally, change Name to something more logical, eg project1 @ rpi-ssh and click OK.

    Step 15: Configuration Files

    In the directory conf you will find 4 files that you first need to adjust and then put in the right place (do this via pycharm). You have to change the username and corresponding home directory everywhere in all 4 files.


    • The parameter module refers to the Flask application. Before the : state the file name, behind it the name of the object. In the example you will find in the line app = Flask (), so that will be module = web: app.
    • Virtualenv hopefully speaks for itself.
    • The rest should be right and the file can stay where it is.

    The two .service files are unit files for systemd. In addition to the Description, you have to adjust the 4 parameters under [Service] to your situation. Note that you use the correct Python interpreter (in virtualenv) and always absolute paths (starting from /).

    Note: Remember to upload these changes to the Pi before you continue.

    Copy everything to the right place

    • cd project1
    • sudo cp/conf/project1-flask.service /etc/systemd/system
    • sudo cp/conf/project1-sensor.service /etc/systemd/system
    • sudo systemctl daemon-reload
    • sudo systemctl start project1-flask.service
    • sudo systemctl start project1-sensor.service
    • sudo systemctl status project1-flask.service
    • sudo systemctl statusproject1-sensor.service

    Picture above of what the output should look like.


    • sudo cp conf/nginx /etc/nginx/sites-available/project1
    • sudo rm /etc/nginx/sites-enabled/default
    • sudo ln -s /etc/nginx/sites-available/project1 /etc/nginx/sites-enabled/project1
    • sudo systemctl restart nginx.service
    • sudo systemctl status nginx.service
    • wget -qO - localhost

    If everything is right you should get back html.


    MariaDB and nginx start automatically, your own services are not (yet).

    • sudo systemctl enable project1-flask.service
    • sudo systemctl enable project1-sensor.service

    Step 16: Fritzing Scheme

    Connect the wires as shown on the image. Or solder the components on a PCB.

    LCD screen:

    The 2*16 LCD that shows us the ip adres of the web server. Or it shows if an rfid tag goes in or out the system.

    • VSS -> GND
    • VDD -> 5V
    • V0 -> Potentiometer
    • RS -> GPIO 22
    • RW -> GND
    • E -> GPIO 27
    • D4 -> GPIO 5
    • D5 -> GPIO 6
    • D6 -> GPIO 13
    • D7 -> GPIO 19
    • A -> 5V
    • K -> GND


    RFID reader for in and outchecken of clothing.

    • SDA -> GPIO 8
    • SCK -> GPIO 11
    • MOSI -> GPIO 10
    • MISO -> GPIO 9
    • IRQ -> GPIO 24
    • GND -> GND
    • RST -> GPIO 25
    • 3.3V -> 3V3

    Passive buzzer:

    Makes a sound when an RFID tag is detected.

    • + -> GPIO 21
    • - -> GND

    Step 17: 3d Print the Case

    We are almost there. The next step is to print our case for the project. I included the files of the model that I used to print my case. To fill up the N from NMCT I use a piece of paper with some glue.

    Step 18: Mount Everything Together

    Take your screwdriver en mount those parts together with screws and bolts. Follow the order as described below.

    1. Screen with front of case.
    2. Rfid reader with front of case.
    3. Raspberry Pi with screen (don't forget to put the power cable in the Pi with the power off).
    4. Front of case with back.

    Now to mount it to your closet you can chose if you want to use screws or velcro. Here I used velcro.

    Step 19: Complete!

    Now that you followed all these steps your prototype should be up and running. Just put the power on, wait till the ip adres is on the lcd screen and surf to the site. Below there is a short demo.

    I learned a lot during the 3 weeks that I had for making this project. This would not have been possible without some people. A special thank you to the teachers who helped me with my questions. And also to Siemen Wauters for the 3D printed housing.

    #NMCT #Howest