Components and supplies
I2C 16x2 Arduino LCD Display Module
Pushbutton Switch, Pushbutton
Breadboard (generic)
DHT22 Temperature Sensor
Gravity: DS18B20 Temperature Sensor (Arduino Compatible)
NodeMCU ESP8266 Breakout Board
5 mm LED: Red
ProtoCentral Pulse Oximeter & Heart Rate Sensor based on MAX30100
Jumper wires (generic)
Apps and platforms
Arduino IDE
Project description
Code
project code
c_cpp
1#include <ESP8266WiFi.h> 2#include <DHT.h> // Including library for dht 3#include <DallasTemperature.h> //for body temp 4#include <OneWire.h> 5#include <Wire.h> 6#include <LiquidCrystal_I2C.h> 7#define BLYNK_PRINT Serial 8#include <BlynkSimpleEsp8266.h> /// for notfication 9 10 11#include <UniversalTelegramBot.h> // Universal Telegram Bot Library written by Brian Lough: https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot 12#include <ArduinoJson.h> 13 14LiquidCrystal_I2C lcd(0x27,16,2); //0x27 is the i2c address, while 16 = columns, and 2 = rows. 15 16#define USE_ARDUINO_INTERRUPTS true // Set-up low-level interrupts for most acurate BPM math. 17#include <PulseSensorPlayground.h> // Includes the PulseSensorPlayground Library. 18#include <LiquidCrystal.h> 19 20 21 22String apiKey = "AZG3E3KOTX4NH1H1"; // Enter your Write API key from ThingSpeak 23 const char *ssid = "EETD"; // replace with your wifi ssid and wpa2 key 24const char *pass = "passwordattceetd2022*"; 25const char* server = "api.thingspeak.com"; 26char auth[] = "EHAfZjPGLhqktPgP34fxMCAcEqOZ9VDp"; // Enter the Auth Token provied by Blynk app 27 28#define ONE_WIRE_BUS 4 //D2 pin of nodemcu 29OneWire oneWire(ONE_WIRE_BUS); 30DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. 31 32#define ledpin D0 33#define switch D1 // pin where the led is connected 34#define DHTPIN D5 //pin where the dht11 is connected 35DHT dht(DHTPIN, DHT22); 36#define ONE_WIRE_BUS D3 // Data wire is connected to GPIO 4 i.e. D2 pin of nodemcu 37 38int val; 39int PulseSensorpin = A0; //Pulse Sensor Pin Connected at A0 Pin 40 double alpha=0.75; 41 int period=20; 42 double refresh=0.0; 43 44 45 46WiFiClient client; 47 48void setup(void) 49{ 50 Serial.begin(9600); 51 52 53 pinMode(switch,INPUT); //set the pushbutton as input 54 pinMode(ledpin,OUTPUT); //set the led as output 55 Blynk.begin(auth, ssid, pass); 56 Serial.begin(9600); 57 delay(10); 58 59 sensors.begin(); 60 dht.begin(); 61 62 Wire.begin(2,0); // gpio 2 and gpio 0 which are D4, and D3 63 lcd.init(); //Init the LCD 64 lcd.backlight(); //Activate backlight 65 lcd.home(); 66 67 Serial.println("Connecting to "); 68 Serial.println(ssid); 69 70 71 WiFi.begin(ssid, pass); 72 73 while (WiFi.status() != WL_CONNECTED) 74 { 75 delay(500); 76 Serial.print("."); 77 } 78 Serial.println(""); 79 Serial.println("WiFi connected"); 80 81} 82 83void loop(void) 84{ 85 86 87 Blynk.run(); 88if(digitalRead(switch) == HIGH) 89{ 90 digitalWrite(ledpin,HIGH); 91Serial.println("Send Notification to Blynk"); 92Blynk.notify("READY TO SEE PATIENT CONDITION"); // This notification will be sent to Blynk App 93} 94 95 if(dht.readTemperature()<= 26 && sensors.getTempCByIndex(0)<=37){ 96 Blynk.email("eyobmillion425@gmail.com", "Doctor Alert", "You are in good condition!"); 97 } 98 else{Blynk.email("eyobmillion425@gmail.com", "Doctor Alert", "You have to go for more checkups!"); 99 } 100 static double oldValue=0; 101 static double oldrefresh=0; 102 int val = analogRead(PulseSensorpin); //Read Analog values and Store in val variable 103 104 double value=alpha*oldValue+(0-alpha)*val; 105 refresh=value-oldValue; 106 oldValue=value; 107 oldrefresh=refresh; 108 delay(period*10); 109 Serial.println("Pulse Sensorvalue= "); // Start Printing on Pulse sensor value on LCD 110 Serial.println(110-refresh); // Start Printing on Pulse sensor value on LCD 111 delay(10); 112 113 sensors.requestTemperatures(); // Send the command to get temperatures 114 Serial.println("Temperature is: "); 115 Serial.println(sensors.getTempCByIndex(0)); // Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire 116 delay(500); 117 118 float h = dht.readHumidity(); 119 float t = dht.readTemperature(); 120 121 if (isnan(h) || isnan(t)) 122 { 123 Serial.println("Failed to read from DHT sensor!"); 124 return; 125 } 126lcd.setCursor(0, 0); 127lcd.print("Room Temp="); 128lcd.print( dht.readTemperature()); 129 130lcd.setCursor(0, 1); 131lcd.print("Body temp="); 132lcd.print(sensors.getTempCByIndex(0)); 133delay(2000); 134 if (client.connect(server,80)) // "184.106.153.149" or api.thingspeak.com 135 { 136 137 String postStr = apiKey; 138 postStr +="&field1="; 139 postStr += String(sensors.getTempCByIndex(0)); 140 postStr +="&field2="; 141 postStr += String(t); 142 postStr +="&field3="; 143 postStr += String(h); 144 postStr +="&field4="; 145 postStr += String(refresh); 146 postStr += "\ \ 147\ \ 148"; 149 150 client.print("POST /update HTTP/1.1\ 151"); 152 client.print("Host: api.thingspeak.com\ 153"); 154 client.print("Connection: close\ 155"); 156 client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\ 157"); 158 client.print("Content-Type: application/x-www-form-urlencoded\ 159"); 160 client.print("Content-Length: "); 161 client.print(postStr.length()); 162 client.print("\ 163\ 164"); 165 client.print(postStr); 166 167 168 Serial.print("Temperature: "); 169 Serial.print(t); 170 Serial.print(" degrees Celcius, Humidity: "); 171 Serial.print(h); 172 Serial.println("%. Send to Thingspeak."); 173 } 174 client.stop(); 175 176 Serial.println("Waiting..."); 177 178 // thingspeak needs minimum 15 sec delay between updates 179 delay(1000); 180} 181
Downloadable files
schematic
schematic
schematic
schematic
Comments
Only logged in users can leave comments