Rishabh Jain
Published © GPL3+

Smart Emergency and Health Assistive Tool

An IoT enabled solution to monitor patient health and inform relatives in case of emergency.

IntermediateFull instructions provided4 hours2,162
Smart Emergency and Health Assistive Tool

Things used in this project

Hardware components

MSP-EXP430F5529LP MSP430 LaunchPad
Texas Instruments MSP-EXP430F5529LP MSP430 LaunchPad
×1
CC3100BOOST SimpleLink CC3100 Wi-Fi BoosterPack
Texas Instruments CC3100BOOST SimpleLink CC3100 Wi-Fi BoosterPack
×1
Texas Instruments LM35
×1
Pulse rate Sensor
×1
Gravity:Digital Push Button (Yellow)
DFRobot Gravity:Digital Push Button (Yellow)
×1
Alphanumeric LCD, 16 x 2
Alphanumeric LCD, 16 x 2
×1

Software apps and online services

ThingSpeak API
ThingSpeak API
Maker service
IFTTT Maker service
Energia
Texas Instruments Energia
Google Sheets
Google Sheets

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Code

Energia code for MSP430

Arduino
Paste this code in Energia IDE and replace the Thingspeak API key and just upload it in your TI board.
#ifndef __CC3100R1M1RGC__
// Do not include SPI for CC3200 LaunchPad
#include <SPI.h>
#endif
#include <WiFi.h>
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(P4_1, P4_2, P3_5, P3_6, P7_0, P6_4);
String apiWritekey = "your API key";                    // replace with your THINGSPEAK WRITEAPI key here
char ssid[] = "awesome"; // your wifi SSID name
char password[] = "awesome12" ;// wifi pasword

char server[] = "api.thingspeak.com";
int val;
int tempPin = P6_5;
float farh;
int Pulse = P6_6;        // Pulse Sensor PURPLE WIRE connected to ANALOG PIN 0
//int LED13 = P1_0;   //  The on-board Arduion LED
int BPM;
int Signal;                // holds the incoming raw data. Signal value can range from 0-1024
int Threshold = 3150;            // Determine which Signal to "count as a beat", and which to ingore.
int button = P1_1;

WiFiClient client;
 
void setup() {
  Serial.begin(115200);
   lcd.begin(16, 2);
   lcd.setCursor(0, 0);
   lcd.print("Patient Monitor");
   delay(2000);
  WiFi.disconnect();
  delay(10);
  WiFi.begin(ssid, password);
 
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
 
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
   lcd.clear();
  lcd.print("connected");
   delay(1000);
//  Serial.println("");
//  Serial.print("connected to wifi...");
//  Serial.println(ssid);
//  Serial.println();
  // pinMode(P1_0, OUTPUT);
   pinMode(P1_1, INPUT_PULLUP); /* Interrupt pin */
   lcd.clear();
 // attachInterrupt(P2_1, tempr, CHANGE);
}
 
void loop() {
 lcd.clear();
  lcd.print("Press Panic butn");
   lcd.setCursor(0, 1);
   lcd.print("in emergency");
   delay(2000);
    lcd.clear();
  val = analogRead(tempPin);
float mv = ( val/4096.0)*5000; 
float cel = mv/10;
float farh = (cel*9)/5 + 32;

 Signal = analogRead(Pulse);  // Read the PulseSensor's value.
BPM = Signal/44;
 lcd.setCursor(0, 0);
  lcd.print("Temp. : ");
 lcd.print(farh);
  lcd.setCursor(0, 1);
  lcd.print("BPM : ");
 lcd.print(BPM);
 //Serial.println(BPM);
// 
//Serial.println("bpm=");  
//Serial.println(BPM);  

if (digitalRead(button) == LOW ){
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("msg sent");
  int action = 1;
   if (client.connect(server,80))
  {  
    String tsData = apiWritekey;
           tsData +="&field3=";
           tsData += String(action);
           tsData += "\r\n\r\n";
 
     client.print("POST /update HTTP/1.1\n");
     client.print("Host: api.thingspeak.com\n");
     client.print("Connection: close\n");
     client.print("X-THINGSPEAKAPIKEY: "+apiWritekey+"\n");
     client.print("Content-Type: application/x-www-form-urlencoded\n");
     client.print("Content-Length: ");
     client.print(tsData.length());
     client.print("\n\n");  // the 2 carriage returns indicate closing of Header fields & starting of data
     client.print(tsData);
     Serial.println("uploaded to Thingspeak server....");
  }
  client.stop();
  
  }
  delay(2000);
 if (client.connect(server,80))
  {  
    String tsData = apiWritekey;
           tsData +="&field1=";
           tsData += String(farh);
           tsData +="&field2=";
           tsData += String(BPM);
          // tsData += "\r\n\r\n";
 
     client.print("POST /update HTTP/1.1\n");
     client.print("Host: api.thingspeak.com\n");
     client.print("Connection: close\n");
     client.print("X-THINGSPEAKAPIKEY: "+apiWritekey+"\n");
     client.print("Content-Type: application/x-www-form-urlencoded\n");
     client.print("Content-Length: ");
     client.print(tsData.length());
     client.print("\n\n");  // the 2 carriage returns indicate closing of Header fields & starting of data
     client.print(tsData);
     Serial.println("uploaded to Thingspeak server....");
  }
  client.stop();
//  Serial.println("Waiting to upload next reading...");
//  Serial.println();
 lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("data uploaded>>");
  delay(10000);
  }

Credits

Rishabh Jain

Rishabh Jain

2 projects • 9 followers
I am a technical blogger. Passionate about new cutting edge technologies.
Thanks to Texas Instruments.

Comments

Add projectSign up / Login