Monitor Kadar Oksigen dalam Darah (SPO2) ONLINE Thingspeak
Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat mengukur kadar oksigen dalam darah dengan monitor via Thingspeak secara online. jadi komunikasi alat dengan server dengan menggunakan internet. sensor yang dipakai adalah max30100 untuk lebih jelasnya berikut adalah daftar komponen dan programnya.
a. Wemos D1 mini
b. Sensor Max30100
c. LCD + I2C
d. Program Arduino IDE
#include <ThingSpeak.h>
#include <ESP8266WiFi.h>
#include <Wire.h>
#include "MAX30100.h"
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
WiFiClient client;
// ThingSpeak Settings
String apiKey = "56GJDDGKJH56GJF";
const char *ssid = "okok";
const char *pass = "123456789";
const char* server = "api.thingspeak.com";
MAX30100* pulseOxymeter;
int counter;
float Spo;
void setup() {
Wire.begin();
Serial.begin(115200);
lcd.begin();
lcd.clear();
Serial.println("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED){\
pulseOxymeter = new MAX30100();
delay(200);
Serial.println(".");
}
Serial.println("");
Serial.println("WiFi connected");
}
void loop(){
pulseoxymeter_t result = pulseOxymeter->update();
if( result.pulseDetected == true ){
lcd.setCursor(2,0);
lcd.print( "SpO2: " );
lcd.print( result.SaO2);
lcd.println( " % ");
Spo = result.SaO2;
}
counter++;
if(counter > 100){
counter = 0;
if(client.connect(server, 80)){
String postStr= apiKey;
postStr += "&field1=";
postStr += String(Spo);
postStr += "\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: "+apiKey+"\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);
Serial.println(Spo);
Serial.println("%. Send to Thingspeak.");
}
client.stop();
Serial.println("Waiting...");
delay(15000);
}
}
#include <ESP8266WiFi.h>
#include <Wire.h>
#include "MAX30100.h"
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
WiFiClient client;
// ThingSpeak Settings
String apiKey = "56GJDDGKJH56GJF";
const char *ssid = "okok";
const char *pass = "123456789";
const char* server = "api.thingspeak.com";
MAX30100* pulseOxymeter;
int counter;
float Spo;
void setup() {
Wire.begin();
Serial.begin(115200);
lcd.begin();
lcd.clear();
Serial.println("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED){\
pulseOxymeter = new MAX30100();
delay(200);
Serial.println(".");
}
Serial.println("");
Serial.println("WiFi connected");
}
void loop(){
pulseoxymeter_t result = pulseOxymeter->update();
if( result.pulseDetected == true ){
lcd.setCursor(2,0);
lcd.print( "SpO2: " );
lcd.print( result.SaO2);
lcd.println( " % ");
Spo = result.SaO2;
}
counter++;
if(counter > 100){
counter = 0;
if(client.connect(server, 80)){
String postStr= apiKey;
postStr += "&field1=";
postStr += String(Spo);
postStr += "\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: "+apiKey+"\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);
Serial.println(Spo);
Serial.println("%. Send to Thingspeak.");
}
client.stop();
Serial.println("Waiting...");
delay(15000);
}
}
e. Gambar Hasilnya
f. VIDEO HASILNYA
No comments:
Post a Comment