what could be the possible reason why the oled ssd1306 fails to initialze when I connect different I2C device on I2C multiplexer like max30100? the oled works fine on its own when connected to the I2C multiplexer or even when connected directly to the arduino, but when I connect my Max30100 pulse oximeter, the oled fails to initialize. I tried scanning them both with i2c scanner and they are both detected. I also tried connecting pull up resistor on sda and SCL using 5k resistors but the issue still persist. I also tried connecting the i2c devices (oled and pulse oximeter) in parallel without the i2c multiplexer since they both have different addresses, and it still doesn't work.
also, sorry if I got this on wrong category, this is where I am only allowed to post my query. Thank you
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <SparkFun_I2C_Mux_Arduino_Library.h>
#include "MAX30100_PulseOximeter.h"
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define SCREEN_ADDRESS 0x3C
#define MAX30100_ADDRESS 0x57
#define REPORTING_PERIOD_MS 1000
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
QWIICMUX myMux;
PulseOximeter pox;
uint32_t tsLastReport = 0;
void onBeatDetected()
{
Serial.println("Beat!");
}
void setup() {
Serial.begin(9600);
// Initialize I2C and the multiplexer
Wire.begin();
if (!myMux.begin()) {
Serial.println("Failed to initialize Qwiic Mux!");
while (1);
} // Initialize the PulseOximeter instance
myMux.setPort(5); // Select the current channel
delay(100);
// Initialize the OLED display
if(display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println("OLED display initialized on channel ");
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(30, 30);
display.println("Health Monitoring!");
display.display();
delay(2000);
display.clearDisplay();
} else {
Serial.println("Failed to initialize OLED display on channel ");
}
myMux.setPort(0);
if (!pox.begin(MAX30100_ADDRESS)) {
Serial.println("FAILED");
while (1);
} else {
Serial.println("Pulse oximeter initialized successfully");
}
pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);
pox.setOnBeatDetectedCallback(onBeatDetected);
}
void loop() {
// No need for code in the loop for this test
}
It sounds like you are connecting them correctly. Can you post an annotated schematic showing exactly how they are wired. Be sure to show the resistors and all power sources.
Try doing some simple sketches for each device where it is the only one connected. Also be sure the scanner shows them.
Hi, thank you for taking notice. This is how I wired my circuit. The pulse oximeter works fine on its own as well as the oled. but when connected together, it just doesn't work.
You need two more pull up resistors, for the display. I believe the pulse works and the display does not when connected as shown because no pull ups on the display.
Hello everyone, thanks for taking time to help me resolve this issue.
I used a u8x8 lib for the display and used hardware I2C instead of software I2C. someone on different forum figured out that writing data on oled may be the cause. Software i2c requires 400ms to write data as compared to 38ms with hardware I2C. Here's my code for your reference.