In this example we look at another terrific little low cost shield for the Wemos mini, this time its the OLED shield. Lets look at the shield and some specs
- Screen Size: 64×48 pixels (0.66” Across)
- Operating Voltage: 3.3V
- Driver IC: SSD1306
- Interface: IIC(I2C)
- IIC Address: 0x3C or 0x3D
The shield uses the I2C pins, so you can still connect another I2C device (if it uses a different address) and the other pins are available
D1 mini | Shield |
D1 | SCL |
D2 | SDA |
Code
You will need to add the https://github.com/mcauser/Adafruit_SSD1306 library
The following code example is a simple hello world type example
[codesyntax lang=”cpp”]
#include <SPI.h> #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> // SCL GPIO5 // SDA GPIO4 #define OLED_RESET 0 // GPIO0 Adafruit_SSD1306 display(OLED_RESET); #define NUMFLAKES 10 #define XPOS 0 #define YPOS 1 #define DELTAY 2 #define LOGO16_GLCD_HEIGHT 16 #define LOGO16_GLCD_WIDTH 16 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); // initialize with the I2C addr 0x3C (for the 64x48) // init done display.display(); delay(2000); // Clear the buffer. display.clearDisplay(); // text display tests display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(0,0); display.println("Hello, world!"); display.display(); delay(2000); display.clearDisplay(); } void loop() { }
[/codesyntax]
Links
OLED Shield for WeMos D1 mini 0.66″ inch 64X48 IIC I2C Compatible
Here’s what I had to do to see anything on the screen. (0,0) is too high and too far left
// text display tests
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(32,20);
display.println(“Hello, world!”);
display.display();
// text display tests
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(31,8);
display.println(“123456789AB”);
display.setCursor(31,16);
display.println(“123456789AB”);
display.setCursor(31,24);
display.println(“123456789AB”);
display.display();
delay(2000);
display.clearDisplay();
Thanks Mike Morrow, you are right!
@Mike Morrow. It’s because the Adafruit library isn’t designed for 64*48 displays. A forked version will likely work. It’s just finding one that is the problem. There are 326 forks… of varying quality!
[…] Pantalla Oled: http://www.esp8266learning.com/wemos-oled-shield-example.php […]
you also need “Adafruit GFX Library” not only Adafruit_SSD1306
[…] Ici, je bosse avec ce type de matériel : http://www.esp8266learning.com/wemos-oled-shield-example.php […]