Introduction: COVID-19 Social Distance Meter
Hi, this is a project that I put together with the idea of creating a wearable battery-powered device that would easily show another person whether they were entering inside the current recommended social distance of 2 meters.
This is an Arduino based project that uses an ultrasonic distance sensor and then turns on either a green led if there is nothing sensed within 2 meters or a red led if something is detected within that range. This is a just for fun project and although the distance sensor is fairly accurate I'm afraid that soft people don't necessarily give as good a return signal as preferred when bouncing sound waves off them :)
Supplies
This is a list of the main components I used or similar items. You can find them easily on eBay or Amazon.
Some of the parts listed below are multi-packs and I've only actually used one or two items from it but I hope this gives you an idea of the items and where you can find them.
HC-SR04 Ultrasonic Distance RangeFinder
https://www.amazon.co.uk/HC-SR04-Ultrasonic-Distan...
Arduino Pro Mini ATMEGA328P 5v
https://www.ebay.co.uk/itm/Arduino-Pro-Mini-Improv...
DC-DC Voltage Booster Converter
https://www.amazon.co.uk/gp/product/B089Y7NDCR
5mm Coloured Leds
https://www.amazon.co.uk/Youmile-100-Pack-Round-Ye...
220 ohm Resistors
https://www.amazon.co.uk/220ohm-4W-Resistors-Pack-...
FTDI USB TTL Serial Adapter
https://www.amazon.co.uk/PIXNOR-FT232RL-Serial-Ada..
Lipo Battery 3.7v
https://www.ebay.co.uk/itm/4pc-450mAh-3-8V-80C-1S-...
I also used some dupont connectors and heatshrink to connect everything up
Step 1: Tools
- Soldering Iron
- Multimeter
- Bradawl (optional)
- 3D Printer
Step 2: HC-SR04 Ultrasonic Sensor
The Ultrasonic Sensor HC-SR04 is a sensor that can measure distance. It emits ultrasound at 40 000 Hz (40kHz) which travels through the air and if there is an object or obstacle on its path It will bounce back to the module. You can measure the travel time and knowing the speed of the sound you can calculate the distance.
The module is 5v which is why I chose the 5v version of the Arduino to make my life a little easier when creating the circuit.
Step 3: Arduino Pro Mini 5v ATMEGA328P
I chose this version of the Arduino as it runs on five volts and I can then easily give that to the ultrasonic sensor.
The version I ordered came with the connectors loose and I decided to solder the inputs to allow connection of an FTDI USB adapter.
This adapter allows you to connect and program the Arduino using a USB cable.
Step 4: DC-DC Voltage Booster
This little device allows you to convert one DC voltage to another. In this case, I need to supply the Arduino with a voltage between 5v & 12v to the RAW input. The Arduino itself will then regulate the power for itself and the 5v feed used for the ultrasound sensor.
I connected the inputs to a supply from a 3.7v Lipo battery and then with a multimeter on the outputs adjusted the little screw on the side until the voltage was reading around 7-9v.
Step 5: LED Indicators
LEDs were connected using a 220-ohm resistor this is fairly low but the idea being that they would be nice and bright. The long leg on an led is the one you connect the resistor to, it is called the anode and is the positive part of the circuit. The shorter leg is the cathode and is connected to the negative part of the circuit (ground).
Step 6: 3D Printing
I designed the case in Tinkercad which is free and super easy to use. I then downloaded the .stl files from there and imported those into Cura and using my Creality Ender 3 on the default standard settings printed the case and lid in one colour. The wording and characters I printed separately using a different colour.
The holes I designed in the lid for the lettering were a little tight so I used a bradawl to ensure that the parts pushed in easily also the ultrasound sensors can vary a bit so this can be snug.
The strap I scavenged from an identity tag and drilled a couple of holes in the side of the case and just pushed the clip through.
The front is a tight enough fit that just pushing the lid on should give you a good enough fit with the hole in the back of the case being an easy way to push the lid off.
Step 7: Circuit
The circuit is fairly simple and I hope the breadboard image gives you a good idea of how it goes together.
The main points are how the connections are made to the Arduino.
RAW - Positive supply 7-12v DC
2 - Activates red led
3 - Activates green led
5 - HC-SR04 Echo
6 - HC-SR04 Trigger
VCC - 5v+ for HC-SR04
I've used various grounds around the Arduino, use whichever suits you.
You can, of course, change the pins but these should match the code :)
The image shows a generic lipo battery and the DC-DC converter appears to have a labeling issue with two voltage in connections.
Step 8: Show Me the Code
The code was created in the Arduino ide and is available on github.
https://github.com/barneynicholls/covid_social_distance_meter
int LED_GREEN = 3; int LED_RED = 2; int TRIG_PIN = 6; int ECHO_PIN = 5; // the setup function runs once when you press reset or power the board void setup() { Serial.begin(9600); // initialize led pins as output. pinMode(LED_GREEN, OUTPUT); pinMode(LED_RED, OUTPUT); // initialize sensor pins pinMode(ECHO_PIN, INPUT); pinMode(TRIG_PIN, OUTPUT); } // the loop function runs over and over again forever void loop() { delay(300); // Clears the TRIG_PIN condition digitalWrite(TRIG_PIN, LOW); delayMicroseconds(2); // Sets the TRIG_PIN HIGH (ACTIVE) for 10 microseconds digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIG_PIN, LOW); // Reads the ECHO_PIN, returns the sound wave travel time in microseconds long duration = pulseIn(ECHO_PIN, HIGH); // Calculating the distance // Speed of sound wave divided by 2 (there and back) int distance = duration * 0.034 / 2; // Displays the distance on the Serial Monitor Serial.print(distance); Serial.println("cm"); // Set the led state based on the distance digitalWrite(LED_GREEN, distance >= 200 ? HIGH : LOW); digitalWrite(LED_RED, distance < 200 ? HIGH : LOW); }
Step 9: Things I Have Learnt
This is my first instructable and I've enjoyed putting it together. I must remember to take pictures of all the steps as I create things and detail the parts that didn't work as well as those that did.

Participated in the
Battery Powered Contest
3 People Made This Project!
- Zano64 made it!
- VincentJ2 made it!
- PeachPython2165 made it!
34 Comments
2 years ago
Hi, cool project! I'm trying to make this myself, and it works when I use an object and am only half a meter away, but when I step away further, it doesn't seem to recognize that there is standing someone/something. Is there a specific range on the distance sensor? I'm using a HC-SR04 with 4 pins
2 years ago
you should add a buzzer speaker, causewhen you are going to wear the device, you will not always watch the led to know it less the one in front of you is at the right distance, so a small buzzing beep is in my opinion a good add...
2 years ago
Very nice indeed. I would add a little switch, allowing to save the battery, when the device is not used. I can not imagine you are using this while you are sleeping ;-)
Adding a circuit for recharging the battery might be too much, making it too bulky.
Reply 2 years ago
Thank you do you have any recommendations on switches that would be suitable?
Reply 2 years ago
a slide switch as shown by Yves is fine, but I find Push & Lock switch better, actually both are fine, dont gona put a rocket switch type on a small project like this one ahahah, so definetly slide switch or Push Switch, it is in the feeling after all 😋
About recharging add a small 2 pin connectors; Femelle Micro USB is a neat choice! Connect it to battery Pins (+ & -), add make a small device, a TP4056 + a Male connector (of course corresponding the the femele used) , and soldered to Battery Pins of TP4056, and there you got your recharger device, or more geek, add in the device a Wireless Charger Receiver!! and same story , TP4056 + Wireless Charger, and there is a neat charger, just drop your "Distancing Device" on it at night at night for charging😉
Reply 2 years ago
https://www.aliexpress.com/item/32950857668.html
by means of example. Depending on what your design can include, as small as possible. There is discussion on the fact whether you should add it on the negative or positive lead of your power source. As I'm not an expert on that matter, I leave it at you to choose on the information you can find on the internet. Anyhow, be careful when you solder wires to these switches. Don't heat the contact for too long or you will render the switch useless.
Tip 2 years ago
Honestly I'd avoid rising the voltage up to 7V and then use an LDO to pull it down to 5V. That's a waste of energy... Instead, use the step up to rise the voltage to 5V, and use it to power directly the 5V rail (and the arduino through the 5V power pin rather than the RAW). The battery will last 40% more time.
In addition, in my experience for indicator LEDs like yours the difference between 5mA and 15mA is barely noticeable, so you can also try using 680mOhm resistors (and I think you will not notice any difference, but will consume far less energy, thus letting the battery last longer)
Reply 2 years ago
Great advice thank you I'm pretty new to this and every bit helps :)
2 years ago
So fashionable! ;)
Very clever project, and nicely presented. Well done!
Reply 2 years ago
Why thank you
2 years ago
Very nice...even the pleasing visual aspect of this is a reminder to anyone approaching that distance matters... accuracy is secondary. Nice 3D case too!
Bob D
Reply 2 years ago
Thank you very much
2 years ago
Nice project and a great Instructable, well done!!
Welcome to the community ;)
Reply 2 years ago
Thank you very much, looking forward to posting and reading more stuff
2 years ago
Nice job project. Needs sound/alarm to get the perfection. :)
Reply 2 years ago
or a mini taser...
Reply 2 years ago
that sounds like a great idea
Reply 2 years ago
Thought about it but wasn't sure if it would drive you crazy rather than warn the space intruders :)
went for super simple this time round
2 years ago
Doesn't this battery need BMS??
Reply 2 years ago
Not sure how I'd implement that easily, I guess if the dc booster was set at 5v and supplied the vcc there would be some way of measuring the supply in and then maybe triggering the leds to flash when low.