Dr. Aghosh B Prasad
Published © GPL3+

Get Notified by Email and SMS When Your Pulse Is Abnormal

Using a pulse sensor + Arduino + Bolt IoT Platform, build your own pulse monitoring system which notifies you when abnormality is detected.

IntermediateFull instructions provided3 hours17,425
Get Notified by Email and SMS When Your Pulse Is Abnormal

Things used in this project

Hardware components

Heartbeat Measuring Sensor Module
×1
Arduino Mega 2560
Arduino Mega 2560
×1
Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Jumper wires (generic)
Jumper wires (generic)
×7

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
DigitalOcean
VPS service to run the code for heart rate monitoring.
Mailgun
Email automation service
SMS Messaging API
Twilio SMS Messaging API

Story

Read more

Schematics

Schematic of all hardware connections.

Make connections as shown in this schematic

Code

Arduino code

Arduino
Code for calculating pulse value.
unsigned long highCounter = 0;
int pulse = 0;
int val = 0;
int lastPulse = LOW;
unsigned long oldMillis = 0;
  
void setup() {
 pinMode(2, INPUT);
 Serial.begin(9600);
 }
  
void loop() {
pulse = digitalRead(2);
if (pulse != lastPulse) {
  lastPulse = pulse;
  if (pulse == HIGH) highCounter++;
} 
  
// print and reset highCounter every seconds
if ( millis() - oldMillis >= 10000 )
{
  oldMillis = millis();
  val = highCounter * 6;
  if (highCounter > 1) 
  Serial.println(val);
  highCounter = 0;
}
}

conf.py

Python
Code containing API keys and other credentials for using Bolt, MailGun and Twilio
#Credentials from Twilio
SID = 'You can find SID in your Twilio Dashboard' 
AUTH_TOKEN = 'You can find  on your Twilio Dashboard' 
FROM_NUMBER = 'This is the no. generated by Twilio. You can find this on your Twilio Dashboard'
TO_NUMBER = 'This is your number. Make sure you are adding +91 in beginning'

#Credentials from Mailgun
MAILGUN_API_KEY = 'This is the private API key which you can find on your Mailgun Dashboard' 
SANDBOX_URL= 'You can find this on your Mailgun Dashboard' 
SENDER_EMAIL = 'This would be test@your SANDBOX_URL'
RECIPIENT_EMAIL = 'Enter your Email ID Here'

#Credentials from Bolt
API_KEY = 'This is your Bolt Cloud accout API key'
DEVICE_ID = 'This is the ID of your Bolt device'

heart_rate.py

Python
Code to collect pulse value and check anomaly
import conf, json, time
from boltiot import Email, Bolt
from boltiot import Sms, Bolt
minimum_limit = 57 #the minimum threshold of heart rate
maximum_limit = 100 #the maximum threshold of heart rate
mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
mailer = Email(conf.MAILGUN_API_KEY, conf.SANDBOX_URL, conf.SENDER_EMAIL, conf.RECIPIENT_EMAIL)
sms = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
while True:
   response = mybolt.serialRead(2)
   data = json.loads(response)
   sensor_value = data['value']
   try:
       sensor_value = data['value']
       if sensor_value > maximum_limit or sensor_value < minimum_limit:
           response = mailer.send_email("Alert", "The Current Heart Rate is " +str(sensor_value))
           response = sms.send_sms("Alert! The Current Heart Rate is " +str(sensor_value))
   except Exception as e:
       print ()
   time.sleep(10)

Credits

Dr. Aghosh B Prasad

Dr. Aghosh B Prasad

1 project • 14 followers
Doctor, Innovator, Researcher, Designer, Developer exploring ways to develop medicine & technology for better healthcare and social welfare.

Comments