Today health system failed in most country in virus infection because gov do not have haealt data and any graphs and analytics that give real time of data of people how much population have normal spo2level how much person have high fever how much population is traveling where. In fact we need a 3D Analytics system with a ML model to protect and tackle the pendamic situation. In Today scenario of virus infection we need the 3D level of protection system 1st :-get isolated and protect our self 2nd :-Reduce risk of getting infected to others from our own virus 3rd :- A predictive and central health analytic system where every person health data is feed to a ML model which monitor and predict about health issue in advance about that person might be in infection and alert the gov and that person so that person and government/health expert can tackle the situation before it get worse. Our system integrate small GPS , distance sensor M5Stack atom microphone , and many different inbuilt sensors of M5stack. It uses all these sensor data feed to a ML model that create analytic about the health of that person and ML model automatically figure out possible health abnormalities and inform the government and health experts so they tackle them in advance and also these data about health travel data of that person is sent to a central AWS cloud and gives analytic so government and health experts will get a real time health analytic of his whole state , country and they plan the health management of his stage and country . This device also checks the person locations of visits and alert the person when he tries to enter in hotspot or corona infected area and if the device detect that person have hight fever then this device alert that person not to enter in healthy virus free area and also sent the alert with all health data to goverment/Health experts using AWS cloud services so that he infected person not spread it other and get instant care and precautions. It in connection of mesh network every person have to wear this device data is exchanged between and if any person come in proximity having high fever the other person automatically get alert to keep safe distance and precaution to protect the spread of virus.
Step 1
First we create code that captures the data from sensor like max30100 for health data and location from gps here we used the Arduino IDE for coding and getting dataFirst we create code that captures the data from sensor like max30100 for health data and location from gps here we used the Arduino IDE for coding and getting data
First we create code that captures the data from sensor like max30100 for health data and location from gps here we used the Arduino IDE for coding and getting dataFirst we create code that captures the data from sensor like max30100 for health data and location from gps here we used the Arduino IDE for coding and getting data
Here we use the liberary tiny GPS plus and and MAX30100 for getting GPS location of person and patiant and health data of person and patients
include <M5Core2.h>
#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
#include "Fonts/EVA_20px.h"
#include "Fonts/EVA_11px.h"
#include <TinyGPS++.h>
PulseOximeter pox;
int Spo2 = 99;
int Bmp= 90;
const char *gpsStream =
"$GPRMC,045103.000,A,3014.1984,N,09749.2872,W,0.67,161.46,030913,,,A*7C\r\n";
// The TinyGPS++ object
TinyGPSPlus gps;
// Callback (registered below) fired when a pulse is detected
void onBeatDetected()
{
Serial.println("Beat!");
}
void setup()
{
Serial.begin(115200);
if ( Serial2.available() > 0){
gps.encode(Serial2.read());
}
M5.begin();
M5.Lcd.fillScreen(WHITE);
Serial.print("Initializing pulse oximeter..");
// Initialize the PulseOximeter instance
// Failures are generally due to an improper I2C wiring, missing power supply
// or wrong target chip
// if (!pox.begin()) {
// Serial.println("FAILED");
// for(;;);
// } else {
// Serial.println("SUCCESS");
// }
// The default current for the IR LED is 50mA and it could be changed
// by uncommenting the following line. Check MAX30100_Registers.h for all the
// available options.
// pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);
// Register a callback for the beat detection
pox.setOnBeatDetectedCallback(onBeatDetected);
}
void loop()
{
pox.update();
M5.Lcd.fillScreen(WHITE);
Spo2 = random(90, 99);;// pox.getSpO2()
Bmp= random(80, 90);//(pox.getHeartRate())
M5.update();
M5.Lcd.drawCircle(150,44, 30,BLUE);
M5.Lcd.drawCircle(150,44, 31,RED);
M5.Lcd.drawCircle(150,44, 34,RED);
M5.Lcd.setTextFont(4);
M5.Lcd.setTextColor(RED);
M5.Lcd.setCursor(30, 30);
M5.Lcd.printf("Spo2 = ");
M5.Lcd.print(Spo2);
M5.Lcd.drawCircle(140,110, 30,BLUE);
M5.Lcd.drawCircle(140,110, 31,RED);
M5.Lcd.drawCircle(140,110, 34,RED);
M5.Lcd.fillCircle(192,63, 3,RED);
M5.Lcd.setCursor(30, 95);
M5.Lcd.setTextColor(RED);
M5.Lcd.printf("Heart = ");
M5.Lcd.print(Bmp);
if (Spo2 < 70){
M5.Lcd.setTextFont(4);
M5.Lcd.setCursor(205, 54);
M5.Lcd.setTextColor(RED);
M5.Lcd.printf("Oxy Low");
}else{
M5.Lcd.setTextFont(4);
M5.Lcd.setCursor(205, 54);
M5.Lcd.setTextColor(BLACK);
M5.Lcd.printf("Oxy ok");
}
M5.Lcd.setTextFont(4);
M5.Lcd.fillCircle(10,170, 3,RED);
M5.Lcd.setCursor(25, 165);
M5.Lcd.setTextColor(BLACK);
M5.Lcd.printf("COVID -Ve");
M5.Lcd.setTextFont(4);
M5.Lcd.fillCircle(10,195, 3,RED);
M5.Lcd.setCursor(25, 195);
M5.Lcd.setTextColor(BLACK);
M5.Lcd.printf("Loc=Delhi");
M5.Lcd.printf("lat=28.1,lon=22.1");
if (gps.location.isValid())
{
M5.Lcd.setTextFont(4);
M5.Lcd.fillCircle(10,195, 3,RED);
M5.Lcd.setCursor(25, 195);
M5.Lcd.setTextColor(BLACK);
M5.Lcd.printf("Loc=Delhi");
M5.Lcd.print(gps.location.lat(), 6);
M5.Lcd.print(gps.location.lng(), 6);
}
// Make sure to call update as fast as possible
//pox.update();
// Asynchronously dump heart rate and oxidation levels to the serial
// For both, a value of 0 means "invalid"
Serial.print("H=");
Serial.print(pox.getHeartRate());
Serial.print("spo2=");
Serial.print(pox.getSpO2());
Serial.prinln("/");
Step 2
Next we will create the code for RASPBERRY PI Python that upload the code and connet the AWS cloud here the M5 stack send the data ver serial and in python we gather the data using pyserial and upload to AWS using Python code
DK.MQTTLib import AWSIoTMQTTShadowClient
import serial
import logging
import time
import json
import argparse
import busio
serialPort = serial.Serial(port = "COM4", baudrate=115200,
bytesize=8, timeout=2, stopbits=serial.STOPBITS_ONE)
# Shadow JSON schema:
#
# {
# "state": {
# "desired":{
# "bmp":<INT VALUE>,
# "spo2":<INT VALUE>
# }
# }
# }
# Function called when a shadow is updated
def customShadowCallback_Update(payload, responseStatus, token):
# Display status and data from update request
if responseStatus == "timeout":
print("Update request " + token + " time out!")
if responseStatus == "accepted":
payloadDict = json.loads(payload)
print("~~~~~~~~~~~~~~~~~~~~~~~")
print("Update request with token: " + token + " accepted!")
print("moisture: " + str(payloadDict["state"]["reported"]["moisture"]))
print("temperature: " + str(payloadDict["state"]["reported"]["temp"]))
print("~~~~~~~~~~~~~~~~~~~~~~~\n\n")
if responseStatus == "rejected":
print("Update request " + token + " rejected!")
# Function called when a shadow is deleted
def customShadowCallback_Delete(payload, responseStatus, token):
# Display status and data from delete request
if responseStatus == "timeout":
print("Delete request " + token + " time out!")
if responseStatus == "accepted":
print("~~~~~~~~~~~~~~~~~~~~~~~")
print("Delete request with token: " + token + " accepted!")
print("~~~~~~~~~~~~~~~~~~~~~~~\n\n")
if responseStatus == "rejected":
print("Delete request " + token + " rejected!")
# Read in command-line parameters
def parseArgs():
parser = argparse.ArgumentParser()
parser.add_argument("-e", "--endpoint", action="store", required=True, dest="host", help="Your device data endpoint")
parser.add_argument("-r", "--rootCA", action="store", required=True, dest="rootCAPath", help="Root CA file path")
parser.add_argument("-c", "--cert", action="store", dest="certificatePath", help="Certificate file path")
parser.add_argument("-k", "--key", action="store", dest="privateKeyPath", help="Private key file path")
parser.add_argument("-p", "--port", action="store", dest="port", type=int, help="Port number override")
parser.add_argument("-n", "--thingName", action="store", dest="thingName", default="Bot", help="Targeted thing name")
parser.add_argument("-id", "--clientId", action="store", dest="clientId", default="basicShadowUpdater", help="Targeted client id")
args = parser.parse_args()
return args
# Configure logging
# AWSIoTMQTTShadowClient writes data to the log
def configureLogging():
logger = logging.getLogger("AWSIoTPythonSDK.core")
logger.setLevel(logging.DEBUG)
streamHandler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
streamHandler.setFormatter(formatter)
logger.addHandler(streamHandler)
# Parse command line arguments
args = parseArgs()
if not args.certificatePath or not args.privateKeyPath:
parser.error("Missing credentials for authentication.")
exit(2)
# If no --port argument is passed, default to 8883
if not args.port:
args.port = 8883
# Init AWSIoTMQTTShadowClient
myAWSIoTMQTTShadowClient = None
myAWSIoTMQTTShadowClient = AWSIoTMQTTShadowClient(args.clientId)
myAWSIoTMQTTShadowClient.configureEndpoint(args.host, args.port)
myAWSIoTMQTTShadowClient.configureCredentials(args.rootCAPath, args.privateKeyPath, args.certificatePath)
# AWSIoTMQTTShadowClient connection configuration
myAWSIoTMQTTShadowClient.configureAutoReconnectBackoffTime(1, 32, 20)
myAWSIoTMQTTShadowClient.configureConnectDisconnectTimeout(10) # 10 sec
myAWSIoTMQTTShadowClient.configureMQTTOperationTimeout(5) # 5 sec
# Connect to AWS IoT
myAWSIoTMQTTShadowClient.connect()
# Create a device shadow handler, use this to update and delete shadow document
deviceShadowHandler = myAWSIoTMQTTShadowClient.createShadowHandlerWithName(args.thingName, True)
# Delete current shadow JSON doc
deviceShadowHandler.shadowDelete(customShadowCallback_Delete, 5)
# Read data from moisture sensor and update shadow
while True:
serialString = serialPort.readline()
# read moisture level through capacitive touch pad
bmp = serialPort.readline()
# read temperature from the temperature sensor
spo2 = serialPort.readline()
# Create message payload
payload = {"state":{"reported":{"bmp":str(bmp),"spo2":str(spo2
)}}}
Next we will connect the sensors to M5stack and Gps to Serial port of M5stack then we connect the M6Stack usb to Raspberry Pi USB and then we run the AWS Cloud uplpad code to Raspebrry pi. Next In AWS we use the Quick sight to create real time graph and it wil display the data of every person who have the device in a single place we also create one place ML based analytics that shwo the amount of pepulation effeted of bad health etc so that goverment can manage perople health smartly . This project is first version we will update soon wih full working model in next version.I was facing problem with my card for payment verification for AWS account so soon will update when I got working card for AWS.
Comments