Move More With Motivation Lock

by Wiebe Cloet in Circuits > Sensors

202 Views, 0 Favorites, 0 Comments

Move More With Motivation Lock

DSC_1276.JPG
199768341_1095853044588113_7166470016667709000_n.jpg

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.

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:

Tools that you need:

  • Saw
  • Screwdriver
  • Multitool that can cut plastic
  • Box cutter
  • Velcro
  • Soldering iron and tin

Setting Up the Database

ProjectOneDb.png

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

TempSoldered.jpg

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

Code example.png

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

GitHub

Making the False Floor

132037248_181867863768183_2338484941678545276_n.jpg
200940603_3827668657342823_7712391024473882297_n.jpg
Fasl bottom.png
198490491_178742567590981_5503229974610765261_n.jpg
201173425_949447622510031_9214212406949511879_n.jpg

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

200982127_304974741170110_7792702271266053894_n.jpg
200235846_1358492644560840_7865104526212876856_n.jpg
201214023_871861417013018_7032806501246643269_n.jpg
200953758_391326252213988_5581198684807715284_n.jpg
201464815_1233261333756721_3276327300428178919_n.jpg
201533731_920348162139779_6939509529769264782_n.jpg

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

200075272_346399500203855_2011635037520392438_n.jpg
201091207_3019879574959198_2034868073640914311_n.jpg
198835351_153260416841709_2987947544468792575_n (1).jpg
199487235_285843523065965_4929648197170500120_n.jpg
200493895_1719383371581523_1499398161453348075_n.jpg
199819234_294649695723911_3312539184408687255_n.jpg

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

201241162_487859562310905_960269434031339330_n.jpg
199313083_669469317784893_2171254117397771068_n.jpg
199559897_1747432262107620_3671195979728369946_n.jpg

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

199756202_341755967365699_7220199092228544844_n.jpg
199649483_558188441849481_2272007035776246740_n.jpg
200319692_535441744127821_1796157079114152350_n.jpg
199779523_214398727174547_4211084437501689848_n.jpg

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.

The Final Product

199709815_562416038059320_3101345408308877827_n.jpg