Move More With Motivation Lock
by Wiebe Cloet in Circuits > Sensors
202 Views, 0 Favorites, 0 Comments
Move More With Motivation Lock
What is a Motivation Lock? I can hear you asking. Well, allow me to explain.
Do you remember when you were little and if you behaved well you got a cookie or a snack? Motivation Lock works in the same way.
The concept is simple. All you have to do is put an item in the box that will drive your motivation. It can be anything, for example, you tell yourself that if you burn 300 calories today you can eat a bag of crisps. So you put the bag of crisps in the box after that you just fill in the required details into the site and be on your way. Once you enter the necessary details the box locks and will only unlock if you either reach the calorie goal that you set or if you press the reset button. So let's take look at how to put it together.
My motivation to build this project came from the fact that I am a student in college now and I am gaining weight fast. When we had to make a prototype for Project One, a module in MCT, I knew that this was the chance to make a prototype that could me get motivated to work out more.
Downloads
Supplies
First of all sorry for the weird PDF format my Adobe Acrobat didn't want to convert my Excel sheet. If you look in the file above you can check the bill of materials this contains links to where I bought my components as well as the total price if you would buy everything that you need to make this. The total price is around €302
The supplies you will need to build this are:
- RaspberryPi 4B - 4Gb
- ESP 32
- MPU6050
- Heart pulse sensor
- DS18B20 TO92 temperature sensor
- Programmable led strip
- Male-Male cables
- Raspberry Pi T-cobbler
- Resistors
- Arm belt for sporting
- Storage box
- Parallax Continuous Rotation Servo (A regular 180-degree servo would be better programming-wise)
- Bolts and nuts
- Arduino
- Little wooden beams (30x30x450mm)
- Wooden plank
- Capacitor (uf10)
- Limit switches x2 (Optional! not a requirement if you have a 180-degree servo)
- A lock
- A power supply
Tools that you need:
- Saw
- Screwdriver
- Multitool that can cut plastic
- Box cutter
- Velcro
- Soldering iron and tin
Setting Up the Database
If we want to device the work properly we will need to set up a database in MySQL. In the image above you can see how I set up mine. We basically want to store important parts of our data, like our temperature, if we are still moving or not and we also want to save our heart rate in beats per minute to the database. This is what we will use in our backend to calculate how many calories we've burned.
Connecting All the Electroniics
In the PDF files above you can see how I wired the electronics. Both setups from the ES32 as well as the Raspberry Pi will go in the false bottom of the box.
Some of the parts connected to the Arduino Uno will need some soldering. For example, I soldered some cable to the DS1820 sensor with a 4.7k Ohm resistor between the voltage cable and the data cable, afterwards I used some tape to make sure everything was isolated well enough. If you are not sure how to solder it be sure to take a look at the PDF called "FritzingSchema".
Just wire everything as shown in the PDF if you can program your Arduino with Bluetooth or another wireless protocol be sure to do so then you won't need to keep it connected to the box as I've done with this prototype then you can actually move around while wearing it.
The Code Behind It All
The main code in the backend that runs on our Raspberry Pi consists of 5 Threads
- We have the sensors thread that requests the sensor data and logs the values into our database.
- We have a data sensor that sends our data to the frontend, our site in other words and provides our LED function with the right values to calculate what colour to display on the LED strip
- Also among these threads is an LCD thread this one displays our WLAN IP.
- Next up is the servo thread this thread checks when it needs to lock.
- Lastly, we have the main thread which will start the other threads when the website sends the start signal.
The code on our Arduino collects the sensor data and when asked will send it to the Raspberry Pi.
Our ESP32 will receive commands from the Raspberry Pi and will change the colour of the LED strip accordingly.
You can get the code for the frontend and the backend, which includes the data repository here
Making the False Floor
In the first picture, you can see that I used an indication tool on how to cut my wooden beams that would become the support beam of my hidden floor. We need to make two of those as you can see in the second picture I am using an old piece of plywood that my parents kept aside when they redid their room. If you don't have the luxury of having a perfectly fitting piece just saw some wood to the right measurements.
Be sure to leave enough room for all the components to fit in. After placing a beam in place I went ahead and drilled it in. These beams are each held together with 2 bolts. The final step for the part is to lay the false bottom on top of the 2 supporting beams. You can see an example of this in the fifth picture
Making the Lock
So for our next step you need a few things. First of you need to mount a bolt between two pieces of metal on top of the slider of the slot. You can refer to the first picture for this step. I secured the bolt on top of the slider by pinching it between 2 metal plates and screwing them together. You could also try welding them together.
After that, I made a place where the slot would slide into and lock the box. To attach it to the box I bolted that and the slot to our box. An example of how it is possible is shown in the third picture.
Next, I connected a long bolt to the continuous servo. Be using silicon to attach it to a piece of plastic which I later screwed on top of the servo. You can see this in the fourth picture.
The last part of this step is to add our limit switch on the places where our servo needs to stop. We place one where it needs to stop when it is in the closing position which is the left side, in this case, and one where it needs to stop when it is open which is the right side. We bolt those to the box as well.
NOTE: if you have a 180-degree Servo that you don't need to overcomplicate the slot as much as I did
Making the Pouch for Our Arduino
This next step is really simple just make your Arduino fit in your sporting arm belt. In the first two pictures, you can see that I cut away the fabric between the inner pouch and the out pouch. This made it easier to get the wires through.
Afterwards, I put a bit of velcro inside the pouch and I also put a bit on my MPU6050. This is to stop it from moving unless I move.
Lastly, we need to connect the wires to the Arduino inside the pouch. Like visible in the 5th picture. We will strap the pulse sensor and the temperature sensor to our hand using a wrist support band you can also put them in a glove or something just to make sure they touch you. An example of the full thing can be seen in the fifth picture.
Cutting Holes Where Necessary
To power our raspberry pi and to show our IP to be able to connect to the site we need to cut some holes inside the box. I made mine at both ends of the box, I did this by using the multitool with a special tip made to saw through plastic easily.
I screw the display to the inside of the box using screws in the right upper corner and left upper corner. This way I only need 2 screws.
Putting Everything Together
So after everything is made and attached to the box it is time to put the electronics inside. The final result should look something like the first picture.
To attach the LED strip to the box I just stuck some velcro on the box and on the LED strip. Normally these come with adhesive tape on the backside, but I found that they weren't sticky enough.