In the current scenario, social distancing matters a lot. COVID-19 to this date does not have a cure. The only feasible preventive method is to wash your hands and follow the norms of social distancing. But we all know that social distancing needs to be followed even when the lockdown end. But how do we do that when we are back to schools, offices and in our college. Human is a social being, no matter how much you try to maintain distance from the other person you need a constant reminder for that. So in order to solve that problem I came up with a unique solution, the SODI band. Also as hackster.io and UN together launched the UN COVID detect & protect challenge it was a perfect opportunity to create something like this with as minimal parts as possible as the supply chain is really broked at the time of making this project.
What is it ?SO.DI band is an esp8266 based wifi-based band that constantly checks for the presence of another band near it. And as soon as it senses that there is another band worn by another user very close to him or her it raises an alarm ( which can also be replaced with a vibration motor to be a bit subtle), because of this the person gets aware that he needs to maintain some distance and he has come too close to the other person.
How it works ?The band is constantly in access point and station mode both. Which means that it constantly checks for another access point ( station mode ) and also makes its own access point ( access point mode ) at the same time. The beauty is, that all the devices make an access point with the name of "SODI BAND" while also looking for another "SODI BAND"
Now you might ask why doesn't the esp gets confused between its own access point and another access point when they have the same name?
Answer: The SDK of esp8266 enables the esp8266 to ignore its own SSID even if it's of the same name what it is looking for.
How does it know when another SODI Band is near ?
Answer: The band constantly checks for the availability of another band while scanning through the WiFi networks once it sees that there is another SODI band in the vicinity after that it checks for its signal strength or RSSI and if the signal strength of another band is much stronger or greater than the threshold it knows that the other person is very near and the alarm needs to be raised.
Well RSSI does not gives you a very exact value of distance for particular signal strength but for such an application it works very well.
RSSI Stands for received signal strength intensity and it basically it tells you about the relationship between distance versus received signal strength. Well, there are very complex formulas available in the research papers to calculate the precise distance between the transmitter and the receiver but just for the sake of keeping the project-based simple, I haven't taken that route.
In the graph, as you can see the far I go from the transmitter the signal gets weaker hence the distance from my transmitter also increases which give me an approximate idea about the distance between them the relationship between the signal strength and the distance is not linear but still for this project it gets the job done. By default, I have chosen a value of -37db which approximately represents 1m
There is an inbuilt function of RSS in the ESP 8266 Wi-Fi library which can be directly used.
Let's build stuff - SchematicSchematic is as simple a just connecting your Node MCU's Pin D5 or a Generic ESP8266's GPIO PIN 14 to an LED
Remember you need another ESP to act as the second band to make this work
Pinouts :
Generic ESP8266 Board:
GPIO 14 to LED, Buzzer
Node MCU 1.0 :
D5 to LED, Buzzer
Also I know that you might be thinking why am I connecting the buzzer and the LED to the same GPIO pin, also I did not even used a resistor. Well the answer is that you can use a resistor or even if you don't just like me things work fine as the LED does not receive too much current from the board to get burned but enough to run the buzzer and the LED at the same time.
Code/*This code is developed by Aman Singhal under the project SODI BAND 1.0
* as it is an open source project i will try to maintain regular updates on
* the github repo at https://github.com/amansinghaljpr/SO.DI-Band do tag
* me wherever you use this project . The project is open source because of
* the tough times we are going through and i hope people will use this out
* of goodwill . Please do no commercialise it without prior permission
*/
#include <ESP8266WiFi.h>
const char* APssid = "SODI BAND"; //the acess point the device is going to make
const char* APpassword = "1234567890";
const int RSSI_MAX =-31;// maximum strength of signal in dBm
const int RSSI_MIN =-100;// minimum strength of signal in dBm
void setup() {
WiFi.mode(WIFI_OFF);
WiFi.disconnect();
delay(100); //this part turns off the wifi and resets it if it was already on
Serial.begin(115200);
pinMode(14,OUTPUT); //As i was using a generic type board so i used GPIO14 pin as output if you have nodeMCU change this to D5
Serial.println();
WiFi.mode(WIFI_AP_STA); //configuring the board in hybrid mode
Serial.print("Configuring access point...");
WiFi.softAP(APssid, APpassword);
Serial.println(WiFi.softAPIP());
}
void loop() {
// this is where magic happens
Serial.println("Wifi scan started");
int n = WiFi.scanNetworks();
Serial.println("Wifi scan ended");
if (n == 0) {
Serial.println("no networks found");
} else {
Serial.print(n);
Serial.println(" networks found");
for (int i = 0; i < n; ++i) {
// Print SSID and RSSI for each network found
Serial.print(i + 1);
Serial.print(") ");
Serial.print(WiFi.SSID(i));// SSID
Serial.print(WiFi.RSSI(i));//Signal strength in dBm
Serial.print("dBm (");
if(WiFi.SSID(i) == "SODI BAND")
{
if(WiFi.RSSI(i) > -37 )//THIS -37 is the key this is the threshold value btw this value is set according to the distance of 1m
{
digitalWrite(14,HIGH);//(Generic esp8255 : (14,HIGH) , NodeMCU : (D5,HIGH) )
Serial.println("A SODI BAND WAS FOUND");
break;
}
}
else
{
digitalWrite(14,LOW);
}
}
delay(100);
}
Serial.println("");
delay(100);
WiFi.scanDelete();
}
Explanation#include <ESP8266WiFi.h>
const char* APssid = "SODI BAND"; //the acess point the device is going to make
const char* APpassword = "1234567890";
This part of the code simply initialises the ESP8266 Wi-Fi library and gives the credentials for access point mode
const int RSSI_MAX =-31;// maximum strength of signal in dBm
const int RSSI_MIN =-100;// minimum strength of signal in dBm
This is one of the most important part of this code this is the maximum signal strength and the minimum signal strength which an ESP can receive from another ESP.You can get this data for yourself when you keep both of the ESP side by side. You can change the max RSSI if you get another result ( RSSI is always a -ve no )
void setup() {
WiFi.mode(WIFI_OFF);
WiFi.disconnect();
delay(100); //this part turns off the wifi and resets it if it was already on
This part of the code simply initialises the setup and disconnects from any of the access points and basically refreshes the wifi part of the ESP for the new activity.
Serial.begin(115200);
pinMode(14,OUTPUT); //As i was using a generic type board so i used GPIO14 pin as output if you have nodeMCU change this to D5
Serial.println();
WiFi.mode(WIFI_AP_STA); //configuring the board in hybrid mode
Serial.print("Configuring access point...");
WiFi.softAP(APssid, APpassword);
Serial.println(WiFi.softAPIP());
This part of the code firstly initialises the pin responsible for the output which is pin 14 in my case and also it puts the ESP8266 in a hybrid mode which configures ESP8266 in access point mode and station mode and then prints out the software access point IP address.
void loop() {
// this is where magic happens
Serial.println("Wifi scan started");
int n = WiFi.scanNetworks();
Serial.println("Wifi scan ended");
Initializing the wifi scanning or band searching process
if (n == 0) {
Serial.println("no networks found");
} else {
Serial.print(n);
Serial.println(" networks found");
for (int i = 0; i < n; ++i) {
// Print SSID and RSSI for each network found
Serial.print(i + 1);
Serial.print(") ");
Serial.print(WiFi.SSID(i));// SSID
Serial.print(WiFi.RSSI(i));//Signal strength in dBm
Serial.print("dBm (");
It initially says that if it does not found any network it will say no network found but if it does it will start printing out all the exercise one by one with their signal strength in decibels.
if(WiFi.SSID(i) == "SODI BAND")
{
if(WiFi.RSSI(i) > -37 ) //THIS -37 is the key this is the threshold value btw this value is set according to the distance of 1m
{
digitalWrite(14,HIGH);//(Generic esp8255 : (14,HIGH) , NodeMCU : (D5,HIGH) )
Serial.println("A SODI BAND WAS FOUND");
break;
}
}
else
{
digitalWrite(14,LOW);
}
}
delay(100);
}
Serial.println("");
delay(100);
WiFi.scanDelete();
}
Then from that list, it specifically searches for an SSID named SODIBAND . After it receives a SODI BAND SSID it then checks the RSSI of that particular SSID and if that signal is way too strong which is defined by our threshold value that is - 37 in the " if(WiFi.RSSI(i) > -37 ) " statement and the signal strength higher than -37 decibels it will make the GPIO14 high and raise an alarm for the user that you are way too close to the other person and you need to maintain some distance
After a lot of testing, I found out that this value work for me when I wanted to maintain a distance of one metre you can conduct your own tests and play with the value to see which value works best for you.
Video :
I hope you would love the project and have fun building it!
Comments