Skip to main content
deleted 11 characters in body; edited title
Source Link
Michel Keijzers
  • 13k
  • 7
  • 42
  • 59

same Same output on displays with different i2cI2C-addresses (adafruitAdaFruit library, esp32ESP32)

I've got two displays hooked up to a esp32ESP32 via i2cI2C and I'm using the adafruitAdaFruit library. EverythingAll handling display output is packed in a own library. As I was testing I only had one display set up and everything looked fine. Now, in my actual setup with two displays, I only get the output of the first display on both screens. The displays are running on the same i2cI2C-bus, different addresses are set. I also ran a address/portscanner that confirmed the different addresses (0x3C and 0x3D).

I have used separate displays with the adafruitAdaFruit library in such a setup before, but only on an arduinoArduino uno and without having code moved to own libraries. So I can't tell if the esp32ESP32 or having multiple files is messing things up or I'm missing something.

I didn't post the complete code or the header file, because it exceeds a few hundred lines. But this should show how the i2cI2C-addresses are used. If necessary, I of course can post the rest of the code.

My next approach would be either trying the U8g2 library or trying start a second i2cI2C bus. Since I already have a finisherdfinished circuit board, so this would be my least preferred option.

same output on displays with different i2c-addresses (adafruit library, esp32)

I've got two displays hooked up to a esp32 via i2c and I'm using the adafruit library. Everything handling display output is packed in a own library. As I was testing I only had one display set up and everything looked fine. Now, in my actual setup with two displays, I only get the output of the first display on both screens. The displays are running on the same i2c-bus, different addresses are set. I also ran a address/portscanner that confirmed the different addresses (0x3C and 0x3D).

I have used separate displays with the adafruit library in such a setup before, but only on an arduino uno and without having code moved to own libraries. So I can't tell if the esp32 or having multiple files is messing things up or I'm missing something.

I didn't post the complete code or the header file, because it exceeds a few hundred lines. But this should show how the i2c-addresses are used. If necessary I of course can post the rest of the code.

My next approach would be either trying the U8g2 library or trying start a second i2c bus. Since I already have a finisherd circuit board, so this would be my least preferred option.

Same output on displays with different I2C-addresses (AdaFruit library, ESP32)

I've got two displays hooked up to a ESP32 via I2C and I'm using the AdaFruit library. All handling display output is packed in a own library. As I was testing I only had one display set up and everything looked fine. Now, in my actual setup with two displays, I only get the output of the first display on both screens. The displays are running on the same I2C-bus, different addresses are set. I also ran a address/portscanner that confirmed the different addresses (0x3C and 0x3D).

I have used separate displays with the AdaFruit library in such a setup before, but only on an Arduino uno and without having code moved to own libraries. So I can't tell if the ESP32 or having multiple files is messing things up or I'm missing something.

I didn't post the complete code or the header file, because it exceeds a few hundred lines. But this should show how the I2C-addresses are used. If necessary, I of course can post the rest of the code.

My next approach would be either trying the U8g2 library or trying start a second I2C bus. Since I already have a finished circuit board, so this would be my least preferred option.

Source Link

same output on displays with different i2c-addresses (adafruit library, esp32)

I've got two displays hooked up to a esp32 via i2c and I'm using the adafruit library. Everything handling display output is packed in a own library. As I was testing I only had one display set up and everything looked fine. Now, in my actual setup with two displays, I only get the output of the first display on both screens. The displays are running on the same i2c-bus, different addresses are set. I also ran a address/portscanner that confirmed the different addresses (0x3C and 0x3D).

I have used separate displays with the adafruit library in such a setup before, but only on an arduino uno and without having code moved to own libraries. So I can't tell if the esp32 or having multiple files is messing things up or I'm missing something.

Here are parts of code in the cpp-file I used to initialize the displays and some functions I call:

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Wire.h>
#include <gfxfont.h>
#include <SPI.h>
#include "DisplayOut.h"
#include "Game.h"


    /* -------------esp32 Pin setup --------------------- */
    const byte displayData = 21;    // I2C SDA
    const byte displayClock = 23;   // I2C SCL
    /* --------------------------------------------------- */

// Define OLED
#define OLED_RESET displayData  
Adafruit_SSD1306 display1(OLED_RESET);
Adafruit_SSD1306 display2(OLED_RESET);



/* some variables */


void DisplayOutClass::init()
{
    // Initialize each display with i2c-address
    
    display1.begin(SSD1306_SWITCHCAPVCC, 0x3C);
    display2.begin(SSD1306_SWITCHCAPVCC, 0x3D);
    display1.setTextWrap(false);
    display2.setTextWrap(false);
}



void DisplayOutClass::scorePlayer1(int score1)
{
    display1.clearDisplay();

    if (gameMode == 2)
    {
        display1.clearDisplay();
        display1.setCursor(0, 0);
        display1.setTextSize(2);
        display1.setTextColor(WHITE);
        display1.print(playerName[player1]);
    }

    display1.setTextSize(4);
    display1.setTextColor(WHITE);
    display1.setCursor(getCenteredPosX(3, String(score1)), 24);
    display1.print(score1);
}

void DisplayOutClass::scorePlayer2(int score2)
{
    display2.clearDisplay();

    if (gameMode == 2)
    {
        display2.clearDisplay();
        display2.setCursor(0, 0);
        display2.setTextSize(2);
        display2.setTextColor(WHITE);
        display2.print(playerName[player2]);
    }

    display2.setTextSize(4);
    display2.setTextColor(WHITE);
    display2.setCursor(getCenteredPosX(3, String(score2)), 24);
    display2.print(score2);
}



/* some more Functions */


DisplayOutClass DisplayOut;

I didn't post the complete code or the header file, because it exceeds a few hundred lines. But this should show how the i2c-addresses are used. If necessary I of course can post the rest of the code.

My next approach would be either trying the U8g2 library or trying start a second i2c bus. Since I already have a finisherd circuit board, so this would be my least preferred option.