COVID Hacks #5 - Distance Monitoring mats

COVID Hacks #5 - Distance Monitoring mats

Distance Monitoring Mats

A minimalist low-cost social distancing enforcement system

Distance Monitoring mats

Story

The Social Distancing Problem

In public places like shopping malls, retail stores, airports, it is difficult social distancing and it is not possible for everyone to afford alarm systems based on distance sensors as other worthy hacksters have pointed out

What needs to change

Existing solutions include manual intervention by public officials, wearing masks and maintaining the 2m distance by estimation. However, all of these are bound to fail in some situation.

Wearing masks for prevention

Wearing masks for prevention

What I propose

My solution is to deploy mats placed in public places that sense if a person steps on them and if persons are detected on two nodes close enough a warning in the form of a buzzer is sounded with a visual warning. These mats would offer a cheap solution to autonomously monitor social distancing.

Such mats are available but there is no one to check if people are following instructions

Such mats are available but there is no one to check if people are following instructions

The solution is cheap enough to rapidly deploy in the field and is much more practical than the computer vision-based crowd monitoring or mask detecting solutions offered which are suitable only in select locations.

 

Concept

Sturdy, industrial-grade push buttons are affixed beneath generic mats and supplied and are connected and supplied from a low power line they are pulled up to. The other ends are connected to the Arduino MKR 1010 through a shift register IC(to increase the number of inputs).

Whenever two buttons in adjacent locations are found pressed, the Arduino activates the buzzer which immediately warns all people in the vicinity.

Things used in this project

Hardware components

Pushbutton switch 12mm

 

SparkFun Pushbutton switch 12mm

 

 

×

1

 

 

Arduino MKR WiFi 1010

 

Arduino MKR WiFi 1010

 

 

×

1

 

 

Li-Ion Battery 1000mAh

 

Li-Ion Battery 1000mAh

 

 

×

1

 

 

 

 

Mat(generic)

 

 

×

1

 

 

Buzzer

 

Buzzer

 

 

×

1

 

 

Software apps and online services

Arduino IDE

 

Arduino IDE

 

 

 

 

 

Ubidots

 

Ubidots

 

 

 

 

 

Android Studio

 

Android Studio

 

 

 

 

 

Hand tools and fabrication machines

Soldering iron (generic)

 

Soldering iron (generic)

 

 

 

 

 

Hot glue gun (generic)

 

Hot glue gun (generic)

 

 

 

 

 

Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires

 

Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires

 

 

 

 

 

What I Built

Distance Monitoring Mats - Main Circuit

Main Circuit

First, I will show you how to connect your Arduino MKR Wifi to the Arduino IoT CLoud and then discuss and demonstrate the working of my circuit. The only thing I think that needs to be discussed in the circuit is the 74HC165 shift register I have used to increase the number of inputs for my arduino MKR1010 board.

Connecting to Arduino IoT Cloud

  • Go to Arduino IoT Cloud
  • Make an account and verify your email address(not helping you with that)
  • Go to the Devices tab and connect your Arduino MKR1010 Wifi to your computer via a microUSB-B cable
  • On successful detection you should see this
Connecting to Arduino IoT Cloud

Board found

  • Give a name to your device(No spaces or special characters)
Set Device Name

Set Device Name

  • After pressing Next, you will be greeted with this annoying message.
Do not Panic!!!

Do not Panic!!!

  • Try three or four times. Surprisingly, the issue will be resolved(Atleast it was resolved in my case
  • Create a new Thing
Give the thing a name

Give the thing a name

  • Go to the Add Property tab and add all the necessary data configuration
https://hackster.imgix.net/uploads/attachments/1181767/mkr5_0XFTPCi4rB.png?auto=compress%2Cformat&w=740&h=555&fit=max
https://hackster.imgix.net/uploads/attachments/1181768/mkr6_lK06UvB9UT.png?auto=compress%2Cformat&w=740&h=555&fit=max
  • Your device is all set to send data to the cloud
https://hackster.imgix.net/uploads/attachments/1181769/mkr7_Xy4cMAlAvK.png?auto=compress%2Cformat&w=740&h=555&fit=max
  • Edit the Sketch and upload to your board using Arduino Create Agent
  • Go to your Dashboards tab and make your own dashboard following this tutorial

The 74HC165 Sorcery

The IC that I am using is 74HC165 Parallel In/ Serial Out Shift Register. One of the advantages that need to be stressed on is that by using only four pins, I can get eight input pins. Moreover, it can be cascaded, thus you can have any amount of input pins with only four pins with the help of this shift register.

74HC165 Parallel in, Serial Out Shift Register

74HC165 Parallel in, Serial Out Shift Register

Some of the features of 74HC165:

  • 8 bit Parallel Input
  • Serial output
  • Can be cascaded/ daisy chained

For more details on the chip, please refer to the datasheet here.

74HC165 Pin Diagram

74HC165 Pin Diagram

Pin description

Pin description

The input pins of the shift registers are pin 11 to 14 (D0 to D3) and pin 3 to pin 6 (D4 to D7). The input voltage acceptable range is between GND to Vcc, where maximum allowable voltage for Vcc is 7V according to the datasheet. However, it is recommended to operate the chip at 5V. 74HC165 has two output pins which are Q7 and /Q7, where /Q7 is the complement (inverted) of Q7.

After discussing about the input and output pins, let us move on with the control pins. To control the shift register, you would need three pins which are parallel load input (PL), clock input (CP) and clock enable input (CE).

Another pin that is useful especially when you want to cascade a few shift registers together, which is Serial Data Input (DS). Schematic on how to cascade the shift register will be shown later on.

Now, let us look into detail how to use the shift register. Initially, you need to make the parallel load input high. A low signal will triggers the input to be loaded into the shift register. This gives you a flexibility when to read the input to the shift registers. Besides, you want to stop reading the inputs while serially sending the output.

Next, you need to send the clock pulse to the shift register in order to obtain the serial output. However, you would need to set the clock enable before clocking out the data. After the clock is enabled, the parallel input data will be sent out in eight clock pulses.

A summary of the shift register operation is shown is the timing diagram below.

Timing Diagram for 74HC165

Timing Diagram for 74HC165

A simple schematic showing how to connect your 74HC165 Shift Register to Arduino. Notice that I am using a pull up resistor of 10k ohm on all the inputs. You can can also change it into pull down resistor network connection.

Schematic for 74HC165

Schematic for 74HC165

In order to ease the process of reading data from shift register, I am using an Arduino built in function which is ShiftIn(). More details regarding the function, please refer Arduino Reference.

ShiftIn(data,clock,order)

– The data is the input pin on Arduino to read the output from shift register whereas the clock is the pin connected to shift register clock. For the order, you can choose either MSBFIRST or LSBFIRST.

Note that you need to control the parallel load pin by yourself since it can’t be controlled by the shiftIn function. It can be controlled simply by digitalWrite to either HIGH or LOW.

#define enable 2
#define load
3
#define clock1
4
#define data
5
void setup
()
{
 pinMode(enable,OUTPUT);
 pinMode(load,OUTPUT);
 pinMode(clock1,OUTPUT);
 pinMode(data,INPUT);
 digitalWrite(load,HIGH);
 digitalWrite(enable,HIGH);
 Serial.print(
"Input = ");
 Serial.
begin(9600);
}
void loop
()
{
 Serial.print(
"Input = ");
 digitalWrite(load,LOW);
 delayMicroseconds(5);
 digitalWrite(load,HIGH);
 delayMicroseconds(5);
 digitalWrite(clock1,HIGH);
 digitalWrite(enable,LOW);
 byte incoming=shiftIn(data,clock1,MSBFIRST);
 digitalWrite(enable,HIGH);
 
for(int i=7;i>=0;i--)
 {
   
if(bitRead(incoming,i)==1)
   {
     Serial.print(
"1");
   }
   
else
   {
     Serial.print(
"0");
   }
 }
}

This code here can be run without using any libraries to check the working of the IC 74HC165. Once, that is done, we can move ahead and start integrating this with the cloud.

The Integration

The integration was pretty straight-forward as I had pre-written both the parts. Here is a demonstration of the system in action.

Further Improvements

The only improvement here is the placement of the buttons which can be bettered. I have arranged it in a very haphazard way due to lack of time. Also, Buttons with smaller form factor can be used.

Conclusion

Lets be clear with this. COVID is here to stay and if we do not adapt ourselves to the new normal, it would affect us terribly. The motive of this project was to enforce social distancing in public places. I believe I have been successful in what I set out to do. If you have any suggestions please let me know in the comments below.

References used

https://iamjxlee.wordpress.com

Fritzing Forum

Arduino Project hub

Schematics

Final Circuit

https://hackster.imgix.net/uploads/attachments/1181810/sujata_circuit_FCKrHpYtZY.png

 

This blog has been submitted by KRSSG, IIT-Kharagpur under the Robocraze Club Outreach Program.

Author: Moinak Ghosh

 

 

Components and Supplies

    You may also like to read

    Frequently Asked Questions

    Back to blog

    Leave a comment

    Please note, comments need to be approved before they are published.

    Components and Supplies

      You may also like to read