Sonar Anti-COVID Gadget for Social Distancing

5 May 2020

Scroll

cover-sonar-anti-covid

Sonar Anti-COVID Gadget for Social Distancing

Questa pagina è disponibile in Italiano Italiano

Licenza Creative Commons
Sonar Anti-COVID of Riccardo Schifaudo is distributed under licence Creative Commons Attribution-NonCommercial 4.0 International.
Based on a work at https://www.the-shinobi-arts-of-eccentricity.com/blog/sonar-anti-covid/.
For furthermore permissions contacts the Author https://www.the-shinobi-arts-of-eccentricity.com/blog/contattami/.

A Good Shinobi is a Ninja expert in art of fighting, and he knows how to move in an intelligent manner during an outbreak;

This warrior has to be able to evaluate the right social distancing to avoid being infected against an invisible enemy

For this reason, you can use a special gadget of portable sonar to detect distances between you and your target.

What is Sonar Anti-COVID Gadget and how does it work?

I made this small gadget using Arduino open-source electronic board in order to measure the social distance using echo sonar sensor which provides feedbacks thanks to three colorful LEDs and a small piezo speaker.

I realized this invention as a new individual protection device in addition to conventional equipment and complementary tool during this sanitary emergency.

I assume prevention is better off healing, so this solution is less intrusive than contact tracing mobile apps.

You can use this Social Distance Detector Anti-COVID to keep safe distances of at least one meter or two meters if you practise sports.

Why use Social Distance Detector?

  • Because prevention is better to heal;
  • To take care of your parents, relatives, and colleagues;
  • During your walking safely in the public spaces;
  • Sonar doesn’t produce pollution and it doesn’t track any personal data and avoid violating your privacy;
  • You can help to decrease the R0 constant of spreading virus;
  • Social distancing is the only tip you can use in case you don’t have surgical mask or gloves;

Which distances are detected of Social Distance Sonar?

In general, the safe distance-based of OMS directive is 1Meter and 82 centimetres.

For this reason, Social Distance Sonar Detector provides audio-video feedback you can use when you walk outdoor.

Which are distances detected?

  • GREEN LED: Distance measure is above 2 meters, so you are at a safe distance to avoid infection of COVID-19.
  • YELLOW LED: Your distance is between one meter to two-meter, so you could be a risk but you are almost safe. In this range, piezo speaker will start to ring to signal to you, and people around you about you are really close.
  • RED LED: You are below under one meter and you risk being infected or infect people close to you, so piezo speaker will ring continuously, so you need to go away immediately and keep the safe distance.

What do you need to made Social Distance Sonar Detector?

  • Arduino Nano;
  • 1 Diode Led red;
  • 1 Diode Led yellow;
  • 1 Diode Led green;
  • 3 resistors of 220 Omh;
  • 1 Piezo speaker;
  • Ultrasonic sensor HC-SR04 for measuring social distance;
  • Wiring cables;
  • Batteries of 5 Volt dell’Arduino as a power bank for instance,
    maybe clock batteries will be better.

Useful link for buying materials of Sonar Anti-COVID

PIEZO Speaker

Ultrasonic Sensor HC-SR04 to measure distance using the Sonar Echo.

Arduino NANO as microcontroller to make the Social Distance Sonar

Colourful Diode LED to signal distance with lights

Wiring Schema of Sonar Anti-COVID for social distancing

Sonar Anti-COVID Gadget for Social Distancing
  • Connect Vcc pinout with 5 volts of Arduino;
  • Connect GND pinout with negative side of LEDs cathode with resistors and anodes of led with analog pinout A2, A3, A4 of Arduino.
  • Connect one of two pins of Piezo Speaker to Arduino GND and the other to pin 8 of Arduino;
  • Connect Vin pin of Arduino to the positive of the battery and GND to the negative.

How does the Sonar Anti-COVID Sketch work?

Basically this code enables the sonar to launch an ultrasonic signal against obstacles and calculate the distance between you and your target.

In based the distance detected, the three conditions if can turn on one of three LEDs with an additional beep of signal of piezo speaker with led red or yellow light. Greenlight doesn’t produce noise.

Piezo speaker is activated of “pitches.h” library while echo sonar is enabled of trigger signal of 10 microseconds, then I increased the time of 20 microseconds to measure unto to 5 meters with microphone of the sonar.

Beep() function call and active the piezo speaker and afterwards can be deactivated with a boolean variable when you get the right social distance.

So is enough easy, nothing of transcendental? 🙂

#include "pitches.h"

#define TRIGGER_PIN 2
#define ECHO_PIN 3
#define MAX_DISTANCE 500
#define greenLed A3
#define yellowLed A4
#define redLed A2
#define toneBuzzer 8


#define echoPin 2 // attach Arduino to pin Echo of HC-SR04
#define trigPin 3 //attach Arduino to pin Trig of HC-SR04

// defines variables
long duration; // variable for the duration of sound wave travel
int distance; // variable for the distance measurement
 
void setup() {
   pinMode(TRIGGER_PIN, OUTPUT); // Sets the trigPin as an OUTPUT
   pinMode(ECHO_PIN, INPUT); // Sets the echoPin as an INPUT
   pinMode(greenLed,OUTPUT);
   pinMode(yellowLed,OUTPUT);
   pinMode(redLed,OUTPUT);
   digitalWrite(greenLed,LOW);
   digitalWrite(yellowLed,LOW);
   digitalWrite(redLed,LOW);
   Serial.begin(9600);
   Serial.println("Ultrasonic Sensor HC-SR04 Test"); // print some text in Serial Monitor
}
 
void loop() {

   //unsigned int distance = sonar.ping_cm();
   //Serial.print(distance);
   //Serial.println("cm");

  // Clears the trigPin condition
    digitalWrite(TRIGGER_PIN, LOW);
    delayMicroseconds(4);
    // Sets the trigPin HIGH (ACTIVE) for 10 microseconds
    digitalWrite(TRIGGER_PIN, HIGH);
    delayMicroseconds(20);
    digitalWrite(TRIGGER_PIN, LOW);
    // Reads the echoPin, returns the sound wave travel time in microseconds
    duration = pulseIn(ECHO_PIN, HIGH);
    // Calculating the distance
    distance = duration * 0.034 / 2; // Speed of sound wave divided by 2 (go and back)
    // Displays the distance on the Serial Monitor
    Serial.print("Distance: ");
    Serial.print(distance);
    Serial.println(" cm");
   if(distance == 0){
        digitalWrite(greenLed,LOW);
        digitalWrite(yellowLed,LOW);
        digitalWrite(redLed,LOW); 
   }
   if(distance>0 && distance < 100){
        digitalWrite(greenLed,LOW);
        digitalWrite(yellowLed,LOW);
        digitalWrite(redLed,HIGH);
        beep(true);
        delay(distance);
   } 
   
   if(distance>=100&&distance<200){
        digitalWrite(greenLed,LOW);
        digitalWrite(yellowLed,HIGH);
        digitalWrite(redLed,LOW);
        beep(true);
        delay(distance*10);
   }
   
   if(distance>=200){
        digitalWrite(greenLed,HIGH);
        digitalWrite(yellowLed,LOW);
        digitalWrite(redLed,LOW);
        beep(false);
   }

    //delay(1000); 
}

void beep(bool status_beep){
  if(status_beep)
   tone(toneBuzzer,432,100);
}

DOWNLOAD PROJECT SONAR ANTI-COVID

Now you have a new individual protection device to protect your health with the feedback of piezo speaker and the three LEDs 😉

Do you like the Article?


Prev Post
Next Post
Copied!