Introduction: Smart Backpack With Gps Tracking and Automatic Lights

About: student MCT at Howest (Kortrijk Belgium)

In this instructable we'll make a smart backpack that can track our position, speed and has automated lights that can keep us safe at night.

I use 2 sensors to detect if it's on your shoulders to make sure it doesn't go off when it doesn't have to, a pull detector(that i made myself) to see if the straps are pulled and an ultrasonic sensor that detects if something is close to it's backside. At least i also use an LDR to see if it's dark or light.

There are also leds inside that light up when you open the backpack to light the inside. It is triggered by the reed switch that switches with the magnetic field produced by the magnets.

The GPS module is used for tracking your position.

LCD module is used to display the ip address.

I made a site that you can upload to your raspberry pi that lets you see the routes you took, save them for later use, and control some settings.

This instructable is NOT for people with NO EXPERIENCE in working with Raspberry pi.

Supplies

  • Raspberry Pi 3 model B+
  • Raspberry PI T-cobbler
  • Wire (i used 10 meters you may use less)
  • Resistors6 x 220 Ohm, 1 x 10k Ohm, 1 x 1k Ohm
  • Trimmer 10k Ohm
  • Backpack
  • Powerbank
  • LDR
  • 4 Red leds and 2 white 5mm
  • Ultrasonic Sensor HC-SR04
  • Levelshifter
  • 10bit ADC MCP3008
  • GPS Module with antenna GY-NEO6Mv2
  • LCD display
  • A stretchable spring (that doesn't deform)
  • String
  • 1 Hex nut (or anything made from conductive metal with a hole)
  • Plastic pipe (around 4-3 cm in diameter)
  • A metal plate (that can cover the pipe ends)
  • Reed swtich
  • Small magnets
  • Thin MDF/other wood/plastic plate (around 5mm)
  • Hard foam plate (at least 2cm thick)
  • Velcro (for sealing the components to the case and the lid. You can use glue instead if you want to do it permanently)
  • 5 Press studs with a 5mm hole in the middle for a led, if it's less you can drill it trough later.

For testing on a breadbord:

  • Breadbord
  • Jump wires

Tools needed:

  • Soldering iron
  • Hot glue gun
  • Saw
  • Scissors
  • Knife
  • Needle and thread
  • Drill (If needed see step 10)


you can find the complete list of build of materials with prices in the attached file.

Step 1: Build the Circuit on the Breadboard

Connect everything like on the schematic above

There's also a pdf attached so you can enlarge the schematic.

Step 2: Build the Pull Detector

First take the spring en the string and glue/tie them to eachother.

Then take the nut and glue it just above the spring. (I used a small metal piece of pipe instead of the nut).

After that solder a wire to the underside of the nut(the side where the spring is).

Then glue the metal plate,spring and the wire to one side of the pipe. (make sure the wire has enough length inside for the spring to stretch to the other side of the pipe).

Afterwards glue the metal plate to the pipe on the other side like on the drawing, make sure the string comes out of the pipe so you can pull it.

Finally solder a wire to the plate that the nut hits when pulled.

At the end you can test it with a multimeter if the circuit is closed on the two wires when you pull the string.

Step 3: Connect the Pull Detector

Connect one end of the pull detector to pin GPIO 18 with a 1K Ohm resistor between.

Connect the other end to GND.

Step 4: Enable Serial and SPI in Raspi-config

  1. Open your Raspberry pi terminal and type in:
    sudo raspi-config
  2. Navigate with arrow keys to Interfacing Options, hit Enter
  3. Select Serial
  4. You'll get: "Would you like a login shell to be accessible over serial?"
    Hit No
  5. "Would you like the serial port hardware to be enabled?"
    Hit YES
  6. "Would you like to reboot now?"
    Hit "NO"
  7. Go again to Interfacing Options
  8. Select SPI
  9. "Would you like the SPI interface to be enabled?"
    Hit YES
  10. Reboot

Step 5: Database

First we'll install the database software we need.

Open your rpi terminal and type in:

> sudo apt-get update 
> sudo apt-get install mysql-server --fix-missing –y
> sudo reboot

Wait until your rpi reboots, then log in and type those lines

sudo mysql_secure_installation
Enter current password for root (enter for none): root
Change the root password? [Y/n] Y
New password: root123
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

We'll also make a user called 'mct' with password 'mct'.

sudo mysql -u root
MariaDB [(none)] > GRANT ALL PRIVILEGES ON<br>*.* TO 'mct'@'%' IDENTIFIED BY 'mct' WITH
GRANT OPTION;
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

We'll now import the database structure

You'll need to download the file attached and upload it to a user folder /home// on your rpi using FTP/SFTP.

Then type the following lines:

mysql -u root -p
mysql >CREATE DATABASE Smartpack;
Now exit the sql shell by pressing CTRL + D
> mysql -u mct -p Smartpack < /home/<user_name>/data-dump.sql
> sudo reboot

After your rpi is rebooted the database should be up and running

Step 6: Testing

First we'll need to install apache webserver

Type in the following code into terminal:

sudo apt-get install apache2 -y

sudo reboot

Now copy alle the files from the FRONT directory via the github repository into the /var/www/html/ directory on your rpi.

Then copy all the files from BACK directory via Github repository into a local user folder on your rpi /home//smartpack

If you used different pins than in the schematic, you'll need to edit them in /home//smartpack/main.py, they are listed above in the document.

Now open terminal and run the script

python3.5 /home/username/smartpack/main.py

You can surf to the ip that will be displayed on the lcd screen to access the website we just installed.

Make sure everything is working correctly before going to the next step!

Step 7: Build a Housing for the Electronics

We'll make a case for our rpi, powerbank and some electronic components.

I encourage you to make your own versions of the case since I'm not very good at making those things.

  1. Cut your plastic/wooden plate into 2 pieces measuring 29 cm x 15,5 cm (Make sure the longest side fits into your backpack)
  2. Cut 2 pieces of hard foam measuring 29 cm x 3 cm and 2 more pieces measuring 9.5 cm x 3cm
  3. Glue the pieces to the edges of a plate.
  4. After it's done cut the holes like on the photo's : You'll need to measure yourself how wide the holes need to be. The hole on the bottom is for Ultrasonic sensor, and the top big one is for cables.

Step 8: Solder Everything With Wires Instead of Jump Cables

Solder everything with normal wires except both white and red leds, LDR and reed switch.

You can use the breadboard for some things like IC's, but i personally don't recommend it.

The GPS and LCD modules need to go into the holes we cut for them in the previous step.

Make sure to use isolation everywhere since a short circuit could break your Rpi.

Step 9: Burn Holes for Leds and Ultrasonic Sensor

Burn? Yes! BURN!

We'll be using a soldering iron to burn our holes. This because most backpack are water-resistant, that means that the material they're made of is either plastic or rubber. So if we burn it instead of cutting, the edges of our hole will nicely melt and with that it'll be less tear-prone.

Burn 4 small holes wherever you want for the automatic red leds. Make sure they're in a visible position. (There are already press studs in the holes on the photo above)

Also burn a hole for the ultrasonic sensor at the bottom of the backpack, on the side where out back goes and a small hole next to it for the string that comes out of the

Finally burn a hole for the cables that will go to the main section of your backpack, do it just above the hole we made for cables in the housing if you'd put it in the bag.

Step 10: Put Press Studs Through the Holes and Glue Leds

Make sure the holes in the studs are 5mm!! if not you can try and drill trough them with a 5mm drill.

Push the press studs trough the 4 holes you've burned and click them together.

Put the 4 leds in the press studs and glue them, make sure the metal parts are not touching the studs.

Step 11: Reed Switch

Reed switches are very fragile, so I've put mine in a plastic tube and that plastic tube again in a metal tube, and then I sealed everything with glue.

How you do it is up to you, but I recommend to make something for it so it doesn't break.

If that's done glue everything to the top of the main section of the backpack. Next to it, on the other side of the zipper glue a strong enough magnet so it'll switch when you open it.
I've put mine between the inside and outside layer of the textile so it isn't visible.

Step 12: Glue the White Leds Inside the Bag

Glue them so they'll light up the inside when on.

You can choose where to put them, but in my opinion the best place is at the top text to the reed switch.

Step 13: Glue the Housing and Put Inside the Bag

Before you glue it shut make sure it is still working correctly.

Then glue the lid onto the rest of the housing, look out for cables that will get between the plate and the side of the housing, it is very tricky to glue it without the cables being between it.

Afterwards put it inside your backpack, make sure the ultrasonic sensor is facing the hole we made earlier.

You'd probably need to secure the housing around the ultrasonic sensor to the backpack so it won't cover it.

Step 14: Edit Rc.local to Run the Script on Startup

Open the terminal and type in:

> sudo nano /etc/rc.local

add the following line at the end, just above exit 0

python3.5 /home/<username>/Smartpack/main.py &

press CTRL + X and 2x Enter

Now the script will start on boot.

Step 15: Finishing Touches

You can sew all the cables together and also to the backpack with a needle and thread.

You can also make a cover for the red leds from a piece of leather/textile.

Sensors Contest

Participated in the
Sensors Contest