Hi everybody! My name is currypuffer, i am trying to send the data of my pulse oximeter via bluetooth and would like some guidance. I need to serial.write the program so that it can send the data via bluetooth from my arduino mega to the arduino uno.
So far i have been trying different methods and have been trying to solve this issue but to no avail. '
I have tried changing the data type such as:
float o2 = pox.getSpO2;
byte oxygen = o2;
( But this has all ended up in the pulse oximeter not working and only producing 0s )
#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
int o2;
int bpm;
float beat;
float breathe;
#define REPORTING_PERIOD_MS 1000
// PulseOximeter is the higher level interface to the sensor
// it offers:
// * beat detection reporting
// * heart rate calculation
// * SpO2 (oxidation level) calculation
PulseOximeter pox;
uint32_t tsLastReport = 0;
// Callback (registered below) fired when a pulse is detected
/*void onBeatDetected()
{
Serial.println("Beat!");
}*/
void setup()
{
Serial.begin(115200);
Serial.print("Initializing pulse oximeter..");
// Initialize the PulseOximeter instance
// Failures are generally due to an improper I2C wiring, missing power supply
// or wrong target chip
if (!pox.begin()) {
Serial.println("FAILED");
for(;;);
} else {
Serial.println("SUCCESS");
}
// The default current for the IR LED is 50mA and it could be changed
// by uncommenting the following line. Check MAX30100_Registers.h for all the
// available options.
// 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();
// Asynchronously dump heart rate and oxidation levels to the serial
// For both, a value of 0 means "invalid"
if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
float beat = pox.getHeartRate();
float breathe = pox.getSpO2();
o2 = (int) breathe;
byte oxygen = o2;
bpm = (int) beat;
byte heart = bpm;
Serial.print(oxygen);
Serial.print(heart);
tsLastReport = millis();
}
}
To start with I'd just get the data from the sensor and print it. If you're getting zeros there's no point playing with bluetooth.
Take a look at the library code: heart rate is indeed returned as a float, but Sp02 is already a byte, no need to mess with it. Just print those two to start with.
I assume the code you post works, if not, get it to work with the serial monitor, or relevant PC terminal.
If you don't already have a Bluetooth module, an HC-05 will suffice for Arduino.
Change the serial begin to 9600. I bet you don't need 115200, but you can configure Bluetooth to that rate later if you do.
Connect a Bluetooth module to the serial pins 0,1 plus power, and you're of and running.
You will need a Bluetooth Terminal on whatever is at the receiving end. If you are currently using a kosher terminal on PC, this will be able to receive through Bluetooth as well.
You might find the following background notes useful.
These notes are pretty thick, but just keep in mind that bluetooth is most probably simpler than you think.