Because of my phone, I often struggle “locking in” or focusing on my schoolwork. I’ve tried implementing app time limits but they are too easily overridden, so I wanted to create a physical barrier between myself and my phone that can only be lifted if both I AND a friend deem I’ve earned it.
HardwareAll components that I used in this project use the PocketBeagle as the microcontroller. Below is the pinout diagram for the PocketBeagle for reference.
The RC522 module uses 3.3V, so I connected the PocketBeagle pins P2_21 and P2_23 to the rails on one side of my breadboard. I used these rails to power both of my RC522 modules. For reader #1, I connected the SDA pin to P1_06, SCK pin to P1_08, MOSI and MISO pins to the corresponding pins on the SPI0 bus on the PocketBeagle, and the RST pin to P1_4.
Similarly, For reader #2, I connected the SDA pin to P2_31, SCK pin to P2_29, MOSI and MISO pins to the corresponding pins on the SPI1 bus on the PocketBeagle, and the RST pin to P2_33.
After making these connections, it is important to run these commands in your PocketBeagle terminal:
sudo config-pin P1_04 gpio
sudo config-pin P1_06 spi_cs
sudo config-pin P1_08 spi_sclk
sudo config-pin P1_10 spi
sudo config-pin P1_12 spi
sudo config-pin P2_33 gpio
sudo config-pin P2_27 spi
sudo config-pin P2_25 spi
sudo config-pin P2_29 spi_sclk
sudo config-pin P2_31 spi_csThis sets the pins to the correct pin modes!
The second RC522 module is actually on in the photo above! The reason you don't see a bright red LED is because it was missing out of the package.
2. LCD Display / PotentiometerThe LCD display uses 5V, so I connected the PocketBeagle pins P1_22 and P1_24 to the rails on the other side of my breadboard. I connected the GND pin to ground, VDD pin to 5V, V0 to the middle pin of a potentiometer, RS to P2_34, RW to ground, E to P2_32, D0-D-3 were left unconnected, D4 to P2_30, D5 to P2_28, D6 to P2_24, D7 to P2_22, and BLA/BLK to 5V/ground (not pictured below, but pictured later in this post).
As for the left and right pins of the potentiometer, they were connected to 5V and ground.
After wiring these connections, I ran these commands in the terminal:
sudo config-pin P2_34 gpio
sudo config-pin P2_32 gpio
sudo config-pin P2_30 gpio
sudo config-pin P2_28 gpio
sudo config-pin P2_24 gpio
sudo config-pin P2_22 gpio3. Servo MotorThe servo motor, like the LCD display, needs 5V, so I hooked up the power and ground wires to the same rails as the LCD display. I then connected the middle yellow pin to P1_36 on the PocketBeagle and set the pin mode to pwm.
sudo config-pin P1_36 pwmNext, I set up a pull-down resistor and a push button. I connected a GPIO pin from the PocketBeagle (P1_35) to one side of the button, and I connected the other side of the button to 3.3V (same rail that the RC522 modules use). I then connected a 1k resistor between the input pin and ground. Finally, I set the mode mode for P1_35 to gpio.
config-pin P1_35 gpioWithout a casing that actually locks my phone away, this is all useless. So, I used SOLIDWORKS to design a pretty simple phone jail. There are two parts: the phone sleeve and the base (I've attached the files for both parts to this post).
Here are some pictures of the base of the casing:
Definitely some room for improvement here: designing an actual slot for the servo motor locking mechanism to sit on instead of a stack of LEGOs and superglue, more compact slots for both the LCD display as well as the RFID scanners instead of the huge windows.
Here are some pictures of the phone sleeve:
Overall, I am pretty happy with how the phone sleeve came out. However, as it is currently designed, when you place the phone sleeve on top of the base, a portion of the slit you slide your phone into is still exposed, but it is not large enough for you to actually be able to take your phone out.
Running The DeviceDownload all of the python files in the project_01/Accountability_Phone_Jail folder from the Github link attached. After doing so, all you need to do to run the phone jail is
sudo python3 main.pyHowever, I noticed that when I ran this command while powering the PocketBeagle using my laptop, the program would always crash during initialization. I found that hooking the PocketBeagle up to an external 5V power supply fixed this issue immediately.
This meant that I had to make all of the commands in this project run on boot (I used cron in this project)!
After setting all of this up, all you have to do is plug the PocketBeagle in, and the program should automatically start to run! After the program starts running, slide your phone into the phone sleeve (I have an iPhone 13; you may have to change the design based on what phone you are using), place the phone sleeve onto the base, and then scan both RFID cards to lock them into place. Here's a video of the device's locking/unlocking and button override functions:
I'd like to thank Erik Welsh, my EDES 301 professor, for his willingness, help, and expertise that made this project possible!













_3u05Tpwasz.png?auto=compress%2Cformat&w=40&h=40&fit=fillmax&bg=fff&dpr=2)
Comments