Notifications
Clear all

Waveshare 1.5" OLED help

9 Posts
3 Users
0 Likes
2,197 Views
(@davemorris)
Member
Joined: 3 years ago
Posts: 31
Topic starter  

I am having a hard time figuring out the proper syntax for using the Waveshare 1.5" OLED display.  I can get it to work following the tutorial on OLED displays, but the example code that I have found is very complicated with multiple tabs. I am making a dual temp display and just want to write to it from two different sensors, but I can't seem to get it right. Is there a more simplistic coding example for writing basic information to this display?

Thx


   
Quote
(@sj_h1)
Member
Joined: 3 years ago
Posts: 167
 

Without going through all the documentation and I found several videos, there are several types of OLED displays, but the basic commands for most seems to be something like below foe my oled display. 

// initialize with the I2C addr 0x3C
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

// Clear the buffer.
display.clearDisplay();

// Display Text
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,28);
display.println("Hello world!");
display.display();
delay(2000);
display.clearDisplay();

 

I would be happy to help if you post your code!

 


   
ReplyQuote
(@davemorris)
Member
Joined: 3 years ago
Posts: 31
Topic starter  

New issue with my 1.5" Waveshare OLED display...I am now trying to use it with an Arduino Mega 2560 and I can not get it to work at all.  I tried hooking up a second display as well and neither of them work.  When moving from an Uno to a Mega, do the pins change?  In the Arduino IDE I set it for the Mega 2560 and uploaded the same sketch that I had for the Uno and the display isn't working. 

This display uses the following pins:

VCC, GND, DIN, CLK, CS, DC, RST

I tried hooking them up using the same pins as in the displays video that Bill did and while it worked on the Uno, it doesn't appear to on the Mega. I am using the Adafruit_SSD1351.h library.

What am I doing wrong??  Here is the code I am using for the display:

image

   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1018
 

@davemorris

Are you using the I2C interface or the SPI interface?  There are differences on the pin numbering between the UNO and the MEGA.  The MEGA has many more pins, and a good number of things are different on the MEGA than on the UNO.

Try getting a handle on working with the display on the UNO first, then it should just be a matter of pin number changes going to the MEGA.

Reply with the pin numbers you are using if things are working on the UNO and we should be able to help you find the proper pins on the MEGA.

SteveG


   
ReplyQuote
(@davemorris)
Member
Joined: 3 years ago
Posts: 31
Topic starter  

@codecage

I am using the SPI interface.  It works perfect on the Uno with the other sensors and components that I have connected. I just need help understanding which pins translate on the Mega. I want to understand better what these pins do so that instead of just looking for a number I can design around knowing how the system uses them.  This shows the pins I'm using on the Uno and it is working:

image

   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1018
 

@davemorris

Dave here is a link to the pin labeling for the MEGA:

Arduino MEGA Pinout Diagram

 

And here is a reference I worked up:

MOSI and MISO on UNO and MEGA (The new politically correct names are now COPI and CIPO)
                       UNO MEGA(ICSP)
MOSI/COPI       11       51(4)
MISO/CIPO        7        50(1)
SCK                 13        52(3)
SS/CS              10        53
RST                   8        ??(5)

Not sure about which reset on the MEGA you should use if needed, but maybe others can chime in.  Also the MEGA has 2 different SPI busses.  They are the 6 pin headers shown on the drawings shown in the link above.

Hope this helps.

SteveG


   
ReplyQuote
(@davemorris)
Member
Joined: 3 years ago
Posts: 31
Topic starter  

@codecage

Still not working.  I am about ready to toss this and just move on.  Unless I am just missing something obvious in the names of some of the connections. Here is how the display is labeled:

VCC - 5V

GND - GND

DIN - 51

CLK - 52

CS - 53

DC - 50

RST - 8

All of these pins are defined as such in my code. I also have an LED set up on pin 30 that I am using as a power ON indicator for this project and it comes on after uploading the code so I know the Mega is getting it.


   
ReplyQuote
(@davemorris)
Member
Joined: 3 years ago
Posts: 31
Topic starter  

So after watching what must be the 900th video regarding OLEDs and the Mega, I tried using pins that sort of matched what the guy in the video was doing.  I got it to work with these pins:

VCC - VCC

GND - GND

DIN - Pin 51

CLK - Pin 52

CS - Pin 11

DC - Pin 10

RST - Pin 8

Now i would just like to know why this works.  What is different about it working this way, but not the way I referenced it in my earlier post.  The only thing I changed in my programming was the pin numbers. I would really like to understand how this works.  I guess its time for some videos on the SPI interface.


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1018
 

@davemorris

Pins 10 and 11 seem to be reversed to me.  CS is Chip Select (or SS in the older naming convention) and DC, from the Waveshare documentation, is the same as COPI (or MOSI) on the SPI buss.  You are showing here Pin 11 as CS when, to my understanding, that should be COPI, and Pin 10 as DC when, again to my understanding, that should be CS.

I hope a few others see this post and can maybe shed some light on the subject.

SteveG 🤔 

SteveG


   
ReplyQuote