ESP32 und OLED Display

OP #6324491
Lesenswert?

Hallo zusammen,

ich habe an meinem ESP32 Dev Kit C von AZ ein Oled 1,3" angeschlossen 
mit 128x64. Programmieren tue ich per PlatformIO und bekomme zwar eine 
Verbindung zum Display, kann aber ein einfaches Hello World nicht 
darstellen. Das Display bleibt dunkel. Wenn ich den i2c scanne, sehe ich 
die Adresse 3c. Ich kann auch den Cursor setzten und zurück lesen.

Hat jemand einen Tipp??
1
#include <Arduino.h>
2
#include <Wire.h>
3
#include <Adafruit_SSD1306.h>
4

5
#define SCREEN_WIDTH 128
6
#define SCREEN_HEIGHT 64
7
#define OLED_RESET -1
8
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
9
void scan_wire(TwoWire *wire);
10

11
    void setup()
12
{
13
  delay(100);
14
  Serial.begin(115200);
15
  Wire.begin(-1,-1,100000);
16
  scan_wire(&Wire);
17
  display.begin(SSD1306_SWITCHCAPVCC,0x3c);
18

19
  display.clearDisplay();
20
  display.setTextColor(SSD1306_WHITE);
21
  display.print("Hello World");
22
 // display.display();
23
  
24
  // put your setup code here, to run once:
25
}
26

27
void loop(){
28
    // put your main code here, to run repeatedly:
29
} 
30

31
    void scan_wire(TwoWire *wire)
32
{
33
  uint8_t device_count = 0;
34
  for (uint8_t i = 0; i <= 128; i++)
35
  {
36
    wire->beginTransmission(i);
37
    uint8_t res = wire->endTransmission();
38
    if (res == 0)
39
    {
40
      Serial.print("0x");
41
      if (i < 16)
42
      {
43
        Serial.print('0');
44
      }
45
      Serial.print(i, HEX);
46
      device_count++;
47
    }
48
    else
49
    {
50
      Serial.print("..");
51
    }
52
  }
53
  Serial.println("");
54
  Serial.print("devicecount: ");
55
  Serial.println(device_count);
56
}
Die Ausgabe des Scans auf dem I2C liefert folgende Ergebnisse:
........................................................................ 
................................................0x3C.................... 
..0x48.................................................................. 
........................0x76..................0x80
devicecount: 4

Vielen Dank vorab!
#6324579
Lesenswert?

Johannes S. schrieb:
> das alte Standard Adressproblem? (0x3C << 1) verwenden?

bin auch gerade wieder darauf reingefallen, beim Scan der PCF8574A der 
hat ja 3 Adressbits ist folgendes möglich:
        case 0x70:
        case 0x72:
        case 0x74:
        case 0x76:
        case 0x78:
          #pragma message"I2C SCAN: 0x78 -> I2C_OLED || 
I2C_TASTATUR_8574A"
        case 0x7A:
        case 0x7C:
        case 0x7E:
       #ifdef I2C_TASTATUR_8574A
          //i2c_test_flags|=(1<<I2C_TASTATUR);
          i2c_test_flags|=(1<<I2C_TASTATUR_8574A);
Gast #6324605
Lesenswert?

Du musst die Funktion
1
display.display();
benutzen, um die erzeugte Grafik an das Display zu senden.

display.print("Hello World") erzuegt nur eine Grafik im Pufferspeicher, 
ohne sie an das Display zu senden.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren