I am trying to use a Protocentral_MAX30102 Pulse Ox sensor to get SpO2 and serial write it to an SD logger. However, my serial write is a mess and I need is in a text form not what it is in now. I would live to write a CSV for to my SD card logger.

This is the stock code.

#include "Protocentral_MAX30102.h"
#include <Wire.h>

MAX30100 sensor;  //attach sensor
uint8_t data_len=8;      
uint8_t DataPacketHeader[15];
volatile unsigned int IRR,REDD;

void setup() {
  sensor.begin(pw1600, i50, sr100 );

void loop() {
    sensor.readSensor();        //read sensor
    DataPacketHeader[0] = 0x0A;
    DataPacketHeader[1] = 0xFA;Uni
    DataPacketHeader[2] = (uint8_t) (data_len);
    DataPacketHeader[3] = (uint8_t) (data_len>>8);
    DataPacketHeader[4] = 0x02;

    DataPacketHeader[5] = REDD;
    DataPacketHeader[6] = REDD>>8;
    DataPacketHeader[7] = REDD>>16;
    DataPacketHeader[8] = REDD>>24; 

    DataPacketHeader[9] = IRR;
    DataPacketHeader[10] = IRR>>8;
    DataPacketHeader[11] = IRR>>16;
    DataPacketHeader[12] = IRR>>24; 

    DataPacketHeader[13] = 0x00;
    DataPacketHeader[14] = 0x0b;

    for(int i=0; i<15; i++) // transmit the data


  • You first need to define how your string looks like, and than convert each value to a string (or text characters you place/append in a character array). – Michel Keijzers Oct 29 at 15:29
  • 2
    You currently create binary data. Why? You want text, so just Serial.print() the data directly. – chrisl Oct 29 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.