COVID-19 Social Distance Meter

by barney.nicholls in Circuits > Arduino

17405 Views, 162 Favorites, 0 Comments

COVID-19 Social Distance Meter

image1 (1).jpeg
image0 (1).jpeg
image2.jpeg
Demo of my Covid-19 Social Distance Wearable

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

Tools

  • Soldering Iron
  • Multimeter
  • Bradawl (optional)
  • 3D Printer

HC-SR04 Ultrasonic Sensor

image5.jpeg

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.

Arduino Pro Mini 5v ATMEGA328P

image2 (2).jpeg
image1 (2).jpeg
image0 (2).jpeg

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.

DC-DC Voltage Booster

image8.jpeg
image4 (2).jpeg

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.

LED Indicators

image7.jpeg

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

3D Printing

back.png
front.png
lettering.png

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.

Circuit

diagram_bb.png
image0.jpeg

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.

Show Me the Code

Capture.PNG

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);
}

Things I Have Learnt

image6.jpeg
image1.jpeg

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.