Project Report
Project Report
A Project Report on
“CPI COVID-19”
Submitted in Partial Fulfilment for the Award of Degree of
BACHELOR of ENGINEERING
in
ELECTRONICS & COMMUNICATION ENGINEERING
Submitted by
i
ABSTRACT
The COVID-19 pandemic is a collective stressor. The corona virus disease-19 is a highly
transmittable and pathogenic viral infection. The intermediate source of origin and transfer to
humans is not known, however, the rapid human-to-human transfer has been confirmed widely.
There is no clinically approved antiviral drug or vaccine available to be used against COVID-
19. In the current review, this research focuses on enhancing security to humans from the
deadly coronavirus by giving them the required guidance.
➢ Firstly, it helps in easy tracking of all those people who has been in close contact with
the person carrying this device. Basically, it eases the procedure of finding the contact
history of a person who has been tested positive.
➢ Secondly, in case a person carrying this device gets tested positive, then that person will
be able to notify the same to all the other people who has been in his contact within the
stipulated vicinity. Thus, all the other people could take the required measures at an early
stage.
This research is based on an optimised format enabling the device to work efficiently.
ii
ACKNOWLEDGEMENT
Any achievement, be it scholastic or otherwise does not depend solely on the individual
efforts but on the guidance, encouragement and cooperation of intellectuals, elders and
friends. A number of personalities, in their own capacities have helped us in carrying out
this project work.
We would like to take this opportunity to thank them all. We would like to take this
opportunity to express our sincere gratitude to our project guide, Ms. SHYLAJA V,
Associate Professor, Department of Electronics and Communication Engineering, B.I.T,
Bengaluru for her constant encouragement, support and guidance.
We also thank Dr. MUKTHI S. L, Assistant Professor, Project Coordinator, Department
of Electronics and Communication Engineering, B.I.T, Bangalore for motivation and
regular source of encouragement.
We extend our thanks to Dr. SREE RANGA RAJU M. N, Professor and Head of the
Department, Electronics & Communication Engineering, B.I.T, who in his capacity gave
us all possible support and assistance for the completion of the report.
We would like to express our gratitude to Dr. M.U. ASWATH, Principal, Bangalore
Institute of Technology for providing us with excellent facilities and academic ambience
which has helped us in satisfactory completion of this Bachelor’s Degree.
SAMARTHA L PRASANNA
1BI17EC103
SHASHANK B M
1BI17EC110
SUMAN GOWDA T M
1BI17EC129
SWAROOP A
1BI17EC130
iii
TABLE OF CONTENTS
CHAPTER 1
1.1 INTRODUCTION 1
1.2 WHAT IS ESP32? 2
1.3 SPECIFICATIONS OF ESP32 3
1.4 DIFFERENT WAYS TO PROGRAM 3
1.5 ESP32 DEVKIT-THE ESP32 DEVELOPMENT 4
BOARD
1.6 LAYOUT 5
1.7 PINOUT OF ESP32 BOARD 6
1.8 CONCLUSION 8
1.9 LITERATURE SURVEY 9
1.10 OBJECTIVES 12
CHAPTER 2
2.1 A BRIEF NOT ON BLE 13
2.2 DIFFERENT LAYERS IN BLE 14
2.3 IMPORTANT TERMS IN BLE 15
2.4 BLE STATES 16
2.5 BLE IN ESP32 17
2.6 ESP32 BLE SERVER CLIENT MODEL 17
2.7 ESP32 BLE SERVER 17
2.8 ESP32 BLE CLIENT 17
2.9 WORKING 18
2.10 ABOUT SPIFFS 21
2.11 CODE WALKTHROUGH 22
CHAPTER 3
3.1 ESP32 ARDUINO: SENDING DATA WITH SOCKET 25
CLIENT
3.2 INTRODUCTION 25
3.3 THE PYTHON CODES 25
3.4 THE ARDUINO CODES 29
3.5 TESTING THE CODES 33
3.6 WHY TO INTEGRATE WITH APPLICATION 35
iv
3.7 SOFTWARE TOOLS USED TO DEVELOP THE 35
APPLICATION
3.8 TECH STACK USED TO DEVELOP THE FRONT 35
END
3.9 WHAT IS REACT LIBRARY? 35
3.10 ADVANTAGES OF REACT 36
3.11 TECH STACK USED TO DEVELOP BACKEND 36
3.12 BACKEND DEVELOPMENT 37
3.13 PROPOSED MODEL 43
3.14 FLOW CHART 44
CHAPTER 4
4.1 RESULTS 46
4.2 EFFECTS OF SOCIAL DISTANCE OF RECEIVER 48
NODE RSSI
4.3 EFFECTS OF BODY ORIENTATION ON 49
RECEIVER NODE RSSI
4.4 EFFECTS OF SENDER-NODE BATTERY LEVEL 50
ON RECEIVER NODE RSSI
4.5 SIGN IN AND SIGN-UP PAGES 51
4.6 FEATURES 54
4.7 APPLICATIONS 55
4.8 CONCLUSION AND FUTURE WORK 56
CHAPTER 5
5.1 REFERENCE 57
5.2 STUDENT CONTACT DETAILS 58
v
LIST OF FIGURES
vi
24 SHOWING ABOUT FILES 52
25 SHOWING ABOUT CONTACT 53
vii
BANGALORE INSTITUTE OF TECHNOLOGY
VISION
To establish and develop the Institute as a centre of higher learning, ever abreast with expanding
horizon of knowledge in the field of engineering and technology, with entrepreneurial thinking,
leadership excellence for life-long success and solve societal problem.
MISSION
• Provide high quality education in the engineering disciplines from the undergraduate through
doctoral levels with creative academic and professional programs.
• Establish mutual beneficial partnerships with industry, alumni, local, state and central
governments
by public service assistance and collaborative research.
• Inculcate personality development through sports, cultural and extracurricular activities and
engage in the social, economic and professional challenges.
viii
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
BANGALORE INSTITUTE OF TECHNOLOGY
VISION
Imparting Quality Education to achieve Academic Excellence in Electronics and Communication
Engineering for Global Competent Engineers.
MISSION
• Create state of art infrastructure for quality education.
• Nurture innovative concepts and problem-solving skills.
• Delivering Professional Engineers to meet the societal needs
ix
DECLARATION
We hereby declare that the project work titled “CPI COVID-19”, is a project report of the
original work done by us at Bangalore Institute of Technology, Bengaluru and to the best of
our knowledge and belief, no part of it has been submitted for any degree or diploma of any
institution previously This project is submitted to Visvesvaraya Technological University,
Belagavi at Bangalore Institute of Technology, Department of Electronics and
Communication Engineering, Bengaluru in partial fulfilment for the award of Bachelor of
Engineering in Electronics and Communication during the academy year 2017-21.
SAMARTHA L PRASANNA
USN:1BI17EC103
SHASHANK B M
USN:1BI17EC110
SUMAN GOWDA TM
USN:1BI17EC129
SWAROOP A
USN:1BI17EC130
x
CPI COVID-19 2020-2021
CHAPTER 1
INTRODUCTION
Arduino is a great platform for beginners into the World of Microcontrollers and
Embedded Systems. With a lot of cheap sensors and modules, you can make
several projects either as a hobby or even commercial.
As technology advanced, new project ideas and implementations came into play
and one particular concept is the Internet of Things or IoT. It is a connected
platform, where several “things” or devices are connected over internet for
exchange of information.
In DIY community, the IOT projects are mainly focused on Home Automation
and Smart Home applications but commercial and industrial IoT projects have
far complex implementations like Machine Learning, Artificial Intelligence,
Wireless Sensor Networks etc.
The important thing in this brief intro is whether it is a small DIY project by a
hobbyist or a complex industrial project, any IoT project must have connectivity
to Internet. This is where the likes of ESP8266 and ESP32 come into picture.
If you want to add Wi-Fi connectivity to your projects, then ESP8266 is a great
option. But if you want build a complete system with Wi-Fi connectivity,
Bluetooth connectivity, high resolution ADCs, DAC, Serial Connectivity and
many other features, then ESP32 is the ultimate choice.
WHAT IS ESP32?
ESP32 is a low-cost System on Chip (SoC) Microcontroller from Espressif
Systems, the developers of the famous ESP8266 SoC. It is a successor to
ESP8266 SoC and comes in both single-core and dual-core variations of the
Tensilica’s 32-bit Xtensa LX6 Microprocessor with integrated Wi-Fi and
Bluetooth.
The good thing about ESP32, like ESP8266 is its integrated RF components like
Power Amplifier, Low-Noise Receive Amplifier, Antenna Switch, Filters and RF
Balun. This makes designing hardware around ESP32 very easy as you require
very few external components.
SPECIFICATIONS OF ESP32
ESP32 has a lot more features than ESP8266 and it is difficult to include all the
specifications in this Getting Started with ESP32 guide. So, I made a list of some
of the important specifications of ESP32 here. But for complete set of
specifications, I strongly suggest you to refer to the Datasheet.
• Arduino IDE
• Platform IO IDE (VS Code)
• LUA
• Micro Python
• Espressif IDF (IoT Development Framework)
• JavaScript
The good thing about ESP-WROOM-32 Module is the PCB has edge
castellations. So, what third-part manufacturers do is take the ESP-WROOM-32
Module and design a break-out board for this module.
One such board is the ESP32 Devkit Board. It contains the ESP-WROOM-32 as
the main module and also some additional hardware to easily program ESP32
and make connections with the GPIO Pins.
LAYOUT
We will see what a typical ESP32 Development Board consists of by taking a
look at the layout of one of the popular low-cost ESP Boards available in the
market called the ESP32 Devkit Board.
The following image shows the layout of an ESP32 Development Board which I
have.
The board which I have has 30 Pins (15 pins on each side). There are some board
with 36 Pins and some with slightly less Pins. So, double check the pins before
making connections or even powering up the board.
As you can see from the image, the ESP32 Board consists of the following:
• ESP-WROOM-32 Module
• Two rows of IO Pins (with 15 pins on each side)
• CP2012 USB – UART Bridge IC
• micro–USB Connector (for power and programming)
• AMS1117 3.3V Regulator IC
• Enable Button (for Reset)
• Boot Button (for flashing)
• Power LED (Red)
• User LED (Blue – connected to GPIO2)
• Some passive components
I will make a separate dedicated tutorial on ESP32 Pinout. But for the time
being, take a look the pinout diagram of the ESP32 Development Board.
This pinout is for the 30 – pin version of the ESP Board. In the pinout tutorial, I
will explain the pin out of both the 30 – pin as well as the 36 – pin version of the
ESP Boards.
CONCLUSION
This is a complete beginner’s tutorial on ESP32, an excellent SoC with
integrated Wi-Fi and Bluetooth connectivity. You learned about the ESP32
Microcontroller, its specifications, development board layout and a brief pinout
as well.
LITERATURE SURVEY
ABSTRACTION:
This application is a tool that tracks the places where a confirmed patient went,
so that every person that had contact with him/her can call the authorities or self-
isolate.
METHODOLOGY:
•The Google Maps JS API to represent the marked locations on the map.
•Open Cage Geocoding API to convert an address or the name of a place to
coordinates.
•Chart-JS to represent the daily number of new cases and the total number
of cases.
LIMITATIONS:
•Since the users expected to turn on location, privacy really becomes an issue.
• Power consumption becomes unusually high.
•Location might be inaccurate, leading to overestimate of contacts.
ABSTRACTION:
This application is a tool that tracks the places using Bluetooth where a
confirmed patient went, so that every person that had contact with him/her can
call the authorities or self-isolate.
METHODOLOGY:
•A digital contact tracing app is built using block chain application.
•Bluetooth is used trace other devices.
•Block chain tech is used to save user privacy.
Department of Electronics and Communication Engineering, BIT Page 9
CPI COVID-19 2020-2021
LIMITATIONS:
•Block chain being a cutting-edge technology there not enough flexible tool
out there to easily develop applications.
•Internet connection is mandatory but it might not be available in every part
of the planet.
ABSTRACTION:
The proposed method uses the Wi-Fi signals data from a possible contact
and a confirmed patient’s Smartphone to detect whether the two shared the same
physical space. Simulation results show up to 95% tracing accuracy depending on
area size.
METHODOLOGY:
•The main idea is used to detect if someone has been nearby of a confirmed
patient based on Wi-Fi signals collected from both people smart phones.
•Machine learning model is used to predict whether the two smart phones
shared same location
•Features introduced in training model
[Link] point-APs ratio
[Link] Wi-Fi signal strength information (RSSI) difference
[Link] RSSI difference between the infected patient’s and possible
contact’s Smartphone.
LIMITATIONS:
•A model is trained with these datasets to predict whether the person is
potential contact or not.
ABSTRACTION:
It is a monitoring, advance warning and detection of a person’s fever, heart beat
rate, cardiac conditions and some of the radiological features to detect the infected
(suspicious) person using wearable smart gadgets. This provides continually
updated map/pattern of communication chain of COVID-19 infected persons that
may span around in our national community.
OBJECTIVES
• Enables easy and faster tracking of all the people who have had close contact
with the person tested positive.
• Effectively helps to prevent the spread of the virus as people can be notified
within minimal amount of time, from an infected person so that other
people too can take up the required precautionary measures as early as
possible.
• Nowhere in the procedure the identity or personal information of the
infected person is exposed to others expect the fact that they were in close
contact with a person tested positive now.
• It is basically an offline device. Thus, does not require a person to have
internet connectivity always.
• The working of the device as well as the app is based on a well-structured
procedure thereby involving minimal steps to be followed up by the people
using it. This facilitates that those people with or without minimal
education can also make use of this device effectively.
• The device just requires the user to possess a smart phone, which usually
everyone owns these days.
• This device could also be used in future to battle against any similar
pandemic.
CHAPTER 2
The main feature of the Bluetooth 4.0 Specification was the integration of
Bluetooth Low Energy or simply BLE. BLE (previously marketed as
Bluetooth Smart) is a highly optimized version of Classic Bluetooth designed
specifically for low power wireless communication.
While the Classic Bluetooth (often described as Basic Rate and Enhanced Dara
Rate in technical documents referring to its data speeds) was designed as a
replacement to wired communication with short-range wireless
communication. It was designed with data speeds in mind and the applications
include large file transfers, wireless audio, etc.
BLE on the other hand is optimized for low power consumption instead of
higher data rates and is designed with IoT and battery-operated applications in
mind. Some of the popular applications of BLE are smart watches, fitness
trackers, health monitoring devices, radio beacons, etc.
• Controller
• Host
• Applications
The application layer is the highest layer which contains user interface, data
handling and logical aspects of the application.
BLE STATES
A BLE device can have 5 possible states:
• Standby
• Advertising
• Scanning
• Initiating
• Connected
The communication between two BLE devices can be either a Broadcast Type or
a Connection Type. In broadcasting, the ‘broadcaster’ BLE Device sends data to
any ‘observer’ BLE Device. It is a one-way data transfer.
BLE IN ESP32
We know that the main feature of ESP32 is Wi-Fi. But additionally, the ESP32
SoC also has Bluetooth support as well. ESP32 Bluetooth is a dual-mode system.
This means ESP32 supports both Classic Bluetooth as well as Bluetooth Low
Energy (BLE).
In this project, we will use two ESP32 Boards, one programmed as BLE Server
and the other as BLE Slave.
WORKING
After uploading codes to both the ESP32 Boards, you need to monitor the serial
ports of both the boards to see the communication. For this, I am using the
Arduino IDE’s Serial Monitor to open the COM port of the ESP32 BLE Client
Device and another software (like Putty or Terminal) to open the serial port of
ESP32 BLE Server Device.
After opening the respective serial port terminals for both ESP32 BLE Server
and Client, reset both the boards by pressing respective ENABLE (EN) buttons.
The ESP32 BLE Server device will start the BLE Server and starts advertising its
services. If you observe the Client ESP32’s Code, we used the Server ESP32’s
Service UUID and Characteristic UUID. What this means is that the Client
ESP32 scans for BLE devices and if the BLE with the particular UUIDs is found,
then it makes a connection.
Once the connection is established, the ESP32 BLE Client first reads the
characteristic value from the server (we set this as ‘Hello, World!’ in the Server’s
code) and prints it on the terminal.
After that, the client tries to set the characteristic value of the server with a new
value every couple of seconds. You can see the client’s terminal in the following
image.
Coming to the Server, once it starts the BLE Server, it reads its own
characteristic value every couple of seconds. You can see the following image
that the Server’s characteristic value is updated by the client and is read by the
server.
ABOUT SPIFFS
SPIFFS (SPI Flash File Storage), which is used for storing larger data in the
form of files. Think of SPIFFS as a very small SD Card onboard the ESP32 chip
itself. By default, about 1.5 MB of the onboard flash is allocated to SPIFFS. You
can see that for yourself by going through Tools −> Partition Scheme.
You can see that there are several other partition options available.
CODE WALKTHROUGH
We will again use the example code provided. Go to File −> Examples −>
SPIFFS −> SPIFFS_Test. This code is ideal for understanding all the file
operations possible with SPIFFS.
We begin with the inclusion of two libraries: FS.h and SPIFFS.h. FS stands for
File System.
#include "FS.h"
#include "SPIFFS.h"
Next, you can see that a number of functions have been defined for different file
system operations. They are −
Note that all of the above functions aren't asking for a file name. They are asking
for the full file path. Because this is a file system. You could have directories,
subdirectories, and files within those subdirectories. Therefore, ESP32 needs to
know the full path of the file you want to operate on.
Department of Electronics and Communication Engineering, BIT Page 22
CPI COVID-19 2020-2021
Next comes a function that isn't exactly a file operation function – test File IO.
This is more of a time benchmarking function. It does the following −
• Writes about 1 MB (2048 * 512 bytes) of data to the file path that you
provide and measures the write time
• Reads the same file and measures the read time
Note that the but array is never initialized with any value. We may very well be
writing garbage bytes to the file. That doesn't matter because the purpose of the
function is to measure the write time and the read time.
Once our functions have been defined, we move on to the setup, where the
invocation of each of these functions is shown.
Since we don't want to perform any recurring activity here, the loop is blank.
void loop () {
}
The output shown in the Serial Monitor will perhaps look like the image below –
CHAPTER 3
INTRODUCTION
In this ESP32 tutorial we will check how to send data with a socket client on the
Arduino core.
1 import socket
After that, we create an object of class socket, which we will use to configure the
server and to listen to incoming connections.
1 s = [Link]()
Now that we have our socket object, we need to bind it to an IP and port. These
will be the two parameters that our socket client needs to know in order to reach
the server.
To perform this binding, we need to call the bind method on our socket object,
passing as first input the IP, as a string, and as second input the port, as a number.
Since we are going to expose the server to be reached in the local network, we will
use the ‘[Link]’ IP, which will bind the socket to all the IP addresses on the
machine. Later, we will need to find out what is the actual local IP of the machine,
so we can reach it from the client.
We will use port 8090 in this code, but you can try with other port. Just make sure
the port you are going to use is available and not already in use by other
application.
1 [Link](('[Link]', 8090 ))
After the binding, we need to make our server start listening to connections. We
do it by calling the listen method on the socket object.
Note that this method receives as input the number of unaccepted connections that
are allowed before refusing new connections [1]. Since our simple use case doesn’t
involve multiple clients, we can pass the value 0.
1 [Link](0)
To start receiving the actual connections, we need to call the accept method on
our socket object. This is a blocking method, which means the execution of the
program will stop until a new client connects to the server.
Once a client connects to the server, this method returns a pair with a new socket
object and the address of the client. We can then use this new socket object to
establish the communication with the connected client.
Note that since sockets are bi-directional mechanisms, we can both send and
receive data from it.
Assuming that we want our server to run indefinitely, we do this accept method
call inside an infinite loop.
1 while True:
2
3 client, addr = [Link]()
4 # Client handling code
Now we will start receiving data from the client. We will also assume that the
client will be the one closing the connection after sending all the data, so we also
read the data inside a nested loop, which will only break when the client
disconnects.
To receive data sent by the client, we simply need to call the recv method on the
socket object returned by the previously called accept method.
Note that in Python 3.x (the one I’m using for this tutorial) the recv method returns
the data as a byte’s object. On other hand, on Python 2.x, the data is returned as a
string, so if you are using an older Python version you should adapt your code
accordingly.
As input, the recv receives the maximum number of bytes to receive at once. If
more than the specified number of bytes are sent by the client, they can be retrieved
with other calls to the recv method.
One important thing to keep in mind is that the recv method is also blocking. So,
after calling this method, the execution will block until either the client sends some
data or disconnects.
In case of disconnection, the recv method will return an empty byte’s object,
which we can leverage as stopping condition for the data reading loop.
1 while True:
2
3 client, addr = [Link]()
4
5 while True:
6 content = [Link](32)
7
8 if len(content) ==0:
9 break
10
else:
11
print(content)
12
Finally, when the client disconnects, we call the close method on the client socket
object to free the resources and go back to listening to a new connection. The final
Python code can be seen below and already includes this call.
1 import socket
2
3 s = [Link]()
4
5 [Link](('[Link]', 8090 ))
6 [Link](0)
7
while True:
8
9
client, addr = [Link]()
10
11 while True:
12 content = [Link](32)
13
14 if len(content) ==0:
15 break
16
17 else:
18 print(content)
19
print ("Closing connection")
20
[Link]()
21
22
In the Arduino code, we will start to include the WiFi.h library, so we can connect
to a WIFI network and then establish the socket connection.
1 #include <WiFi.h>
As global variables, we will declare the credentials of the WIFI network to which
we are going to connect. We will need the network name (SSID) and password.
We will also declare as global variables the IP address and port of the socket server
we have implemented in Python. As we have seen in the Python code, we did not
bind the server to a particular IP address, but rather used the ‘[Link]’ IP, which
means the server should be available in all the IPs of that machine.
Thus, we need to figure out the local IP of the machine on the local network, so
we can use that IP on the Arduino code. The easiest way to obtain the IP is by
typing the ipconfig command on the command line if you are on Windows, or the
ifconfig command if you are on Linux. These commands should be sent on the
machine that will be running the Python code.
Note that for the ESP32 to be able to reach the Python server hosted on a computer,
both devices need to be on the same network since we are not doing any port
forwarding and we are simply using local IPs.
Alternatively, you can obtain your machine’s local IP from this website.
Note that in the code below I’m using the local IP of my computer on my local
network. Yours will most likely be different. The port was 8090, as we have
defined in the Python code.
Moving on the Arduino setup function, we will simply open a serial connection to
output the results of our program and take care of connecting to the WiFi network,
using the previously declared credentials.
1
void setup ()
2
{
3
4 [Link](115200);
5
6 [Link](ssid, password);
7 while ([Link]()! = WL_CONNECTED) {
8 delay (500);
9 [Link]("...");
10 }
11
[Link]("WiFi connected with IP: ");
12
[Link]([Link]());
13
14
}
15
Next, on the Arduino loop, we will establish the connection to the server
periodically and send some data to it.
First, we declare an object of class WIFI Client, which we will use to establish
the connection and send the data.
1 WiFiClient client;
Then, to establish the actual connection, we need to call the connect method on
our WIFI Client object, passing as first input the IP of the server and as second
the port.
This method returns 1 if the connection was successful and 0 otherwise, so we can
use this to do some error checking. In case the connection fails, then we print a
message to the serial connection and delay for a second before trying to connect
again.
1 if () {
2
In case of success, we move on and send the actual data to the server, which is
done by calling the print method on the WIFI Client object and passing as input
the string to send.
Note that there other methods that we can use to send data to the server, such as
the write method.
Since this is a simple introductory tutorial, we will not be expecting data from the
server, so we can simply finish the connection by calling the stop method on our
WIFI Client object, thus freeing the resources.
1 [Link]();
The final source code is shown below. It contains some additional prints and a 10
seconds delay between each iteration of the Arduino loop.
1 #include <WiFi.h>
2
3 const char* ssid = "yourNetworkName";
4 const char* password = "yourNetworkPass";
5
const uint16_t port = 8090;
6
const char * host = "[Link]";
7
8
void setup ()
9 {
10
11 [Link](115200);
12
13 [Link](ssid, password);
14 while ([Link]()! = WL_CONNECTED) {
15 delay (500);
16 [Link]("...");
17 }
18
[Link]("WiFi connected with IP: ");
19
[Link]([Link]());
20
21
}
22
23 void loop ()
24 {
25 WiFiClient client;
26
27 if () {
28
29 [Link]("Connection to host failed");
30
delay (1000);
31
return;
32
}
33
34
[Link]("Connected to server successful!");
35
36 [Link] ("Hello from ESP32!");
37
38 [Link]("Disconnecting...");
39 [Link]();
40
41 delay (10000);
42 }
43
44
45
To test the whole system, we will start by compiling and uploading the Arduino
code to the ESP32. Once the procedure finishes, simply open the Arduino IDE
serial monitor.
Since the Python server is not yet running, then the connection attempts should
fail.
Fig. 15 Output of the program when the Python socket server is not connected
Next, run the Python code on the tool of your choice. In my case, I’m running it
on IDLE, the Python IDE that comes with the language installation.
Once the server is up and running, you should start receiving the messages from
the ESP32.
Fig. 16 Output of the Python program when receiving data from the ESP32
If you go back to the Arduino IDE serial monitor, you should start seeing the
connection and disconnection messages we have included in our code, as shown
in figure 3.
1) React js
React is a free and open-source front-end JavaScript library for building
user interfaces or UI components. It is maintained by Facebook and a
community of individual developers and companies. React can be used as a
base in the development of single-page or mobile applications. However,
React is only concerned with state management and rendering that state to
the DOM, so creating React applications usually requires the use of
additional libraries for routing, as well as certain client-side functionality
ADVANTAGES OF REACT
1)Nodejs
As an asynchronous event-driven JavaScript runtime, [Link] is designed to build
scalable network applications. In the following "hello world" example, many
connections can be handled concurrently. Upon each connection, the call back is
fired, but if there is no work to be done, [Link] will sleep. This is in contrast to
today's more common concurrency model, in which OS threads are employed.
Thread-based networking is relatively inefficient and very difficult to use.
Furthermore, users of [Link] are free from worries of dead-locking the process,
since there are no locks. Almost no function in [Link] directly performs I/O, so the
process never blocks. Because nothing blocks, scalable systems are very reasonable
to develop in [Link].
2)Express js
Express is a minimal and flexible [Link] web application framework that
provides a robust set of features for web and mobile applications. With a
myriad of HTTP utility methods and middleware at your disposal, creating a
robust API is quick and easy. Express provides a thin layer of fundamental
web application features, without obscuring [Link] features that you know
and love.
3)MongoDB
MongoDB’s document data model naturally supports JSON and its expressive
query language is simple for developers to learn and use. Functionality such
as automatic failover, horizontal scaling, and the ability to assign data to a
location are built-in.
Department of Electronics and Communication Engineering, BIT Page 36
CPI COVID-19 2020-2021
BACKEND DEVELOPMENT
User is the only entity that is stored in the database and with few attributes as
possible. Here is the code:
const mongoose =
require("mongoose");
name: {
type: String,
required: true,
maxlength: 32,
},
email: {
type: String,
required: true,
},
encry_password: {
type: String,
},
salt: {
type: String,
},
phoneNumber: {
type: Number,
required: true,
},
deviceid: {
type: String,
required: true,
},
role: {
type: Number,
default: 0,
},
isPrimaryContact: {
type: Boolean,
},
contacts: {
type: Array,
default: [],
},
});
userSchema
.set(function (password) {
this._password = password;
[Link] = uuidv1();
this.encry_password =
[Link](password);
})
.get(
function () {
return this._password;
},
{ timestamps: true }
);
[Link] = {
try {
return crypto
.createHmac("sha256", [Link])
.update(plainpassword)
.digest("hex");
} catch (error) {
return "";
},
};
[Link] = [Link]("User",
userSchema);
{
"confirmedPatient": "123457",
"suspectedContacts": [
"123453",
"123455"
]
}
This contacts details will be fetched from database and is added to user
contacts attribute through which we can extract details.
Json file is parsed from the frontend and it transferred to this route
if (![Link]()) {
return [Link](422).json({
error: "missing attribute",
});
}
const { confirmedPatient, suspectedContacts } = [Link];
phoneNumber: phoneNumber,
name: name,
};
[Link](obj);
[Link](obj);
[Link](patients);
[Link](
{ deviceid: confirmedPatient },
{ $push: { contacts: obj } },
(err, user2) => {
if (err) {
return [Link]({ error: "could not add attribute" });
}
}
);
});
}
[Link]({ deviceid: confirmedPatient }, (err, user) => {
if (err) {
return [Link](err);
}
return [Link](user);
});
};
PROPOSED MODEL
When a node receives a BLE advertising packet, it uses RSSI to estimate the
approximate distance between nodes.
Device ON
Configured Scan
Period, Rebroadcast
In broadcaster:
In listening mode:
NO
If
devices
available
?
CHAPTER 4
RESULTS
We used ESP32 devices as nodes in our implemented system (Fig. 2). Which
supports Wi-Fi (IEEE 802.11b/g/n) and Bluetooth (classic and BLE). An ESP32
has dimensions 24×24×14 mm and weighs 33 g. With inbuild LED and Memory
Nodes in the implemented system send a BLE advertising packet every second.
The ESP32 cannot change its transmission power. Up to 31 bytes of advertising
data can be included in each BLE advertising packet. Adverting packets in our
implemented system include a flag, a 16-byte service UUID, and two bytes of
battery voltage information used for power consumption evaluation and
debugging. The overall size of an advertising packet, including its header, CRC,
etc., is 43 bytes.
We should note here that we obtained these evaluation results under limited
conditions. In future work, we will perform additional evaluations by changing
conditions including combinations of nodes, combinations of people, postures of
persons wearing monitors, and the environments in which measurements are
performed.
As the Figure shows, there were variations in RSSI even among same
orientations. However, the average and median RSSI decreased with orientation.
Compared to the case where both subjects faced each other (defined as 0°), RSSI
decreased by about 5 dBm at sender-node subject orientations of 90 and 270°,
and by about 10 dBm at 180°. There will likely be situations where students sit
side-by-side on campus, so it is necessary to estimate close contact with a margin
of about 5 dBm.
Here, as an outlier, also shows a point at which RSSI exceeded -100 dBm at a
180° orientation. The influence of such outliers can be reduced by using median
values when estimating social distancing.
We found that the battery voltage fell below 3.0 V after the sender node
transmitted 2130 BLE advertising packets. Figure 4(c) shows the relation
between battery voltage and RSSI as a scatter diagram. As the figure shows, we
found no correlation between battery voltage and received signal strength. The
calculated correlation coefficient was -0.0133. We therefore conclude that in us
Based on the role of the user he will be redirected to either home page (normal
user) or add contacts page (Authorized user)
Once json file received from the ESP32 is uploaded it shows the user details
in card like structure.
This application is quite simple but our primary focus of the project was to
develop sensor that senses other and saves id.
FEATURES
APPLICATIONS
CHAPTER 5
REFERENCE
NAME: Shashank BM
USN : 1BI17EC110
CONTACT NUMBER: 8073534448
EMAIL ID: shashankbm073@[Link]
NAME: Swaroop A
USN : 1BI17EC130
CONTACT NUMBER: 8105687933
EMAIL ID: swaroopaee98@[Link]