This is the 1.3 inch OLED Display driven by SH1106 from Waveshare, 128×64 resolution, it has integrated 3 interface the 3 wire SPI, 4 wire SPI, and i2C for ease integration in your microcontroller. This OLED is mainly runs by SH1106 a single chip CMOS OLED/PLED for organic polymer light emitting diode dot-matrix graphic display system.
SH1106 it has 132 segments, 64 commons that can support a maximum display resolution of 132 X 64 and designated for common cathode type OLED panel. SH1106 has integrated contract control, display RAM oscillator and efficient DC to DC converter, which reduce the number of external components and power consumption.
SH1106 is suitable for wide range compact portable applications such as sud-display for mobile devices, mp3 players, calculators, home appliances, automotive, industrial machineries. The diagram below shows two options to wire the OLED display see the diagram for SPI and i2C note: this modules are soldered as 4 SPI interface for i2c see the datasheet or diagram for soldering the required connection to enable the interface.
Required Components
- Arduino Microcontroller, NodeMCU, Teensy Board, TeensyDuino, ESP8266 12, 12E, ESP8266 NodeMCU, ESPDuino, ATMEGA328 16/12, ATMEGA32u4 16/8/ MHz, ESP8266, ATMEGA250 16 MHz, ATSAM3x8E, ATSAM21D, ATTINY85 16/8 MHz (Note: The Diagram below is using NANO. (please refer to the respective pin-outs)
- 1.3″ OLED Display Monochrome Module from Waveshare
- Jumper Wires / DuPont Wires
- Solder Less Bread Board
Wiring Guide for SPI
Wiring Guide for i2C
Source Code 3 Wire – 4 Wire SPI
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
#include "U8glib.h" // U8glib library for the OLED you download below #include <Wire.h> // Set Wire library for I2C communication //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); //set i2C Interface void draw(void) { u8g.setFont(u8g_font_profont15r); // Set display font 1 u8g.drawStr(1, 12, "14CORE |i2C TEST CODE");// u8g.setFont(u8g_font_profont29r); // Set display font 2 u8g.println("Line 1 i2C OLED"); u8g.setPrintPos(35, 45); // set print position 35, 45 u8g.println("Line 2 i2C OLED"); u8g.drawRFrame(15, 20, 100, 30, 10); // Set to draws frame with rounded edges } void setup(void) { Serial.begin(9600); Serial.print("14CORE | Test for Waveshare 4 Wire | 3 Wire | I2C OLED Display Module"); Serial.print("---------------------------------------------------------------------"); delay(1000); //Set delay 1 Second } void loop(void) { u8g.firstPage(); do { draw(); } while( u8g.nextPage() ); delay(1000); //Set delay 1 second } |
Source Code i2C (Two Wire Interface)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
#include "U8glib.h" // U8glib library for the OLED you download below #include <Wire.h> // Set Wire library for I2C communication U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9, 8); // D0=13, D1=11, CS=10, DC=9, Reset=8 void draw(void) { u8g.setFont(u8g_font_profont15r); // Set display font 1 u8g.drawStr(1, 12, "14CORE |i2C TEST CODE");// u8g.setFont(u8g_font_profont29r); // Set display font 2 u8g.println("Line 1 i2C OLED"); u8g.setPrintPos(35, 45); // set print position u8g.println("Line 2 i2C OLED"); u8g.drawRFrame(15, 20, 100, 30, 10); // Set to draws frame with rounded edges } void setup(void) { Serial.begin(9600); Serial.print("14CORE | Test for Waveshare 4 Wire | 3 Wire | I2C OLED Display Module"); Serial.print("---------------------------------------------------------------------"); delay(1000); //Set delay 1 Second } void loop(void) { u8g.firstPage(); do { draw(); } while( u8g.nextPage() ); delay(1000); //Set delay 1 second } |
Downloads
Download Waveshare 1.3″ OLED Display Configuration Guide | PDF
Download Waveshare 1.3″ OLED Display Schematics | PDF
Download SPI, i2C u8glib Code Lbrary for Arduino | Version 1.14 | Version 1.17 |
Download SH1106 132 X 34 Matrix OLED/PLED Segment/Common Driver Datasheet | PDF
You have reversed the constructor code for each sample. You have the SPI constructor in the I2C example and vice versa.
Pingback:Point to Point / Server & Client Setup on ESP8266 & MCP9808 Temp Sensor | 14core.com
Oh my god. You save my live. Thank you so much
I did it
Pingback:Wiring SENSERION SCD30 CO2 Sensor in ESP32 TFT Display | 14core.com