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!