Need help porting the Jeelabs Pulse SPO2 sensor library (SI1143 library)

Hi all,

I’m working on a project with a SPO2 sensor from Mordern DevicesLinked here and it’s pretty functional on an Arduino and uses the software I2C. I’ve been stuck for days trying to port it to my photon.Full disclosure, I’m a noobie to firware dev and programming and I mainly work on the HW side of things so please bear with me :slight_smile: .

I tried uploading the program along with library files from Particle Dev on Windows, Here’s a link to the library.
First it threw me an error saying ‘Wprogram.h’ does not exist as I had aldready encountered this error I removed it SI114.h file along ‘Arduino.h’ , ‘avr/pgmspace.h’, ‘avr/pgmspace.h’, ‘util/atomic.h’ and compiled again. Now I got a boat load of errors like ‘pinMode’’ was not declared in scope and similar errors for some core functions like ‘digitalRead’ ‘digitalWrite’. After some quick google search I added a #include “application.h” to SI114.h file.

Now however I’m faced with a lines of errors like this,

I’m clueless now and I have no idea on how to proceed can anyone please help me out with porting this?
We’re working on connected pulse ox sensors for children in rural villages.

In the Particle world pinMode() expects a second parameter of type PinMode, but you are providing a uint8_t.

So you could either change the function signature to inline void mode(PinMode value) or use a cast inside the function.
But you might still need to do some more code cleanup, since Particle has some other pin modes than Arduinog (e.g. INPUT_PULLUP vs INPUT in conjunction with digitalWrite(HIGH) to attach the pull-up).

Thanks for the quick reply, What should I do about the digiPin(), digiPin2() part?
Can you also tell me what other fixes I should attempt?

Thanks again

digPin() and digPin2() seem to return the SDA respectively SCL pins for a given port, but on the Photon there is only one SDA pin (D0) and one SCL pin (D1).
so you could add something like this

#if defined(SPARK)
    inline uint8_t digiPin() const
        { return D0; }
    inline uint8_t digiPin2() const
        { return D1; }
    static uint8_t digiPin3()
        { return D2; }
    inline uint8_t anaPin() const
    { return A0; }
#elif defined(__AVR_ATtiny85__)
// was before #if defined(__AVR_ATtiny85__)

Will give it a shot, Thanks again!