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 :)


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

Arduino Pro Mini ATMEGA328P 5v

DC-DC Voltage Booster Converter

5mm Coloured Leds

220 ohm Resistors

FTDI USB TTL Serial Adapter

Lipo Battery 3.7v

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.

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() {
  // initialize led pins as 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() {
  // Clears the TRIG_PIN condition
  digitalWrite(TRIG_PIN, LOW);
  // Sets the TRIG_PIN HIGH (ACTIVE) for 10 microseconds
  digitalWrite(TRIG_PIN, HIGH);
  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

  // 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.

Battery Powered Contest

Participated in the
Battery Powered Contest