Hi,
I’m trying to run two displays off the ESP32 dev w/OLED. The 128x64 OLED which it’s a part of the board and the 1.2 7-segment LED from Adafruit (Adafruit 1.2 4-Digit 7-Segment Display w/I2C Backpack - Red : ID 1270 : $17.50 : Adafruit Industries, Unique & fun DIY electronics and kits). Both displays use an I2C bus.
The code below works for the OLED display but if I uncomment the line //matrix.begin(0x70); //init 7seg, the OLED stops working.
I tried several combination using the Wire library but just cannot get it right. For some reasons, the two displays cannot work in harmony.
Any help is appreciated.
TIA
#include <Wire.h>
#include <dummy.h> //for esp32
#include "Adafruit_LEDBackpack.h"
#include <Adafruit_GFX.h>
#include "SSD1306Wire.h"
#include "OLEDDisplayUi.h" // Include the UI lib
#define seg_sda 2 //i2c SDA 7 segments
#define oled_scl 4 //SCL OLED
#define oled_sda 5 //SDA OLED
#define seg_scl 15 //i2c SCL 7 segments
Adafruit_7segment matrix = Adafruit_7segment();
SSD1306Wire display(0x3c, oled_sda, oled_scl); //SDA/SCL
OLEDDisplayUi ui (&display);
TwoWire Wire1 = TwoWire(1);
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println("Setup start...");
Wire.begin(seg_sda, seg_scl);
Wire1.begin(oled_sda, oled_scl);
//matrix.begin(0x70); //init 7seg display
//init OLED
display.init();
display.flipScreenVertically();
display.setFont(ArialMT_Plain_10);
matrix .clear(); //clear display
display.clear(); //clear display
Serial.println("Setup end...");
}
void loop() {
// 7 seg display
matrix .clear(); //clear display
matrix.print(0xBEEF, HEX);
matrix.writeDisplay();
delay(1000);
// OLED
display.clear(); //clear display
display.setFont(ArialMT_Plain_10); // Text alignment demo
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawString(0, 10, "Left aligned (0,10)");
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.drawString(64, 22, "Center aligned (64,22)");
display.setTextAlignment(TEXT_ALIGN_RIGHT);
display.drawString(128, 33, "Right aligned (128,33)");
display.display();
Serial.println("In loop...");
delay(1000);
}