Connect and use an OLED Display with Arduino using the SPI Bus - Tutorial
HTML-код
- Опубликовано: 30 июл 2024
- Let's use the SPI Bus to connect and use an OLED Display and display temperature and humidity values from a DHT11 sensor.
To get the schematic, libraries and the sketch we used please check out our tutorials page at : brainy-bits.com/tutorials/ Наука
Thank you so much for making the video and sharing it here. Best explanation of the oled display I have seen, will check out your webpage now.
Merci
+iHayri1 Thank you for the comment, always great to see my videos are helping others :) Merci!
This video and the tutorial description helped me a lot and only with this example I got my display to work. Thank you very much! :-)
Fantastic.. it helped me alot.
i have an identical oled thanks for the video i had no idea how to get it to work since most are 4 pins
every photo i load it to the oled is crashed it just display interfaced lines,what is the reason?
thank you. Good video. Excellent pronounciation for foreign ears.
+Volker Block That's nice of you to say, since I'm french and sometime have a hard time with pronunciations :) Thank you for watching!
thank you ! was helpful
+Hobby at home Always great to hear it helped! Thanks for watching!
Nice video. Is there a way of using this code with a 64x48 SPI oled display?
Can you now teach how to connect multiple sensors in the single arduino ?
Do you know how to hack a 0.5 inch display from some videoglasses? I want to hook it to an android board
Good tutorial.
Thank you.
Thank you! Glad it was helpful to you :)
+Brainy-Bits Yes thank you for a Great Tutorial, After a bit of searching and matching this made my Chinese OLED SPI work, thumbs up!
+Brainy-Bits
hi, Good tutorial like always (y)
the spi is more faster than i2c but it tooks 5 digital pins of the arduino and sooner or later will run out of pins.
is there a module like the LCD backpack to make it i2c ; i noticed on the back of this Oled some resister to add or to remove ?
about the 1.44" TFT LCD module it cant be modified to work on i2c , so i thought may be using an arduino pro mini or micro to make it a standalone i2c LCD to use it with other arduino board . so can you help with the code
thanks a lot i really enjoyed and learned from your tutorial (y)
+Akrout Osama You are correct that the SPI is faster but does take more pins than the I2C. Haven't had a chance to play around too much with the resistors on the back or the 1.44 TFT LCD, will try to revisit these modules in future videos. Thanks for the suggestion and for watching of course :)
thanks for the video, good explaining, but have a video for use a 2.4" TFT SPI 240*320? thank you
+川崎春と Don't have those on hand right now, but will try to make a video on using TFT LCD soon. Thanks for the suggestion and watching!
sir, i am having a problem with the adafruit library. well my oled is working fine but the problem is that the whole adafruit logo is not fitting in my oled. i am using the adafruit1306 SPI example. my oled is 128x64 SPI oled. please help me
You have to edit the Adafruit_SSD1306.h file in your library. By default it's set to 128x32 pixels. Just open with a text editor and scroll down a few lines till you see "#define SSD1306_128_64" Remove the "//" from in front of it and place "//" in front of the line below it to ignore "#define SSD1306_128_32"
icarus03lmfp, it's not working. Please tell some other way.
For those with Chinese parts like the 4 pin DHT11 here are the pin configs
arduino-info.wikispaces.com/DHT11-Humidity-TempSensor
And the chinese OLED SPI like this one i.ebayimg.com/00/s/NzAwWDcwMA==/z/8scAAOxyVLNSuZ8f/$_1.JPG
Dont' forget to install the U8GLib library & DHT library which can be found on this page
brainy-bits.com/tutorials/connect-and-use-a-spi-oled-display/
Chinese version OLED SPI Connect your pins like this
gnd - gnd
vcc - 3.3v (VIN)
SCL - pin 13(Clock)
SDA - pin 11(Data)
rst - pin 8
D/c - pin 9
Arduino Code:
#include "U8glib.h"
#include "dht.h"
#define dht_apin A0
dht DHT;
U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9, 8); // D0=13, D1=11, CS=10, DC=9, Reset=8
const uint8_t brainy_bitmap[] PROGMEM = {
0x00, 0x00, 0x03, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x46,
0x00, 0x00, 0x00, 0x00, 0xFC, 0x47, 0xC0, 0x00, 0x00, 0x01, 0xCE, 0x4C, 0x60, 0x00, 0x00, 0x03,
0x02, 0x58, 0x30, 0x00, 0x00, 0x03, 0x02, 0x58, 0x10, 0x00, 0x00, 0x02, 0x02, 0x58, 0x18, 0x00,
0x00, 0x03, 0x06, 0x4C, 0x18, 0x00, 0x00, 0x07, 0x04, 0x44, 0x18, 0x00, 0x00, 0x0D, 0x80, 0x40,
0x3C, 0x00, 0x00, 0x09, 0xC0, 0x40, 0xE6, 0x00, 0x00, 0x18, 0x78, 0x47, 0xC2, 0x00, 0x00, 0x18,
0x0C, 0x4E, 0x02, 0x00, 0x00, 0x1F, 0x86, 0x4C, 0x7E, 0x00, 0x00, 0x0E, 0xC6, 0xE8, 0xEE, 0x00,
0x00, 0x18, 0x43, 0xF8, 0x82, 0x00, 0x00, 0x10, 0x06, 0x4C, 0x03, 0x00, 0x00, 0x30, 0x0C, 0x46,
0x01, 0x00, 0x00, 0x30, 0x18, 0x46, 0x01, 0x00, 0x00, 0x10, 0x18, 0x43, 0x03, 0x00, 0x00, 0x18,
0x10, 0x43, 0x03, 0x00, 0x00, 0x1C, 0x70, 0x41, 0x86, 0x00, 0x00, 0x0F, 0xE0, 0x40, 0xFE, 0x00,
0x00, 0x09, 0x1E, 0x4F, 0x06, 0x00, 0x00, 0x08, 0x30, 0x43, 0x86, 0x00, 0x00, 0x0C, 0x20, 0x41,
0x86, 0x00, 0x00, 0x06, 0x60, 0x40, 0x8C, 0x00, 0x00, 0x07, 0x60, 0x40, 0xB8, 0x00, 0x00, 0x01,
0xE0, 0x41, 0xF0, 0x00, 0x00, 0x00, 0x38, 0xE3, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xBE, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xCF, 0x82, 0x0C, 0x86, 0x46, 0x1F, 0xEF, 0xC3, 0x0C,
0xC6, 0xEE, 0x1C, 0xEC, 0xC7, 0x0C, 0xE6, 0x7C, 0x1C, 0xED, 0x8D, 0x8C, 0xFE, 0x38, 0x1C, 0xED,
0x8D, 0xCC, 0xDE, 0x38, 0x1D, 0xCD, 0xDF, 0xCC, 0xCE, 0x38, 0x1F, 0x8C, 0xF8, 0xEC, 0xC6, 0x38,
0x1F, 0xEC, 0x08, 0x0C, 0xC2, 0x18, 0x1C, 0xEC, 0x00, 0xC0, 0x00, 0x00, 0x1C, 0xFD, 0xFB, 0xC0,
0x00, 0x00, 0x1C, 0xFC, 0x63, 0x00, 0x00, 0x00, 0x1C, 0xEC, 0x63, 0xC0, 0x00, 0x00, 0x1F, 0xEC,
0x60, 0xC0, 0x00, 0x00, 0x1F, 0xCC, 0x63, 0xC0, 0x00, 0x00, 0x1F, 0x0C, 0x63, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x2B, 0x4F, 0x67,
0x42, 0x38, 0x7B, 0xEA, 0x86, 0xB2, 0x28, 0xC7,
};
void draw(void) {
u8g.drawBitmapP( 76, 5, 6, 50, brainy_bitmap); // put bitmap
u8g.setFont(u8g_font_unifont); // select font
u8g.drawStr(0, 30, "Temp: "); // put string of display at position X, Y
u8g.drawStr(0, 50, "Hum: ");
u8g.setPrintPos(44, 30); // set position
u8g.print(DHT.temperature, 0); // display temperature from DHT11
u8g.drawStr(60, 30, "c ");
u8g.setPrintPos(44, 50);
u8g.print(DHT.humidity, 0); // display humidity from DHT11
u8g.drawStr(60, 50, "% ");
}
void setup(void) {
}
void loop(void) {
DHT.read11(dht_apin); // Read apin on DHT11
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
delay(5000); // Delay of 5sec before accessing DHT11 (min - 2sec)
}
What about CS on the chinese OLED display?
@@RSuarez66 pin 10
more please :)
+ce6ugt Thanks for watching :)
good, good, good good.
+ce6ugt Thanks for the comment and watching!
In this case SPI DOES NOT only offers speed advantage!! BUT, the ability to use more than 2 OLEDs at the same time by using the CS pin unlike in I2C case where the device only has 2 addresses. Correct me if I’m wrong.
You are correct about SPI having the CS (cable select) option, but there are ways around it when using I2C by using a multiplexer. I've done a tutorial on this here: ruclips.net/video/wqyHbQvcoWw/видео.html
Thank you for the comment and for watching!
Btw you only need a multiplexer when the I2C devices you are using are sharing the same I2C address.
It doesn't working on me.