0% found this document useful (0 votes)
8 views2 pages

Node Mcu

This document defines constants and variables for connecting a pulse oximeter sensor to Blynk via WiFi. It initializes the pulse oximeter sensor, registers a callback function to detect heartbeats, and sends oxygen level readings to the Blynk virtual pin V4 every second. It also parses incoming serial data and sends substrings to different virtual pins on Blynk.

Uploaded by

s6837971
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Node Mcu

This document defines constants and variables for connecting a pulse oximeter sensor to Blynk via WiFi. It initializes the pulse oximeter sensor, registers a callback function to detect heartbeats, and sends oxygen level readings to the Blynk virtual pin V4 every second. It also parses incoming serial data and sends substrings to different virtual pins on Blynk.

Uploaded by

s6837971
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#define BLYNK_TEMPLATE_ID "TMPL3qzhkvmsO"

#define BLYNK_TEMPLATE_NAME "worker helmet"


#define BLYNK_AUTH_TOKEN "Nl7kaVRgn5VfR80hfJJAfC5aOhuX3_32"
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
#define REPORTING_PERIOD_MS 1000
PulseOximeter pox;
float oxy;
uint32_t tsLastReport = 0;
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "water"; // Enter your WiFi Username
char pass[] = "123456789"; // Enter your WiFi password

int a;
int b;
int c;
int d;
BlynkTimer timer;

void myTimer() {
// Blynk.virtualWrite(V0, a);
// Blynk.virtualWrite(V1, b);
// Blynk.virtualWrite(V2, c);
// Blynk.virtualWrite(V3, d);
}
void onBeatDetected() {
// Serial.println("Beat!");
}

void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
timer.setInterval(1000L, myTimer);

if (!pox.begin()) {
// Serial.println("FAILED");
for (;;)
;
} else {
//Serial.println("SUCCESS");
//digitalWrite(1,HIGH);
}
pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);

// Register a callback for the beat detection


pox.setOnBeatDetectedCallback(onBeatDetected);
}

void loop() {

// Make sure to call update as fast as possible


pox.update();
if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
oxy = pox.getSpO2();
Serial.print(" OXYGEN ");
Serial.println(oxy);
delay(1000);
// Serial.println("%");
tsLastReport = millis();
Blynk.virtualWrite(V4,oxy);
}
while (Serial.available() > 0) {
char receivedChar = Serial.read();
if (receivedChar == 'a') {
// Full string received
String str = Serial.readString();
String a = str.substring(0, 2);
Serial.print("a:");
Serial.println(a);
String b = str.substring(3, 5);
Serial.print("b:");
Serial.println(b);
String c = str.substring(6, 9);
Serial.print("c:");
Serial.println(c);
String d = str.substring(10, 13);
Serial.print("d:");
Serial.println(d);

// Send the values to Blynk


Blynk.virtualWrite(V0, a);
Blynk.virtualWrite(V1, b);
Blynk.virtualWrite(V2, c);
Blynk.virtualWrite(V3, d);

}
}

Blynk.run();
timer.run();
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy