Oximeter Max30100 with GY-NEO6MV2, SIM800l Arduino Pro Mini

Hi, I'm currently working with my first Arduino project its sends an SMS with GPS whenever the Oximeter reaches a certain number, I already made the Oximeter Max30100 and SIM800l with GY-NEO6MV2 works (I received a SMS with GPS Coordinates) but only separately and it works fine but when I combined them together, the Oximeters is the only things that works, the data on GPS Module wont show together with the Data of Oximeter in the Serial Monitor meaning the GPS Module cant enter its data together with Oximeter, I already try to change the baud rate of my Serial.begin(); different from mySerial.begin(); (GPS module).

I really hope some body can help me I've been struggling with this problem for weeks and its driving me mad.

#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
#include "U8glib.h"
#include <SoftwareSerial.h>
SoftwareSerial sim800l(10, 11);
#include <SoftwareSerial.h>
#include <TinyGPS.h>
SoftwareSerial mySerial(4, 3);
TinyGPS gps;

#define REPORTING_PERIOD_MS 1000

U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE);
char str[10];
PulseOximeter pox;

uint32_t tsLastReport = 0;

const int buzzer = 13;

String number = "+63xxxxxxx";

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

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

Serial.print("Initializing pulse oximeter..");

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

pox.setOnBeatDetectedCallback(onBeatDetected);
}

void loop()
{
float a = pox.getHeartRate();
float b = pox.getSpO2();

u8g.firstPage();
do {
pox.update();

if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
  Serial.print("Heart rate:");
  Serial.print(pox.getHeartRate());
  Serial.print("bpm / SpO2:");
  Serial.print(pox.getSpO2());
  Serial.println("%");

  tsLastReport = millis();
}

u8g.setFont(u8g_font_helvB08);

u8g.drawStr( 0, 15, "BPM:");
u8g.drawStr( 50, 15, dtostrf(a, 5, 2, str));
u8g.drawStr( 80, 15, "bpm");

u8g.drawStr( 0, 30, "SpO2:");
u8g.drawStr( 50, 30, dtostrf(b, 5, 2, str));
u8g.drawStr( 80, 30, "%");

} while ( u8g.nextPage() );

// here when the oximeter reaches certain number (so i can try)
if ( b <= 98 && a >= 30) {

bool newdata = false;

mySerial.begin(9600);

if (mySerial.available())
{ 
  char c = mySerial.read();   
  mySerial.flush();
  Serial.print(c);        // heres the part where it doesnt work, it only sends partial of the data then it continue to display the oximeter data again
  Serial.flush();
  delay(50);
  
  if (gps.encode(c))
  {
    newdata = true;
  }
} 

if (newdata)
{
  gpsdump(gps);
  Serial.println();
}

}

}

void gpsdump(TinyGPS &gps)
{
long lat, lon;
float flat, flon;
unsigned long age;
gps.f_get_position(&flat, &flon, &age);
Serial.println("Sending SMS...");
sim800l.print("AT+CMGF=1\r");
delay(1000);
sim800l.print("AT+CMGS="" + number + ""\r");
delay(1000);
sim800l.print("Google Maps");
sim800l.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
sim800l.print(",");
sim800l.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
sim800l.print((char)26);
delay(500);
sim800l.println();
Serial.println("Text Sent.");
delay(500000); // for testing only
}

I think you need to post your code so people can have a look at it

1 Like

Thank you, I edit it out

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.