Intro: How to Make a Smart Suitcase With a Raspberry Pi
In this tutorial, I'm going to explain how you can make a smart suitcase with a Raspberry Pi.
When you're finished, you will be able to track your suitcase worldwide and weigh it without the need of a scale.
Let's get started!
Step 1: Components You Need
- Raspberry Pi (ofcourse xd)
- Jumper cables
- A suitcase
- A powerbank to power your Pi
- Adafruit Ultimate GPS breakout + Antenna
- HX711 load cell amplifier
- Load sensor combinator
- Four 50kg load cells
- Two (wooden) boards that don't bend too easily (e.g. plywood). Make sure that the boards have the same dimension and that they fit in your suitcase.
- LCD-display (optional, I will use it to display the IP of my Raspberry Pi so that the user can know to which website he has to go to see the info of the suitcase)
Step 2: Assembling Your Suitcase
On the picture you can see how you have to connect all the different parts. If you have problems, follow these steps:
To connect your GPS:
- VIN -> Raspberry Pi pin 1 (3.3V)
- GND -> Raspberry Pi pin 6 (GND)
- TX -> Raspberry Pi pin 10 (RXD)
- RX -> Raspberry Pi pin 8 (TXD)
To connect your LCD-display: (didn't draw it on the Fritzing scheme because it would get messy..)
- VSS -> Raspberry Pi pin 6 (GND)
- VDD -> Raspberry Pi pin 2 (5V)
- V0 -> potentiometer (this takes care of the contrast adjust)
- RS -> Raspberry Pi pin 18 (GPIO24)
- RW -> Raspberry Pi pin 6 (GND)
- E -> Raspberry Pi pin 32 (GPIO25)
- D0 -> Raspberry Pi pin 42 (GPIO12)
- D1 -> Raspberry Pi pin 46 (GPIO16)
- D2 -> Raspberry Pi pin 48 (GPIO20)
- D3 -> Raspberry Pi pin 50 (GPIO21)
- D4 -> Raspberry Pi pin 11 (GPIO17)
- D5 -> Raspberry Pi pin 13 (GPIO27)
- D6 -> Raspberry Pi pin 15 (GPIO22)
- D7 -> Raspberry Pi pin 33 (GPIO13)
- A -> Raspberry Pi pin 2 (5V)
- K -> Raspberry Pi pin 6 (GND)
To connect your load cells:
- In the middle of the combinator board, you can see that there are four columns with each three connections (-, + and C). One load cell has exactly three wires (wite, red and black). Connect each load sensor to a column as follows:
- - -> Black
- + -> White
- C -> Red
- Red -> E+
- Black -> E-
- Green -> A-
- White -> A
- VCC -> Raspberry Pi pin 17 (3.3V)
- GND -> Raspberry Pi pin 9 (GND)
- DT -> Raspberry Pi pin 29 (GPIO5)
- SCK -> Raspberry Pi pin 31 (GPIO6)
(B- and B+ on the HX711 and Yellow on the combinator board remain empty)
To attach your load cells to your boards:
- First, make sure that the load cells are placed evenly on the board.
- Then, for each load cell, make a small, rectangular hole so that the "lid" of the load cell doesn't touch the ground. If it did, you would get negative values.
- Put the load cells on their right place and attach them to the board with screws.
- Next, attach the combinator board to the top of the board so that the pins are "outside" the surface of the board.
Secure the wires from the load cells with some tape to the board.
After that, make little cubes with some wood and attach them to the middle bar of each load cell with some glue. The weight will be measured by the folding of that middle bar.
Finally, attach the second board to the little cubes with some glue.
Step 3: Putting the Components in Your Suitcase
So once you've connected everything, it's time to put everyting in your suitcase.
The one thing that has to be in the same place no matter what is the weighing scale, so make sure you connect them very well to the bottom of the suitcase with some strong glue or screws.
To get a better GPS-signal, I made a little hole in my suitcase so that the top of the antenna can be attached to the outside of the suitcase.
To put the LCD-display in your suitcase, if you want, you make a rectangular hole that has the same size as the LCD-screen. Then attach the LCD-screen with some strong glue.
You can place the other parts, like the Raspberry Pi and the powerbank, to the bottom or the sides of the suitcase with some glue. You can do it like you want to.
So in summary, just make sure that all the components are connected well to the suitcase so that nothing can get out of place.
Step 4: Setting Up Your Raspberry Pi
To start things off, we have to do some setup first, so just typ the following commands:
- First install some packages:
sudo apt update
sudo apt install -y python3-venv python3-pip python3-mysqldb mariadb-server uwsgi nginx uwsgi-plugin-python3
- Then create a virtual
python3 -m pip install --upgrade pip setuptools wheel virtualenv
mkdir project1 && cd project1
python3 -m venv --system-site-packages env
python -m pip install mysql-connector-python argon2-cffi Flask Flask-HTTPAuth Flask-MySQL mysql-connector-python passlib
- Next, clone this project into e.g. PyCharm (the project has 4 folders)
- Make sure that the project interpreter is python on your Raspberry Pi
- To configure the database:
sudo mariadb < sql/db_init.sql
- Make connection with your database in PyCharm
- Finally, right click on the file 'lugapp.sql' in the folder 'sql' and choose 'run'. This wil put the tables into the database on you Pi.
Next, the only thing you have to modify, is in the config files in the folder "CONF". Read every file in this folder and make changes where necessary. (e.g. working path, user...).
The final steps:
- Copy the files "project1-flask.service" and "project1-lcd.service" to /etc/systemd/system by using the following command:
sudo cp conf/project1-*.service /etc/systemd/system/
- Then, reload:
sudo systemctl daemon-reload
- Finally, start the two services:
sudo systemctl enable project1-*
sudo systemctl start project1-*