7/22/19 – Sensing Distance using a Magnetic Hall Sensor

Today I worked on integrating the Hall Sensor, a sensor that senses a magnetic field, into my glove prototype.

The hall sensor works by detecting a magnetic field at all times and outputs the corresponding voltage. When there is no disruption to the magnetic field at all, the sensor outputs a number around 500 out of 1023 onto the serial monitor. Depending on the distance and which side of a magnet you bring closer to the sensor, it will change the voltage to go all the way up to 1023 when one side is completely touching or down to 0 when the other side is completely touching. So, I decided I would use this sensor to sense the distance the finger (magnet) is away from touching the sensor, and this will eventually determine the speed of the movement of the car.

First, I just set up a simple circuit with the magnetic sensor. My simple circuit (This picture is after I fried the first sensor). The sensor has 3 pins, where the left is 5V, middle is GND, and right is the sensing. I hooked up the right pin to analog pin 2 and performed the analogRead() function so I could see the value the sensor was reading on the serial monitor/plotter. I accidentally fried one of the magnetic sensors I used, though, so I had to replace it. The circuit itself worked well and was pretty accurate in its reading. I also added in an averaging function to have clearer readings. Averaging and reading Graph

Then, I wanted to mount the sensor and Arduino UNO to my glove to try using it in a real prototype. I first took measurements with a caliper of the Arduino UNO’s dimensions and used the MakerCase website to generate a box file to hold the Arduino UNO that I could cut on the laser cutter. Screenshot of template You can download my box template here. I used hot glue to keep the edges together, and I had to cut out a small hole for the downloading cable. The box came together well, though, and held the UNO securely! Box

I also soldered the sensor to a protoboard for easier mounting and connecting of wires. protoboard The protoboard was too long, so I used a hacksaw to cut off the excess length. Sawing I also soldered on the wires so the sensor protoboard could connect directly to the UNO, but I accidentally mixed up the colors of 5V and the signal wires.

I first tried to mount my sensor, magnet, and UNO box to a plastic vinyl glove using hot glue. First attempt However, the glue just didn’t stick to the glove well, so my components fell off. I also burned my hand. :( Fail

So, after going through the different materials cabinets, I decided to use the black webbing in the sewing cabinet to mount my UNO box and protoboard onto. Webbing, needle, hook eye The hot glue stuck to the webbing well, and it was actually pretty sturdy. I also glued the wires down partially to the webbing so they stayed untangled. Wires To finish off the webbing, I used a match to go over the raw edges to keep them from fraying. Matches The completed band: Band

For the magnet, on the other hand, when I first tried gluing it to the vinyl it fell off immediately, and I was worried that if I only put it in glue it would fall off again. Also, the webbing was too large to comfortably wear it around my finger. So, I used a red expandable tubing that I found in the sewing closet, and it held the magnet inside the tubing nicely while leaving the signal unobstructed. New tubing I was able to glue the tubing together to make a ring and keep the magnet in its position. Final ring I also used a needle and thread to sew in some hook and eye closures to keep the band that holds the UNO and the sensor together around my hand. Hook and eye

I actually like this version of the glove a lot better, and I think I’ll be sticking with this idea of multiple bands or rings rather than a solid glove. However, the UNO is really bulky, so I might just switch to an Arduino Nano or ProMini for my final version. I also want a way to keep the ring attached to the band, but I’ll find that later. I think the physical part of the prototype was pretty successful! Top view Palm view

As for calibrating the sensors, when my hand is flat (the control situation) the magnetic sensor takes a reading of around 500. Normal reading When my finger is bent and the magnet is around a centimeter to half a centimeter, it gives readings between approximately 200 and 400. Bent When my finger is fully touching the sensor, it gives a reading of 1. Touching I can use these readings to accurately judge the speed I’ll output on the car.

You can download my code here.