Project tutorial
TraceX-Contact Tracing & Social Distancing (Nano 33+IOTA)

TraceX-Contact Tracing & Social Distancing (Nano 33+IOTA) © GPL3+

A wearable band and iOS app to trace contacts, enable social distancing, report active cases, instant alert and self health monitoring.

  • 72 views
  • 0 comments
  • 0 respects

Components and supplies

Uploads2ftmp2f846c5da0 b017 4033 97be d07213c421252fscreenshot2019 08 0213 57 36 u4wa0vvm7t
Arduino Nano 33 BLE Sense
This MCU is the heart of the smart band. I am using on board sensors for temperature, humidity and air pressure readings, fall detection using on board IMU sensor.
×1
Max30102 functional diagram 836uf6fvws
Maxim Integrated MAX30102 High-Sensitivity Pulse Oximeter and Heart-Rate Sensor for Wearable Health
I am using this low cost sensor to measure blood pressure or BPM
×1
Oled lcd 128x64 1
ElectroPeak 0.96" OLED 64x128 Display Module
OLED display to show readings on smart band
×1
HM-10
Bluetooth 4.0 Module. Separate from Nano 33 BLE. This module is used solely for transmitting iBeacon advertisement.
×1
Vibration module
×1
LiPo 3.7v battery
×1

Necessary tools and machines

3drag
3D Printer (generic)
4859917
10 Pc. Jumper Wire Kit, 5 cm Long
Used during bread boarding

Apps and online services

Zthq9891 400x400
IOTA Tangle
Screen%20shot%202015 07 20%20at%206.10.26%20pm
Amazon Web Services AWS Lambda
AWS Pinpoint
Screen%20shot%202015 07 20%20at%206.11.48%20pm
Amazon Web Services AWS DynamoDB
Ide web
Arduino IDE
Swift Language
Mobile app for iOS created using Swift language

About this project

Since COVID-19 break out, entire world went into isolation, offices were closed, factories were shut down, airports are locked down. This brings the fear of big financial crisis and recession. People started realizing locked down helped to flatten the curve but they can't afford to continue any longer. It's time to face it and live with it.

As governments and states are considering to lift the lock down and employers are planning to bring their workforce back, our safety is the foremost priority for everyone. We need a smart mechanism to trace someone who was exposed to COVID-19 to stop the spread in entire workforce plus a mechanism to enable/enforce social distancing guidelines recommenced by CDC.

What is social distancing?

[Source CDC website]

Limiting face-to-face contact with others is the best way to reduce the spread of coronavirus disease 2019 (COVID-19).

Social distancing, also called “physical distancing, ” means keeping space between yourself and other people outside of your home.

To practice social or physical distancing stay at least 6 feet (about 2 arms’ length) from other people.

In addition to everyday steps to prevent COVID-19, keeping space between you and others is one of the best tools we have to avoid being exposed to this virus and slowing its spread locally and across the country and world.

Limit close contact with others outside your household in indoor and outdoor spaces. Since people can spread the virus before they know they are sick, it is important to stay away from others when possible, even if you—or they—have no symptoms. Social distancing is especially important for people who are at higher risk for severe illness from COVID-19.

Why social distancing is so important ?

COVID-19 spreads mainly among people who are in close contact (within about 6 feet) for a prolonged period. Spread happens when an infected person coughs, sneezes, or talks, and droplets from their mouth or nose are launched into the air and land in the mouths or noses of people nearby. The droplets can also be inhaled into the lungs. Recent studies indicate that people who are infected but do not have symptoms likely also play a role in the spread of COVID-19.

It may be possible that a person can get COVID-19 by touching a surface or object that has the virus on it and then touching their own mouth, nose, or eyes. However, this is not thought to be the main way the virus spreads. COVID-19 can live for hours or days on a surface, depending on factors such as sunlight, humidity, and the type of surface. Social distancing helps limit opportunities to come in contact with contaminated surfaces and infected people outside the home.

Although the risk of severe illness may be different for everyone, anyone can get and spread COVID-19. Everyone has a role to play in slowing the spread and protecting themselves, their family, and their community.

Well, this is well understood that social distancing is the way to stop spreading the infection when we are back to our usual social life again. But how do we actually do it?

  • Go to grocery stores with measuring tape ? :)
  • What if we come close to a stranger accidentally? We should panic and go to doctor?
  • What if someone is diagnosed positive? Do do we know whom that person met in last 14 days and transmitted the virus?

The answer is Contact Tracing

So, what is Contact Tracing?

[Source UT Austin]

Contact tracing is a very lengthy process that requires many steps, but when done successfully, it can interrupt the ongoing transmission of a disease and reduce the spread of infection. Contact tracing helps catch and control new outbreaks before they are able to grow, effectively stopping the disease in its tracks.

When deployed early enough, contact tracing can often make a difference in the dynamics of an outbreak. As in the case of South Korea, whose rapid response involved enhanced testing availability, safe COVID-19 medical facilities, and a government-run, technologically advanced contact tracing system. South Korea was able to lower the number of new infections from 851 on March 3 to 11 infections as of April 21. Their mortality rate from COVID-19 hovers around 2%.

Data gathered from contact tracing also helps epidemiologists learn more about a disease and its transmission in a particular population, which is used to track impact regionally, nationally, and globally. Enhancing contract tracing funding and efforts can help keep communities safe from outbreaks and death rates low..

Our concerns about Contact Tracing

  • Privacy - First thing comes in mind with contact tracing is sharing GPS location through smart phones. But recent poll in the United States reveals 50% of smartphone users said they would not use Apple or Google’s contact tracing app, and only 43% said they trusted the big tech companies with their information. So clearly, people are scared to share their GPS coordinates with government agencies or big tech companies.
  • Cross border data sharing - COVID-19 is a global crisis and contact tracing data must be shared across border. But there is not trust-less system to share data between two countries or government agencies.
  • Data transparency and immutability - Another big issue we have to deal with is data transparency and immutability. We need to make sure no traces are deleted or modified or hide for any reasons.

Presenting TraceX, most affordable contact tracing solution which solves all the above problems with contact tracing, cross border data sharing and data transparency.

TraceX is a wearable bracelet accompanying by a mobile

How does it work ?

Principal is very simple and explained in 3 simple comic screens below. Please watch the video for more detail explanation.

Features at a glance

  • Enable social distancing by on screen notification and beep as well as vibration on the bracelet.
  • Enable contact tracing by exchanging secret data, iBeacon advertisement.
  • Securely and anonymously record new case with option to share coordinate and local traces to help frontline health care providers and governments to proactively take necessary steps to disinfect and quarantine the place, object or persons.
  • Each case is recorded in immutable IOTA tangle making it temper proof.
  • Self health monitoring - On device pulse oximeter sensor to trace BMP and SpO2 level. Data is streamed to TraceX app over bluetooth.
  • On device temperature, humidity and pressure sensor to monitor surroundings of a person. This is very useful for senior citizen to monitor remotely maintaining social distancing guidelines.
  • On click device activation. Simply scan the QR code on TraceX app and you are ready to go.

TraceX is available in two variants.

  • Lite is the most affordable contact tracing enabled wearable. Build cost is less than $8
  • Pro is loaded with sensors such as pulse oximeter, OLED display, IMU for fall detection / measuring steps, environmental sensors to measure humidity, temperature and pressure with bluetooth connectivity. Arduino Nano 33 BLE sense is the heart of the device. Build cost is around $40.

Choice 1 - TraceX Lite ( Only trace enabled iBeacon )

Choice 2 - TraceX Pro ( With Pulse Oximeter and MEMS sensors with Bluetooth )

Demo

Before we deep dive, let's watch the demo

Demo video

High Level Design / Architecture

Considering cost, scale and availability I chose AWS serverless architecture. Backend is written in NodeJS/ExpressJS, deployed to Lambda. User profile and device token ( for push notification ) are stored in dynamoDB. Backend is accessed as REST API through API Gateway. Lambda connects to IOTA Tangle.

Why IOTA ?

IOTA has fundamentally reengineered distributed ledger technology, enabling secure exchange of both value and data, without any fees. IOTA is not Blockchain but more than a Blockchain. No blocks. No Miners. When you send an IOTA transaction you validate two other transactions. This allows IOTA to overcome the cost and scalability limitations of blockchain. IOTA has endless possibilities and promises. If you are not familiar with it, I would strongly encourage you to visit their website https://www.iota.org/

As IOTA is built on distributed ledger technology, fundamentally data is immutable. This makes it perfect fit for my use case as I like to record the traces as immutable records. Moreover as there is no real owner of the data, it breaks the cross border barrier. Any healthcare organization, government agencies with valid secret key can look up data and integrate with their own system. There is no trust issue as no one has full control over the data to alter.

TraceX Mobile Application

TraceX mobile app is super easy to use and loaded with all the feature needed for contact tracing at high scale.

The dashboard gives you all the information you need right at your finger tip. You can monitor your BPM and environment just registering the bracelet with TraceX app.

User can see graphical representation of traces and proximity through the app as well.

Use report the case through the app and elect to share coordinate.

Code

Arduino Nano 33 BLE code for wearableArduino
#include <ArduinoBLE.h>
#include <Arduino_HTS221.h>
#include <Arduino_LPS22HB.h>

#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include "MAX30105.h"
#include "spo2_algorithm.h"
#include "heartRate.h"

MAX30105 particleSensor;

#define MAX_BRIGHTNESS 255

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

//#define OLED_RESET LED_BUILTIN
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(OLED_RESET);
static const unsigned char PROGMEM logo2_bmp[] =
{ 0x03, 0xC0, 0xF0, 0x06, 0x71, 0x8C, 0x0C, 0x1B, 0x06, 0x18, 0x0E, 0x02, 0x10, 0x0C, 0x03, 0x10,              //Logo2 and Logo3 are two bmp pictures that display on the OLED if called
  0x04, 0x01, 0x10, 0x04, 0x01, 0x10, 0x40, 0x01, 0x10, 0x40, 0x01, 0x10, 0xC0, 0x03, 0x08, 0x88,
  0x02, 0x08, 0xB8, 0x04, 0xFF, 0x37, 0x08, 0x01, 0x30, 0x18, 0x01, 0x90, 0x30, 0x00, 0xC0, 0x60,
  0x00, 0x60, 0xC0, 0x00, 0x31, 0x80, 0x00, 0x1B, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x04, 0x00,
};


BLEService sensorService("FFE0");  // Environmental_Sensor-Service
BLEStringCharacteristic bleCharTemp("2A6E", BLERead | BLENotify, 2);  // Temperature-Characteristic
BLEStringCharacteristic bleCharBpm("2A37", BLERead | BLENotify, 3);  // BPM-Characteristic
BLEStringCharacteristic bleCharOximetry("2A62", BLERead | BLENotify, 3);  // Oximetry-Characteristic
BLEShortCharacteristic switchChar("2A63", BLERead | BLEWrite | BLENotify);
BLEStringCharacteristic bleCharHumidity("2A64", BLERead | BLENotify, 3);  // Humidity-Characteristic
BLEStringCharacteristic bleCharPressure("2A65", BLERead | BLENotify, 4);  // Baromerter-Characteristic (hPa)



long previousMillis = 0;
int oldTemperature = 0;



const byte RATE_SIZE = 4; //Increase this for more averaging. 4 is good.
byte rates[RATE_SIZE];
byte rateSpot = 0;
long lastBeat = 0; //Time at which the last beat occurred
float beatsPerMinute;
int beatAvg;


//vibration
#define VIBRATE_PIN 2

void switchCharacteristicWritten(BLEDevice central, BLECharacteristic characteristic) {
  // central wrote new value to characteristic, update LED
  Serial.print("Characteristic event, written: ");

  if (switchChar.value()) {
    Serial.println("LED on");
    digitalWrite(VIBRATE_PIN, HIGH);
    delay(1000);
    digitalWrite(VIBRATE_PIN, LOW);
  }

}


void setup() {
  Serial.begin(9600);
  //while (!Serial);

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  //display.drawBitmap(0, 0, logo3_bmp, 32, 32, WHITE);    //Draw the second picture (bigger heart)
  display.drawBitmap(5, 5, logo2_bmp, 24, 21, WHITE);
  display.setTextSize(2);                                //And still displays the average BPM
  display.setTextColor(WHITE);
  display.setCursor(50, 0);
  display.print("BPM");
  

  display.display();
  delay(3000);

  
  
  pinMode(22, OUTPUT);
  pinMode(24, OUTPUT);
  pinMode(VIBRATE_PIN, OUTPUT);
  digitalWrite(VIBRATE_PIN, LOW);

  if (!BLE.begin()) {
    Serial.println("Bluetooth init. failed!");
    while (1);
  }

  if (!HTS.begin()) {
    Serial.println("Failed to initialize humidity temperature sensor!");
    while (1);
  }

  if (!BARO.begin()) {
    Serial.println("Failed to initialize BARO sensor!");
    while (1);
  }


  BLE.setDeviceName("TRACEX");
  BLE.setLocalName("TRACEX");


  BLE.setAdvertisedService(sensorService);

  switchChar.setEventHandler(BLEWritten, switchCharacteristicWritten);

  sensorService.addCharacteristic(bleCharTemp);
  sensorService.addCharacteristic(bleCharBpm);
  sensorService.addCharacteristic(bleCharOximetry);
  sensorService.addCharacteristic(switchChar);
  sensorService.addCharacteristic(bleCharHumidity);
  sensorService.addCharacteristic(bleCharPressure);
  
  BLE.addService(sensorService);

  bleCharTemp.writeValue(String(0));
  bleCharBpm.writeValue(String(0));
  bleCharOximetry.writeValue(String(0));
  bleCharHumidity.writeValue(String(0));
  bleCharPressure.writeValue(String(0));

  
  BLE.advertise();
  Serial.println("Bluetooth active, waiting to be connected.....");

  //Initialize sensor
  if (!particleSensor.begin(Wire, I2C_SPEED_FAST)) //Use default I2C port, 400kHz speed
  {
    Serial.println("MAX30105 was not found. Please check wiring/power.");
    while (1);
  }
  particleSensor.setup(); //Configure sensor with default settings
  particleSensor.setPulseAmplitudeRed(0x0A); //Turn Red LED to low to indicate sensor is running
  particleSensor.setPulseAmplitudeGreen(0);



}

void updateTemperature() {
  int temperature = HTS.readTemperature(FAHRENHEIT);
//  Serial.print("Temperature = ");
//  Serial.print(temperature);
//  Serial.println(" °F");
  int sensorValue = map(temperature, 0, 100, 0, 10000);
  bleCharTemp.writeValue(String(sensorValue));
  oldTemperature = sensorValue;

  
  int humidity = HTS.readHumidity();
  bleCharHumidity.writeValue(String(humidity));

  int pressure = BARO.readPressure(PSI);
//  Serial.print("Pressure = ");
//  Serial.print(pressure);
//  Serial.println(" kPa");
  bleCharPressure.writeValue(String(pressure));
}


void updateBMP(){
 
  bleCharBpm.writeValue(String(beatAvg));
  display.clearDisplay();
  display.drawBitmap(5, 5, logo2_bmp, 24, 21, WHITE);
  display.setTextSize(2);                                //And still displays the average BPM
  display.setTextColor(WHITE);
  display.setCursor(60, 10);
 // display.print("BPM");
  
  //display.setCursor(90, 0);
 display.print(beatAvg, DEC);
 
  display.display();
  
}


void loop() {

  // poll for BLE events
  BLE.poll();

  // waiting for a BLE central device.
  BLEDevice central = BLE.central();

  if (central) {
    Serial.print("Connected to central: ");

    Serial.println(central.address());
    digitalWrite(22, HIGH);  // indicate connection
    digitalWrite(24, HIGH);

    while (central.connected()) {




      long currentMillis = millis();
      if (currentMillis - previousMillis >= 5000) {
        previousMillis = currentMillis;
        updateTemperature();
        updateBMP();
        //switchChar.writeValue(1);
        //vibrate();
        //updateHeartBeat(loggedheartRate, loggedspo2);
        //loggedheartRate = 0;
        //loggedspo2 = 0;
      }
      long irValue = particleSensor.getIR();
      if (checkForBeat(irValue) == true)
      {
        //We sensed a beat!
        long delta = millis() - lastBeat;
        lastBeat = millis();
        beatsPerMinute = 60 / (delta / 1000.0);
        if (beatsPerMinute < 255 && beatsPerMinute > 20)
        {
          rates[rateSpot++] = (byte)beatsPerMinute; //Store this reading in the array
          rateSpot %= RATE_SIZE;                    //Wrap variable
          beatAvg = 0;
          for (byte x = 0; x < RATE_SIZE; x++)
            beatAvg += rates[x];
          beatAvg /= RATE_SIZE;
        }
      }
      Serial.print("IR=");
      Serial.print(irValue);
      Serial.print(", BPM=");
      Serial.print(beatsPerMinute);
      Serial.print(", Avg BPM=");
      Serial.print(beatAvg);
      if (irValue < 50000)
        Serial.print("Bracelet removed!");
      
  



    }//end of while connected


    digitalWrite(22, LOW);
    digitalWrite(24, LOW);
    Serial.print("Disconnected from central: ");
    Serial.println(central.address());

  }


}

void vibrate() {
  Serial.println("Vibrate");
  digitalWrite(VIBRATE_PIN, HIGH);

  delay(200);
  digitalWrite(VIBRATE_PIN, LOW);
  Serial.println("End Vibrate");
}
lambda-backend.zipJavaScript
NodeJS backend API code
No preview (download only).

Comments

Similar projects you might like

TraceX-Contact Tracing & Social Distancing Ecosystem

Project tutorial by Mithun Das

  • 1,719 views
  • 0 comments
  • 11 respects

Smart Glasses for Social Distancing

Project tutorial by Bilal Ahmed

  • 1,364 views
  • 0 comments
  • 1 respect

Plant Monitoring System using AWS IoT

Project tutorial by CJA3D

  • 39,791 views
  • 6 comments
  • 93 respects

Heart Rate Monitor Using IoT

Project tutorial by Team Technopaths

  • 32,492 views
  • 3 comments
  • 36 respects

Scent-terrific Smart Candle

Project tutorial by Darian Johnson

  • 4,993 views
  • 0 comments
  • 35 respects

SIGFY (Sigfox Farm Yield) with Crop and Health Monitoring

Project tutorial by Sumit

  • 4,462 views
  • 2 comments
  • 28 respects
Add projectSign up / Login