Study Buddy: a Raspberry Pi-powered Phone Detector Using Computer Vision to Help You Stay Focused. Made by Students for Students.

by fsarreal in Circuits > Raspberry Pi

146 Views, 3 Favorites, 0 Comments

Study Buddy: a Raspberry Pi-powered Phone Detector Using Computer Vision to Help You Stay Focused. Made by Students for Students.

IMG_6084.JPG
IMG_6085.JPG
IMG_6087.JPG
IMG_6088.JPG
glassesexpanded.gif
felixwglasses.jpg
glassescharging.jpg
glassesfinal.jpg
Study Buddy Example

Hi, we are a group of three students who all struggle with paying attention sometimes. Staying focused in class or on your homework is tougher than ever. Our phone’s notifications coming from social media apps sending countless notifications and the temptation of doomscrolling can pull our attention away in an instant. That’s why we built Study Buddy, a pair of sleek, blue-light protective glasses with a camera node and an alert system. A Raspberry Pi Zero 2 W (the camera module) streams live video using Flask to a separate Raspberry Pi 5, where an OpenCV + YOLOv8 model spots your phone in the frame. When it detects your device, the glasses’ LED quietly lights up, calmly reminding you to put it away. The goal is to reduce screen related distractions and encourage more mindful work habits. These glasses offer a simple, wearable solution to promote awareness and improve self-regulation without invasive software or parental controls. In addition we tried to design the glasses to look and feel light and minimalistic. Built using basic object recognition tools and microcontroller technology, this device makes screen management more personal and more effective.

Designed, Rendered, and Animated in Autodesk Fusion 360

Supplies

Disclaimer: Since each builds’ glasses might be a different size, length measurements for wires are not included in this Instructable, these should be cut according to the length that fits whatever glasses you use.

Electronics

  1. Raspberry Pi Zero 2 W: https://a.co/d/8XnRloR
  2. Raspberry Pi 5: https://a.co/d/9KH4Tcm
  3. USB C Cable: https://a.co/d/f5ewjWL
  4. LiPo battery (3.7 V, 1000 mAh): https://a.co/d/abgjmQk
  5. Boost converter (5V and 1A output): https://a.co/d/emc4J2E
  6. Pi Camera Module: https://a.co/d/c33C8zr
  7. Mini Slide Switch: https://a.co/d/4z6IO6M
  8. Jumper wires (male-female): https://a.co/d/4PPuU7k
  9. Lithium Battery Charger Module: https://a.co/d/3GjFjfV
  10. MicroSD Card with Raspberry Pi OS 32bit WiFi and SSH enabled: https://a.co/d/5KWGqUz
  11. MicroSD Card with Raspberry Pi OS 64bit and WiFi enabled: https://a.co/d/5KWGqUz
  12. MicroSD Card Reader: https://a.co/d/7twZeBe
  13. 100 Ohm Resistor: https://a.co/d/eCkwyaW
  14. 5mm Red LED: https://a.co/d/cFa7TNZ
  15. 100 Ohm Resistor: https://a.co/d/eCkwyaW
  16. 5mm Red LED: https://a.co/d/cFa7TNZ

Tools

  1. Soldering iron kit
  2. 3D printer
  3. Wire Stripper
  4. 1.5mm Allen Key

Other

  1. Socket-head screws (6 M2.5x12mm and 2 M2.5x4mm): https://a.co/d/dhuzbsP
  2. Superglue: https://a.co/d/j2BzeJg
  3. Any eyeglasses frame (preferably blue-light protective): https://a.co/d/7VYTtft
  4. 3D-printed housings (left & right): export STL from Fusion 360 (see upcoming steps)

Download and 3D Print the Housing

Screenshot 2025-05-27 at 11.42.52 PM.png
  1. Download the STL files from this link
  2. https://github.com/FelixJSarreal/StudyBuddy/tree/main
  3. Print all the parts
  4. Resolution: 0.2mm layer height
  5. Material: ABS
  6. Infill: 20%
  7. It should be 10 pieces in total. Make sure to print 4 copies of the Left Spacer and 2 copies of the Right Spacer and try to lay them upwards on the print bed for a clean print

Configure Pi Zero 2 W

IMG_6094.jpg
IMG_6095.jpg
  1. Download and flash the OS onto MicroSD Card using MicroSD Card Reader using RaspBerry Pi Imager (https://www.raspberrypi.com/software/)
  2. Make sure to Set Up Wi-Fi in the advanced settings
  3. Add your network SSID and password so it joins your LAN on boot.
  4. This allows you to connect to the pi without a mouse and keyboard and allows the two pi’s to talk to each other
  5. SSH into the pi using the hostname and password you created when flashing the OS and run the following commands to update, upgrade, and automatically reboot your pi:
  6. sudo apt update && sudo apt full-upgrade -y
  7. sudo reboot
  8. (This will update and upgrade your pi and automatically reboot it)
  9. Find the IP address of the Pi Zero by running this into the terminal and writing down the first batch of numbers:
  10. Hostname -I
  11. Install python and the camera module support
  12. sudo apt install -y python3-flask python3-picamera2 libcamera-apps python3-opencv
  13. Download the two code files by running this into the terminal:
  14. wget https://raw.githubusercontent.com/FelixJSarreal/StudyBuddy/main/led.py
  15. wget https://raw.githubusercontent.com/FelixJSarreal/StudyBuddy/main/camera.py
  16. Now your Pi Zero is ready to be installed. To run the programs later open the terminal in SSH and run the following:
  17. python3 led_server.py &
  18. python3 camera_stream.py &


Configure the Pi 5

IMG_6096.jpg

This should be simpler than setting up the Pi Zero

  1. Download and flash the OS onto MicroSD Card using MicroSD Card Reader using RaspBerry Pi Imager (https://www.raspberrypi.com/software/)
  2. Make sure to Set Up Wi-Fi in the advanced settings
  3. Add your network SSID and password so it joins your LAN on boot.
  4. This allows the two pi’s to talk to each other
  5. Connect your monitor, keyboard, and mouse to the pi and run the following commands to update, upgrade, and automatically reboot your pi:
  6. sudo apt update && sudo apt full-upgrade -y
  7. sudo reboot
  8. (This will update and upgrade your pi and automatically reboot it)
  9. To install python, opencv, and the dependencies for the YOLOv8 CV program run the following:
  10. sudo apt install python3-pip python3-opencv libopencv-dev libjpeg-dev libatlas-base-dev -y
  11. pip install --upgrade pip
  12. pip install numpy requests opencv-python ultralytics
  13. Create the code file:
  14. Wget https://raw.githubusercontent.com/FelixJSarreal/StudyBuddy/main/detectphone.py
  15. Edit this file with the IP address you wrote down earlier.
  16. Open gearny code editor from the desktop of the pi
  17. Open detectphone.py
  18. Look for the section where it says <IPAddressHere> and replace it with the IP Address you wrote down
  19. Save the file
  20. You’re all set! When you need to run the program just type into the terminal:
  21. Python3 detectglasses.py


Glue Side Panels to Glasses

IMG_6081.JPG
IMG_6082.JPG
IMG_6083.JPG
Screenshot 2025-05-27 at 11.29.48 PM.png

It’s time to start assembling the electronics housings! Take the two printed parts with large cut-out rectangles and place them on the glasses to measure their fit. The left side should have a small tab coming towards the eyes on the front side (for the camera). Place a light amount of superglue on the upper ridge of both sides (check image above for area to glue) and firmly press the 3d print into the glasses for around 2 minutes. Try to get them as square with the joints as possible.

Assemble the Sides

glassesexpanded.gif

Now lets get to assembling the sides. Watch this GIF to see how everything fits together.

On the left side, plug the camera into the Pi Zero camera port. Try to fit the Pi Zero as close to the holes as possible, and then screw the M2.5 bolt through the cover. Attach the 4 short spacers after the cover, then the pi zero, and finally the left side and the nut. Repeat for all 4 bolts. Make sure to fold the pi zero camera inside of the cover. Finally, superglue the camera as flat and square as possible on the small platform at the front of the glasses.

On the right side, glue the battery to the bottom right corner of the cover and glue the charging module to the middle of the battery. Attach the switch and the LED. Screw the two M2.5 bolts through the cover, spacer, and then the right side and attach 2 nuts.

Solder Electronics

glassesside.jpg
solder.jpg
  1. Prepare Tools and Wires
  2. Plug in the soldering iron and allow it to fully heat up. While waiting, use a wire stripper to strip the ends of all jumper wires that will be soldered into the modules or switch.
  3. Connect the Battery to the Battery Charger
  4. Connect the battery’s positive (+) wire to the B+ pad on the battery charger. Connect the battery’s negative (–) wire to the B– pad.
  5. Connect Battery Charger Output to Slide Switch
  6. Solder the OUT+ pad of the battery charger to one side of the slide switch. The OUT– pad will serve as the ground for the entire system.
  7. Connect the Slide Switch to the Boost Converter
  8. Solder the other side of the slide switch to the IN+ pad of the boost converter. Then solder the OUT– pad from the battery charger to the IN– pad on the boost converter.
  9. Connect Boost Converter Output to Raspberry Pi
  10. Solder the OUT+ pad on the boost converter to the Raspberry Pi’s 5V pin (GPIO Pin 2 or Pin 4). Solder the OUT– pad on the boost converter to any GND pin on the Pi (GPIO Pin 6 or Pin 9).
  11. Important: Before connecting to the Pi, use a multimeter to adjust the boost converter’s output to exactly 5.0–5.1V by carefully turning the small screw on the module.
  12. Connect the LED Indicator to GPIO 17
  13. Connect the cathode (shorter leg) of the LED to any GND pin on the Pi. Connect the anode (longer leg) to one end of a 220Ω resistor, and the other end of the resistor to GPIO 17 (Pin 11 on the Pi). This allows the Raspberry Pi to control the LED via code.
  14. Insulate and Check Continuity
  15. Cover every exposed solder joint with electrical tape, especially around the switch, to prevent short circuits. Use the multimeter in continuity mode to test all key connections. Ensure that grounds are shared across all modules and that there are no shorts between power and ground lines.
  16. Final Check
  17. Double-check that all wires are secure and insulated. Confirm the boost converter is outputting 5V. Flip the switch to ON — the Raspberry Pi should power up safely.

Become Distraction Free!

Study Buddy Example

Run both programs found at the end the configure steps on both Pis (try to run the zero ones first). Put on the glasses and start to study. If you're near the monitor connected to the Pi 5, you can see what the computer vision sees. If you take out your phone in front of the camera, it will start to draw a yellow box around the phone with a confidence score out of 1.00. If it sees a phone for a consecutive 5 frames it will turn on the LED until you put the phone away!