Devices & Components
Arduino Uno Rev3
Jumper wires (generic)
Solderless Breadboard Half Size
RGB LCD Shield Kit, 16x2 Character Display
9V battery (generic)
ESP8266 ESP-01
ProtoCentral Pulse Oximeter & Heart Rate Sensor based on MAX30100
Rotary Potentiometer, 10 kohm
Gravity: Analog LM35 Temperature Sensor For Arduino
Software & Tools
ThingSpeak API
Arduino IDE
Project description
Code
Code for Esp 8266
arduino
1#include "ThingSpeak.h" 2#include <ESP8266WiFi.h> 3 4//------- WI-FI details ----------// 5char ssid[] = "XXXXXXXXXXX"; // SSID here 6char pass[] = "YYYYYYYYYYY"; // Passowrd here 7//--------------------------------// 8 9//----------- Channel details ----------------// 10unsigned long Channel_ID = 123456; // Channel ID 11const char * myWriteAPIKey = "ABCDEFG1234"; //Your write API key 12//-------------------------------------------// 13 14const int Field_Number_1 = 1; 15const int Field_Number_2 = 2; 16String value = ""; 17int value_1 = 0, value_2 = 0; 18int x, y; 19WiFiClient client; 20 21void setup() 22{ 23 Serial.begin(115200); 24 WiFi.mode(WIFI_STA); 25 ThingSpeak.begin(client); 26 internet(); 27} 28 29void loop() 30{ 31 internet(); 32 if (Serial.available() > 0) 33 { 34 delay(100); 35 while (Serial.available() > 0) 36 { 37 value = Serial.readString(); 38 if (value[0] == '*') 39 { 40 if (value[5] == '#') 41 { 42 value_1 = ((value[1] - 0x30) * 10 + (value[2] - 0x30)); 43 value_2 = ((value[3] - 0x30) * 10 + (value[4] - 0x30)); 44 } 45 else if (value[6] == '#') 46 { 47 value_1 = ((value[1] - 0x30) * 100 + (value[2] - 0x30) * 10 + (value[3] - 0x30)); 48 value_2 = ((value[4] - 0x30) * 10 + (value[5] - 0x30)); 49 } 50 } 51 } 52 } 53 upload(); 54} 55 56void internet() 57{ 58 if (WiFi.status() != WL_CONNECTED) 59 { 60 while (WiFi.status() != WL_CONNECTED) 61 { 62 WiFi.begin(ssid, pass); 63 delay(5000); 64 } 65 } 66} 67 68void upload() 69{ 70 ThingSpeak.writeField(Channel_ID, Field_Number_1, value_1, myWriteAPIKey); 71 delay(15000); 72 ThingSpeak.writeField(Channel_ID, Field_Number_2, value_2, myWriteAPIKey); 73 delay(15000); 74 value = ""; 75}
Code for Arduino
arduino
1#include <LiquidCrystal.h> 2#include <SoftwareSerial.h> 3#include <OneWire.h> 4#include <DallasTemperature.h> 5#define USE_ARDUINO_INTERRUPTS true 6#include <PulseSensorPlayground.h> 7SoftwareSerial esp(10, 11); 8LiquidCrystal lcd(7, 6, 5, 4, 3, 2); 9#define ONE_WIRE_BUS 9 10#define TEMPERATURE_PRECISION 12 11OneWire oneWire(ONE_WIRE_BUS); 12DallasTemperature sensors(&oneWire); 13DeviceAddress tempDeviceAddress; 14int numberOfDevices, temp, buzzer = 8; 15const int PulseWire = A0; 16int myBPM, Threshold = 550; 17PulseSensorPlayground pulseSensor; 18unsigned long previousMillis = 0; 19const long interval = 5000; 20void setup() 21{ 22 lcd.begin(16, 2); 23 Serial.begin(9600); 24 esp.begin(115200); 25 sensors.begin(); 26 numberOfDevices = sensors.getDeviceCount(); 27 pulseSensor.analogInput(PulseWire); 28 pulseSensor.setThreshold(Threshold); 29 pulseSensor.begin(); 30 pinMode(buzzer, OUTPUT); 31 digitalWrite(buzzer, HIGH); 32 lcd.setCursor(0, 0); 33 lcd.print(" IoT Patient"); 34 lcd.setCursor(0, 1); 35 lcd.print(" Monitor System"); 36 delay(1500); 37 digitalWrite(buzzer, LOW); 38 lcd.clear(); 39} 40 41void loop() 42{ 43 myBPM = pulseSensor.getBeatsPerMinute(); 44 if (pulseSensor.sawStartOfBeat()) 45 { 46 beep(); 47 lcd.setCursor(0, 1); 48 lcd.print("HEART:"); 49 lcd.print(myBPM); 50 lcd.setCursor(9, 1); 51 lcd.print(" BPM"); 52 delay(20); 53 } 54 sensors.requestTemperatures(); 55 for (int i = 0; i < numberOfDevices; i++) 56 { 57 if (sensors.getAddress(tempDeviceAddress, i)) 58 { 59 temp = printTemperature(tempDeviceAddress); 60 lcd.setCursor(0, 0); 61 lcd.print("BODY:"); 62 lcd.print(temp); 63 lcd.print(" *C"); 64 } 65 } 66 upload(); 67} 68 69int printTemperature(DeviceAddress deviceAddress) 70{ 71 int tempC = sensors.getTempC(deviceAddress); 72 return tempC; 73} 74 75void beep() 76{ 77 digitalWrite(buzzer, HIGH); 78 delay(150); 79 digitalWrite(buzzer, LOW); 80} 81 82void upload() 83{ 84 unsigned long currentMillis = millis(); 85 if (currentMillis - previousMillis >= interval) 86 { 87 previousMillis = currentMillis; 88 esp.print('*'); 89 esp.print(myBPM); 90 esp.print(temp); 91 esp.println('#'); 92 } 93}
Downloadable files
IoT based health monitoring system | Arduino Project
IoT based health monitoring system | Arduino Project

Comments
Only logged in users can leave comments