They were initially in SPI Mode. For I2C some soldering has to be done: Move resistor R3 to R1 and bridge R8.
Two IO Pins are sufficient, if Res Pin goes with 100nF to ground and with 10k Resistor to 3.3V.
DC, CS are on ground.
With Micropython on a Wemos d1 mini:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ssd1306 | |
from machine import I2C, Pin | |
i2c = I2C(sda=Pin(4), scl=Pin(5)) | |
display = ssd1306.SSD1306_I2C(64, i2c) | |
display.fill(0) | |
display.text('Hallo',20,20) | |
display.show() |
There is only one small font usable in micropython so I used the very good Adafruit_SSD1306 lib:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SPI.h> | |
#include <Wire.h> | |
#include <Adafruit_GFX.h> | |
#include <Adafruit_SSD1306.h> | |
#include <Fonts/FreeSans24pt7b.h> | |
// No IO Pin for Reset nedded, if oled Res 100nF to ground and 10k to 3.3V | |
#define OLED_RESET -1 | |
Adafruit_SSD1306 display(OLED_RESET); | |
#if (SSD1306_LCDHEIGHT != 64) | |
#error("Height incorrect, please fix Adafruit_SSD1306.h!"); | |
#endif | |
void setup() { | |
Serial.begin(9600); | |
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!) | |
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); | |
// init done | |
// Clear the buffer. | |
display.clearDisplay(); | |
// text display tests | |
display.setTextSize(1); | |
display.setTextColor(WHITE); | |
display.setCursor(0,0); | |
display.println("Hello, world!"); | |
display.setTextSize(1); | |
display.setTextColor(WHITE); | |
display.setFont(&FreeSans24pt7b); | |
display.setCursor(5,32); | |
display.print(" 2:83"); | |
display.display(); | |
} | |
void loop() { | |
} |
No comments:
Post a Comment