0% found this document useful (0 votes)
2 views

Sensors Code

The document contains two code snippets: one for interfacing with the MAX30100 Pulse Oximeter to measure heart rate and SpO2 levels, and another for connecting to WiFi using an ESP8266 module. The Pulse Oximeter code initializes the sensor, detects beats, and reports BPM and SpO2 every second. The WiFi code sets up the ESP8266, attempts to connect to a specified WiFi network, and indicates connection status through serial output.

Uploaded by

ZeeshaN
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Sensors Code

The document contains two code snippets: one for interfacing with the MAX30100 Pulse Oximeter to measure heart rate and SpO2 levels, and another for connecting to WiFi using an ESP8266 module. The Pulse Oximeter code initializes the sensor, detects beats, and reports BPM and SpO2 every second. The WiFi code sets up the ESP8266, attempts to connect to a specified WiFi network, and indicates connection status through serial output.

Uploaded by

ZeeshaN
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Max30100 code

#include "MAX30100_PulseOximeter.h"

#define REPORTING_PERIOD_MS 1000

PulseOximeter pox;
uint32_t tsLastReport = 0;

void onBeatDetected()
{
Serial.println("Beat!!!");
}

void setup()
{
Serial.begin(115200);

if (!pox.begin()) {
Serial.println("FAILED");
for (;;);
} else {
Serial.println("SUCCESS");
}

pox.setOnBeatDetectedCallback(onBeatDetected);
}

void loop()
{
pox.update();
if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
Serial.print("BPM: ");
Serial.println(pox.getHeartRate());
Serial.print("SpO2: ");
Serial.print(pox.getSpO2());
Serial.println("%");
tsLastReport = millis();
}
}

Wifi code:
#include <SoftwareSerial.h>
#include <stdlib.h>

SoftwareSerial ESP8266(2, 3); // RX, TX


unsigned char check_connection=0;
unsigned char times_check=0;

void setup() {
Serial.begin(115200);
ESP8266.begin(115200);

ESP8266.print("***VER:");
delay(2000);
ESP8266.println("AT+RST");
delay(1000);
ESP8266.println("AT+GMR");
delay(1000);
ESP8266.println("AT+CWMODE=3");
delay(1000);
ESP8266.println("AT+CWLAP");
delay(1000);
}

void loop()
{
Serial.println("Connecting to Wifi");
while(check_connection==0)
{
Serial.print(".");
ESP8266.print("AT+CWJAP=\"Jazz 4G MIFI_7CB3\",\"49811681\"\r\
n");
ESP8266.setTimeout(5000);
if(ESP8266.find("WIFI CONNECTED\r\n")==1)
{
Serial.println("WIFI CONNECTED");
break;
}
times_check++;
if(times_check>3)
{
times_check=0;
Serial.println("Trying to Reconnect..");
}
}

while(1);
}

You might also like