The Problem we are tackling is the Coronavirus, the pandemic we are all facing. There are currently more than 9 million cases across the US today. These numbers were expected to drop, but sadly they have not improved. However, the European Union and the rest of the world is doing a much better job at handling the global pandemic. The reason for this is better regulation. A major contributor to the spread of the disease is human interactions, a lot of which occur in closed buildings like stores. The best way to decrease those interactions is for people to only enter closed buildings when there are fewer people there.
Device Description:Our device tells customers how many people are in a closed building in real time so they can decide if they want to enter. The device will also collect data on the number of people within the store to determine peak hours so that customers can plan accordingly to avoid those times and store owners can plan to be more strict about social distancing and mask-wearing.
Parts & Cost of the device:Our device was designed to be a cost efficient product with multiple applications. Below are the components of the device and their respective prices.
Arduino Nano 33 BLE - $20.20
Solderless Bread board full size - $2.67
UltraSonic Sensor HC-SR04 - $2.67
Power supply Module - $1.50
Micro-SD Card Module - $1.70
Micro-SD Card - $4.00
DS1307 - RTC module - $3.43
PIR Sensors - $1.80(x2)
LCD panel - $3.25
Jump wires - $5.79
Resistor - $0.06
Total: $48.87
- Prices found on amazon.com and links to parts are in hardware section
This device can be built for around $50 to build one unit(a reasonable cost for businesses) and provides multiple different functions that helps decrease the spread of coronavirus.
Parts details:Counter:
The counter uses two PIR(Passive Infrared) sensors and an ultrasonic sensor. The ultrasonic sensor uses sound waves to determine an object's distance from it and the PIR sensors use pyroelectric sensors to compare heat readings and determine if there was motion caused by a living being. The reason that two PIR sensors are being used is that once a PIR sensor is activated it enters a block time where no motion can be detected. Since no motion can be detected the device cannot count a person entering or exiting the building during that time. To resolve this issue
The code of the device checks which sensor was activated first and whether or not the second sensor was activated to determine the direction of the person's movement.
//check to see if someone passed ultrasonic sensor then PIR sensor
ultrasonicStart();
if(distance>0 && distance<doorwayLength){
delay(250);
PIRstate = digitalRead(PIRpin);
if(PIRstate != LOW){
//Increase count by one after someone passed ultrasonic then PIR sensor
counter+=1;
//make sure that count is never negative
if(counter<0){
counter = 0;
}
//Set LCD screen, Switch which PIR sensor is being used, and add changes to count along with time to that days files
lcdSet();
pirSwitch();
SDset();
}
}
//check to see if someone passed PIR sensor then ultrasonic sensor
PIRstate = digitalRead(PIRpin);
if(PIRstate!=LOW){
delay(450);
ultrasonicStart();
if(distance>0 && distance<doorwayLength){
//Decrease count by one after someone passed PIR then ultrasonic sensor
counter-=1;
//make sure that count is never negative
if(counter<0){
counter = 0;
}
//Set LCD screen, Switch which PIR sensor is being used, and add changes to count along with time to that days files
lcdSet();
pirSwitch();
SDset();
}
}
}
If someone passes the ultrasonic sensor then the PIR sensor the count of people in the building increases by one. If someone passes the PIR sensor than the ultrasonic sensor then the count of the number of people in the building decreases by one. The real-time count of the number of people in the building is displayed on an LCD screen along with the maximum capacity of the building.
RTC Module:
The RTC module is a real-time clock that is attached to the Arduino. The reason we attached this module is that the Arduino cannot keep track of the time when it is disconnected from power. The RTC module however has a built-in battery that allows it to keep the time even when not connected to any power source. Our device uses this module so that it can send the time along with the count to the SD card so that later on, a graph can be made comparing the time and count allowing store owners to easily see peak hours for their store.
Data Storage:
The data collected on the count of people at certain times is stored on a micro-SD card that is connected to the Arduino. When our device is powered on for the first time on a day it creates a file named after the date. For the remainder of that day, every time the count of the number of people in the store changes the time of the change and the new count are added to that file in columns under the headers of time and count. Once the device is powered off the micro-SD card can be safely disconnected from the Arduino and connected to a computer. Store owners can see the data of any day by selecting that day’s file. The file will open as a text document and the data can either be imported or copied and pasted into a spreadsheet to make the graph of Time verse count to see peak hours of their store.
Set up InstructionsStep 1: Downloading and setting up the libraries
In this device we used 5 library codes that need to be downloaded. The five libraries are the RTClib, Liquid Crystal,Wire, SPI, and SD libraries. To download these libraries go to the library manager in the Arduino IDE, type the names into the search bar, select the correct library, and click install.
After installing, the libraries need to be included in the code. This is done by typing #include<libraryname.h> for each library at the start of the code.
//Include Library Codes
#include <RTClib.h>
#include <LiquidCrystal.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
Step 2: Connect Arduino and Power Supply Module to Breadboard
Take the Arduino nano and connect it near the middle of the breadboard. If pins of the Arduino are not pre-soldered, solder them before attaching to breadboard.
After connecting the Arduino, attach the power supply module to the breadboard facing away from the serial port. Connect the Voltage In(VIN) pin of the Arduino to the 5V of the power supply module and connect the GND pin to the ground of the power supply module.
-Tip: Label wires with labeling tape when connecting them so device can be taken apart and put back together easily.
Step 3: Setting up the RTC module
Connect the DS1307 RTC Module's 5V pin to the 5V of the breadboard. Connect the module's GND pin to the ground of the breadboard. Connect the SCL pin to A5 on the Arduino. Connect the SDA pin to A4 on the Arduino.
At the start of the code define rtc using the code below.
RTC_DS1307 rtc;
After defining rtc, create a set of variables to store the values for the time and date.
//Define variable for time and date
int nowMinute;
int nowSecond;
int nowHour;
int nowDay;
int nowDate;
int nowMonth;
Once these variables have been defined, in the setup of the Arduino start up the rtc module and adjust the date and time on it (will only adjust if device is connected to a computer). Retrieve the exact date and time from the RTC module and store that in the date and month variables to later be used to create a file with a name based on the date.
//Set time on RTC module and get date for filename
rtc.begin();
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
DateTime now = rtc.now();
nowDate = now.day();
nowMonth = now.month();
Lastly, in the loop of the Arduino retrieve the exact time from the Arduino and store them in the minute and hour variables to later be used when sending data to the file on the sd card.
//Get time and date from RTC module
DateTime now = rtc.now();
nowMinute = now.minute();
nowHour = now.hour();
Step 4: Setting up the SD card module using the code below.
Connect the micro-SD card module's GND pin to the ground of the breadboard. Connect the modules VCC pin to the 5V on the breadboard. Connect the MISO pin to D12 on the Arduino. Connect the MOSI pin the D11 on the Arduino. Connect the SCK pin to D13 on the Arduino. Connect the CS pin to D10 on the Arduino.
At the start of the code define a file using the code below.
File myFile;
Create a file name with the date collected from the RTC module in the Arduino's setup using strings and a conversion to char.
//Create filename using the date
str = String(nowDate);
str2 = String(nowMonth);
str3 = String("/");
str4 = String(".txt");
str5 = str+str3+str2+str4;
str.toCharArray(Filename, 15);
Check to see if the SD card is properly working(if it is not properly functioning the module might not be connected to the right pins or the sd card is not set to the proper format). If it is then open a file using the filename using the one just created, set the module to write on that file, and write column headers of time and count to the file.
//Check to see if SD card module is working properly
if (!SD.begin(10)) {
Serial.println("SD not connected");
while (1);
}
Serial.println("working");
//Create file on SD card module using filename
myFile = SD.open(Filename, FILE_WRITE);
if (myFile) {
myFile.print("Time");
myFile.print("\t");
myFile.println("Count");
myFile.close();
Serial.println("done.");
}
Lastly, create a function that adds the count and time to the file just created so that every time the count changes the time when the change happened and the new count will be added to that file.
//Function to add new count and time when count changed to that days file
void SDset(){
myFile = SD.open(Filename, FILE_WRITE);
myFile.print(nowHour);
myFile.print(":");
myFile.print(nowMinute);
myFile.print("\t");
myFile.println(counter);
myFile.close();
Serial.println("Done");
}
Step 5: Placing the device into a box
Take the device an place it in the box the box where the LCD screen, Ultrasonic, and PIR sensors are set. Adjust the device so that the holes for the power supply modules wires match the ports and the SD card module can fit through its pre-cut slot.
Step 6: Setting up the Ultrasonic Sensor
Connect the GND pin to the ground on the breadboard. Connect the Echo pin to the A7 pin on the Arduino. Connect the Trig pin to the A6 pin on the Arduino. Connect the VCC pin to the 5V on the breadboard.
For the code, create a function that sends out a sound wave and calculates the amount of time it takes for that sound wave to bounce of and object and return to the sensor. Take the amount of time and convert to centimeters using speed of sound then divide by 2(time is amount of time sound takes to travel two ways) to determine the distance an object is from the sensor in centimetres.
//Function to find distance using Ultrasonic Sensor
void ultrasonicStart(){
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration*.0343)/2;
}
Call this function and determine if someone walked within a certain distance(the length of the doorway) to the ultrasonic sensor using a logic statement.
ultrasonicStart();
if(distance>0 && distance<doorwayLength){
Step 7: Setting up PIR sensors
For the first PIR sensor connect the GND pin to the ground on the breadboard. Connect the OUT pin to D9 on the Arduino. Connect the VCC to 5V on the breadboard. For the second PIR sensor connect the GND pin to the ground on the breadboard. Connect the OUT pin to A3 on the Arduino. Connect the VCC pin to A2 on the Arduino.
-Tip: Before connecting the wires, wrap the Fresnel lenses of the sensors with tape(masking and electric) to block the senors from getting any infrared readings from their surroundings.
For the code, create a function that switches which PIR sensor is used and turns on the second PIR sensor when it is being used.
//Function to switch which PIR sensor is used
void pirSwitch(){
pinSwitcher = PIRpin;
PIRpin = PIRpin2;
PIRpin2 = pinSwitcher;
delay(750);
if(PIRpin == A3){
digitalWrite(A2,HIGH);
}
else if(PIRpin == 9){
digitalWrite(A2, LOW);
}
}
Lastly, use a logic statement to determine that someone walked past the sensor.
PIRstate = digitalRead(PIRpin);
if(PIRstate != LOW){
Step 8: Setting up LCD display
Connect the GND pin to the ground on the breadboard. Connect the VCC to the 5V on the breadboard. Connect the contrast pin(V0) to D6 on the Arduino. Connect the RS pin to D8 on the Arduino. Connect the R/W pin to ground on the breadboard. Connect EN to D7 on the arduino. Connect d4 to D5 on the Arduino. Connect d5 to D4 on the Arduino. Connect d6 to D3 on the Arduino. Connect D7 to D2 on the Arduino. Connect the LCD annode(A) to a 220 ohm resistor connected to 5V on the breadboard. Connect the LCD cathode(K) to ground on the breadboard.
At the beginning of the code define which pins the LCD display is connected to and set up the LCD display. Create a contrast variable and set it to a contrast where the screen can easily be read(usually 50).
//Define pins, set up LCD display, and define contrast value
const int rs = 8, en = 7, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int contrast = 50;
In the Arduino setup start up the LCD screen and set the initial display
//Set contrast for LCD and start LCD display
analogWrite(6,contrast);
lcd.begin(16, 2);
lcd.print(counter);
lcd.setCursor(0, 1);
lcd.print("out of");
lcd.setCursor(7,1);
lcd.print(maxCapacity);
Create a function to update the screen every time the count changes.
//Function to update LCD screen with new count
void lcdSet(){
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(counter);
lcd.setCursor(0,1);
lcd.print("out of");
lcd.setCursor(7,1);
lcd.print(maxCapacity);
}
Step 9: Upload Code
Connect a computer to the Arduino nano through the Serial Port(use a micro-USB to USB cable). Open the Arduino IDE and open the code file. In the tools menu under boards select the proper Arduino board(if the board is not seen go to board manager and search for the board and click install).
After selecting the proper board go back to tools and under Port select the serial port that the Arduino is connected to. Verify and Compile the code to check if there are any errors. If there are not any errors then upload the code to the Arduino.
Final Product
The video gives a final explanation on the connection within the device. There are also two demos: one that was conducted in a home and another that was done at a local grocery store. In the video data collected from store is shown and and an explanation on how that data could be used is given.
CONCLUSION:This device provides a way to limit human interaction that is key to decreasing the spread of the Coronavirus. Using this device many customers can see a real-time count of people in the store to decide if they want to enter and see peak hours to plan and avoid times when many others are present. Building owners can use this device to know when to be more strict and have more regulations for social distancing and mask-wearing. The actions done by both the customers and the store owners can minimize the number of human interactions within stores decreasing the spread of the virus.
Comments