I had a smartwatch project using a MAX30101 sensor and the SPI MicroOLED which worked fine. It was based on the Sparkfun library code, and it runs the Sparkfun code to read the BPM on a software timer every 25 ms, and the OLED screen refreshes every 2 seconds the average BPM. However, I changed the project over to use the same MAX30101 sensor with the Qwiic MicroOLED. Now that both devies are on the I2C, the OLED is having issues. It distorts the output everytime it redraws the screen.
Here is an example
Things I have tried:
I thought perhaps it was an issue with the pullup resistors, so I cut the jumpers on the MAX30101 sensor, but the effect is the same
- I tried slowing down the software timer that reads from the MAX30101, but the OLED still distorts on redrawing (and the slower MAX30101 read affects the BPM calculation
- I tried slowing the OLED redraws, but it still distorts
- I removed the software timer completely, and the screen is fine
I think the MAX30101 reads are interfering when the OLED tries to update since they are both on the I2C bus. I’m not sure how to fix this problem though because the MAX30101 sensor needs to be continuously reading to be effective. Does anyone know way to prevent I2C interference (since I didn’t have this problem with the SPI OLED)?
Thanks!
I forgot to add that I’m using a Particle Argon.
Further update:
The following code is from the Sparkfun library, and I have it on a 25 ms software timer to continually read the BPM
void updateBPM() {
irValue = heartRateSensor.getIR();
if (checkForBeat(irValue) == true) {
// We sensed a beat!
long delta = millis() - lastBeat;
lastBeat = millis();
beatsPerMinute = 60 / (delta / 1000.0);
if (beatsPerMinute < 255 && beatsPerMinute > 20) {
rates[rateSpot++] =
(byte)beatsPerMinute; // Store this reading in the array
rateSpot %= RATE_SIZE; // Wrap variable
}
}
}
If I keep the software timer running but comment out the third line
irValue = heartRateSensor.getIR();
then there is no distortion in the OLED (but obviously the heart rate isn’t calculated).
I think this confirms that the MAX30101 is somehow interfering on the I2C bus with the Qwiic OLED, but I would really appreciate any advice how to fix this so the sensor and the OLED can both work on the I2C bus.