The 1.5” & 2.42” oled display module for Arduino, it’s interface is 20 pins, the interface definition is as below, we would introduce how to use it in Arduino in hardware connection and software initialized code:
Power Pins
Signal Pins
Remaining Pins
· These modules can be used in SPI or 8-Bit mode. Somewhat annoyingly, the only way to switch modes is to desolder/solder jumpers on the back of the modules.
· This is the mode you likely want to be in. Your module may have come with this setting by default.
· On the 1.5" OLED display module: Make sure the R12 and R10 resistors are soldered in and the R11 and R9 spots are blank
· On the 2.4" OLED module: Make sure the R19 and R21 resistors are soldered in and the R18 and R20 spots are blank
· On the 1.5" OLED module: Make sure the R12 and R9 resistors are soldered in and the R11 and R10 spots are blank
· On the 2.4" OLED module: Make sure the R18 and R21 resistors are soldered in and the R19 and R20 spots are blank
· This mode uses 8 pins + 4 or 5 control pins. We dont have support code for it but you could modify the library if you like to add it. Check the datasheet for more details!
· On the 1.5" OLED module: Make sure the R11 and R10 resistors are soldered in and the R12 and R9 spots are blank
· On the 2.4" OLED module: Make sure the R19 and R20 resistors are soldered in and the R18 and R21 spots are blank
We will demonstrate using this display with an Arduino UNO compatible. If you are using a 3V logic device you can skip the level shifter and connect direct from the microcontroller to display. You can also use another kind of level shifter if you like.
Any microcontroller with I2C + 1 pin or 4 or 5 pins can be used, but we recommend testing it out with an UNO before you try a different processor.
Don't forget you have to set the display to SPI mode, see the Assembly step on how to do that!
Since this is a SPI-capable display, we can use hardware or 'software' SPI. To make wiring identical on all Arduinos, we'll begin with 'software' SPI. The following pins should be used:
Later on, once we get it working, we can adjust the library to use hardware SPI if you desire, or change the pins to any others.
You will also want to power the HC4050 level shifter by connecting pin #1 to 3V (the red wire) and pin #8 to ground (the black wire)
We also include a 220uF capacitor with your order because we noticed that the 3V line can fluctuate a lot when powered via an Arduino's 3.3V regulator. We really recommend installing it. Clip the leads on this capacitor and connect the negatve pin to GND and the positive pin to 3V
To begin reading sensor data, you will need to download Adafruit_SSD1305 and Adafruit_GFX. You can install these libraries via the Arduino library manager.
Open up the Arduino library manager:
Search for the Adafruit GFX library and install it:
If using an older (pre-1.8.10) Arduino IDE, locate and install Adafruit_BusIO (newer versions do this one automatically).
Then, search for the Adafruit SSD1305 library and install it
We also have a great tutorial on Arduino library installation at: http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use
Before you compile and run the demo, you'll need to make sure you have the library configured to the right size. Open up the Adafruit_SSD1305.h file in your ArduinoSketchFolder/libraries/Adafruit_SSD1305 folder and look for the lines that have:
1. #define SSD1305_128_32
2. //#define SSD1305_128_64
If you are running a 128x32 display, leave the second line commented
If you are running a 128x64 size display, comment the first line and uncomment the second one. Then save the file
After restarting the Arduino software, you should see a new example folder called Adafruit_SSD1305 and inside, an example called ssd1305 test
Now upload the sketch to your Arduino. That's pretty much it! You should see immediate update of the display.
If nothing shows up at all, make sure you have your wiring correct, we have a diagram above you can use. Also, check that you converted the module to "SPI" mode (see the Assembly) step on how to do that
Now that you have it working, there's a few things you can do to change around the pins.
If you're using Hardware SPI, the CLOCK and MOSI pins are 'fixed' and cant be changed. But you can change to software SPI, which is a bit slower, and that lets you pick any pins you like. Find these lines:
1. // If using software SPI, define CLK and MOSI
2. #define OLED_CLK 13
3. #define OLED_MOSI 11
4.
5. // These are neede for both hardware & softare SPI
6. #define OLED_CS 10
7. #define OLED_RESET 9
8. #define OLED_DC 8
9.
Change those to whatever you like!
If you want a little more speed, you can 'upgrade' to Hardware SPI. Its a bit faster, maybe 2x faster to draw but requires you to use the hardware SPI pins.
1. // this is software SPI, slower but any pins
2. Adafruit_SSD1305 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
3.
4. // this is for hardware SPI, fast! but fixed oubs
5. //Adafruit_SSD1305 display(OLED_DC, OLED_RESET, OLED_CS);
Comment out the top line and uncomment the bottom line
It is also possible to use the display in I2C mode. Its a little slower but uses way fewer pins.
Don't forget you have to set the display to I2C mode, see the Assembly step on how to do that!
Unless you are using a Metro 328 you will need to add I2C pullups on SDA and SCL! Use two 10K (or so) resistors, each one connected from SDA & SCL to 3.3V
For I2C you will need to use the hardware I2C pins on your Arduino or microcontroller. The following pins should be used:
While its ideal to use level shifters on the I2C pins, you can sorta get away with this on an arduino, because the I2C pins are open collector and there are very weak pullups on those two lines. If using with other I2C devices, we suggest using a 3V-logic arduino or an I2C-safe shifter.
Later on, once we get it working, we can adjust the library to use hardware SPI if you desire, or change the pins to any others.
We also include a 220uF capacitor with your order because we noticed that the 3V line can fluctuate a lot when powered via an Arduino's 3.3V regulator. We really recommend installing it. Clip the leads on this capacitor and connect the negatve pin to GND and the positive pin to 3V
In the test code, change the top area where you define the protocol used by commenting out the software and hardware SPI and uncommenting the I2C version
1. // software SPI
2. //Adafruit_SSD1305 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
3. // hardware SPI
4. //Adafruit_SSD1305 display(OLED_DC, OLED_RESET, OLED_CS);
5. // I2C
6. Adafruit_SSD1305 display(OLED_RESET);
Everything else about the display is identical to SPI mode.
By default we use I2C address 0x3C which is what we get by connecting DC/A0 to ground. If you tie that pin to 3.3V instead, the address will be 0x3D and all you have to do is call display.begin(0x3D) to initialize with that address.
The Adafruit_GFX library for Arduino provides a common syntax and set of
graphics functions for all of our TFT, LCD and OLED displays. This allows
Arduino sketches to easily be adapted between display types with minimal
fuss…and any new features, performance improvements and bug fixes will
immediately apply across our complete offering of displays.
The GFX library is what lets you draw points, lines, rectangles, round-rects,
triangles, text, etc.
Since this is a 'buffered' display, dont forget to call the "display()" object function whenever you want to update the OLED. The entire display is drawn in one data burst, so this way you can put down a bunch of graphics and display it all at once.
Tel: +86-755-27205930
Email: [email protected]
Add: No.205,A Zone,Mingyou Purchasing center,Baoyuan Road,Baoan District,Shenzhen,China