Go Down

Topic: SSD1322 OLED Display and Arduino Nano - Asking for help from A to Z (Read 7172 times) previous topic - next topic

Lyechee

Hello everybody,
My name is Nicolas, I'm french and student in aeronautical engineering. That was for the presentation part!

I came here because I have a project in my mind, but arduino is a blurry world to me. I tried to learn alone with examples about OLED screens from the internet or the forum but it always gets specific very fast. I know how to code, I learnt web languages, Fortran, ADA, Python, a bit of C++, so algorithmic isn't a problem. I juste have the feeling that Arduino is really closer to hardware and I'm lost. This is why I came for your help!

First of all, my project. I built a HTPC based on a miniITX motherboard and a skylake CPU, the OS beeing W10 and the mediacenter software, KODI. Now that the hardware and software parts are fonctional, I focus on the homemade case I want around this system. This is where it leads to the OLED display: I would like a display on the case to show what is currently playing, time remaining, etc... I planned to communicate this information via serial usb to arduino with a python little program of my own.

For the display, I'd like to use a 256x64 white Oled display and I found this one: EastRising ER-OLEDM032-1W.
For the board, I found a Arduino Nano like board on Amazon:
 Sodial Nano (I guessed it would be just same with the proper drivers to make it recognisable by the computer).
The first victory was to find that the u8g2 supports the SSD1322 controller of the display. But it's where my abilities stop.

As I'm a complete noobie in Arduino (and electronics in general - not to mistake with informatics), I would like to learn how to wire this display to an Arduino Nano.
I read that I had to use the 4-Wire SPI, but the display has 16 differents pins and I don't understand the meaning of the schematics available here: Interfacing.

Once it will be done, what should I write/do (or read) to display whatever I want to my display using the u8g2 library?

Please notice that everything here is for now theoretical as I'm finishing an internship in Canada, I will be home in a couple weeks. I just anticipated my need for information.

Thanks for reading me, I know it was quite long. I didn't want to come and only ask you to do all the work for me (still not far from that idea).

Have a nice day/evening,
Nicolas

olikraus

Hi Nicolas

Tool Setup:
- Install Arduino IDE (download from arduino.cc)
- Within Arduino IDE locate the library manager and install u8g2 (https://github.com/olikraus/u8g2/wiki/u8g2install)

Hardware Setup:
- OLED: SSD1322
- Nano (BTW: link is broken in your first post)

Note that your OLED is a 3.3V device, while the Nano is a 5V device: You need a level shifter (voltage level translator from 5V to 3.3V) from Nano to OLED. Best is to use a 74HC4050 for this.

The next step  is to create a connection table. You can also take some ideas from here: https://github.com/olikraus/u8g2/wiki/setup_tutorial, but it will probably look like this:


Function | Nano Pin | OLED Pin
---------+----------+----------
DC       | 3        | 14    
Reset    | 4        | 15
CS       | 5        | 16
Clock    | 13       | 4
Data     | 11       | 5


You get all this information from the OLED datasheet chapter 4 and from the SSD1322 datasheet chapter 8.1. You should verfy this table, I am not sure whether this connection table is fully correct.
Chapter 8.1 of the SSD1322 datasheet will also tell you what to do with the other pins of the OLED: Many of them have to be connected to GND.

On Nano side you can basically use any Pins, but it might be clever to choose SPI Clk (sclk) and SPI Data (MOSI) pins on the Nano.

Of course the five data lines must not be connected directly from Nano to OLED, but instead they have to be routed across the 74HC4050.

Two more thinks to consider:
1) The OLED has to be put into 4-wire SPI mode
2) U8g2 has to be put into 16 bit mode (see U8g2 FAQ)

Hope this helps. Let me know if you need more support.

Oliver

Hoek

 :o  Also note these devices can be run parallel, 3 wire and 4 wire SPI.

There are 2 pads on the back that are either connected or disconnected. Off memory these are set to parallel!!!

The SSD1322 is my favourite OLED as has 16 color grayscale.

From the notes in my driver code (below)

SSD1322 EMOLED 256*64 4bpp driver

Supports SPI, SPI via DMA or SW SPI

Usually has 1 - 20 pins

The data mode I2C, SPI or 8 bit parallel is selected by 2 solder bridges on the back, need to check to see what the default is and change if
needed. In my case it was set for parallel so I had to desolder and resolder for SPI.

for SPI
1 = VSS/ground
2 = VDD/VCC +3.3v to +5.0v
3 = NC
4 = SCLK
5 = SDIN (MOSI)
6 = NC
7-13 = GND
14 = PIN_DC
15 = PIN_RESET
16 = PIN_CS

All other pins were grounded via a nice single blob of solder.


*NOTE - SPI_MODE3


Lyechee

Hello!
Thanks olikraus for your complete answer, and Hoek for answering to one question before I even ask  :D .
But because I am a pure noobie in Arduino, I still have questions.

I planned to buy the screen of the provided link, and I can choose a "Pin Header Connection-4-Wire SPI", I assume it means that the "jumper" is in the right position just as you said Hoek?

I corrected the link for the Nano board. I think it would do the job if I install the right drivers as explained here: Topic on the forum.
To understand why you chose these pins olikraus, I used this "map" of the Nano.

I then understood why wire the Clock and Data pins of the OLED to the D13 (SCK) and D11 (MOSI) but why the DC, Reset and CS pins wired to D3, D4, D5? Any particular reason?
Then I assume I can wire the pin 2 of the OLED(VBAT) to the 3V3 pin of the nano and all the ground connections to the ground of the nano.

Now, the problematic (for me) part of your answer olikraus, the level shifter part. I perfectly understand why you can't send 5V to a 3V input  :smiley-mr-green: , but is there any other way that this level shifter alone? What I mean is that I need something really compact as it has to be included in a PC case, so I can't use any arduino board with all the holes. Do a board with pins exist that could do the same job? I found this on Sparkfun but it has only 4 channels and I have 5 to connect.
EDIT: I found this 8-bit bidirectional level shifter that seems perfect for me. Do you agree?


Thank you both for your answer, it starts to be clear for me and I hope for anyone in my condition.
Have a nice day!
Nicolas

olikraus

... but why the DC, Reset and CS pins wired to D3, D4, D5? Any particular reason?
Any GPIO pin will do the job, I just selected some random pins.

Then I assume I can wire the pin 2 of the OLED(VBAT) to the 3V3 pin of the nano and all the ground connections to the ground of the nano.
I found this on Sparkfun but it has only 4 channels and I have 5 to connect.
EDIT: I found this 8-bit bidirectional level shifter that seems perfect for me. Do you agree?
It probably should do the job. I personally had never used such boards. Another option might be to use a 3.3V Arduino board instead of a 5V board. This will avoid the level shifter. Examples are:

Feather 32u4 https://www.adafruit.com/product/2771
Pro Micro 3.3V https://www.sparkfun.com/products/12587
MKRZero https://store.arduino.cc/arduino-mkrzero

Oliver

Lyechee

Hello olikraus!

To the part "Then I assume I can wire the pin 2 of the OLED(VBAT) to the 3V3 pin of the nano and all the ground connections to the ground of the nano.", your answer meant I was right?

I think I will stay with the level shifter, as I can put it where I want with the screw holes, and the nano seems more common.
If I understand right the functionment of the level shifter, I have to connect VA to the 5V output of the nano and the VB to the 3V3 output of the nano. Then every input on the level shifter on the A side will be converted into a 3V3 output on the B side?
I obviously have to connect the GND pin to the ground of the nano, but what about the OE pin?
EDIT: If it can help, here is a documentation about the level shifter used by this board: TXS0108E

Finally, I have questions about the connection of the nano:
-is the serial protocol different with a USB3 than with a USB2 port?
-can the nano be alimented only with the USB port (remember that I plan to aliment the OLED with the nano 3V3 output

Thanks again!
Nicolas

olikraus

Hello olikraus!

To the part "Then I assume I can wire the pin 2 of the OLED(VBAT) to the 3V3 pin of the nano and all the ground connections to the ground of the nano.", your answer meant I was right?
Yes (I guess the word "yes" got lost in my previous answer)


I think I will stay with the level shifter, as I can put it where I want with the screw holes, and the nano seems more common.
If I understand right the functionment of the level shifter, I have to connect VA to the 5V output of the nano and the VB to the 3V3 output of the nano. Then every input on the level shifter on the A side will be converted into a 3V3 output on the B side?
I obviously have to connect the GND pin to the ground of the nano, but what about the OE pin?
EDIT: If it can help, here is a documentation about the level shifter used by this board: TXS0108E
I am not a specialist on this, but I guess regarding VA/VB you are right. OE probably means "output enable", but better lookup the datasheet.


-is the serial protocol different with a USB3 than with a USB2 port?
no

-can the nano be alimented only with the USB port (remember that I plan to aliment the OLED with the nano 3V3 output
hmm i am not sure, what you mean.

Oliver


Lyechee

I am not a specialist on this, but I guess regarding VA/VB you are right. OE probably means "output enable", but better lookup the datasheet.
In fact I wasn't, the datasheet mentions for VA : "A-port supply voltage. 1.2 V ≤ VCCA ≤ 3.6 V, VCCA ≤ VCCB.", so I would have burned that thing if I had followed my plan!

For OE, that is the description by the datasheet : "3-state output-mode enable. Pull OE low to place all outputs in 3-state mode". But I don't understand what it means..

hmm i am not sure, what you mean.
I mean, is the USB port connected to the arduino enough to power the nano, the level shifter and the OLED?

Thanks,
Nicolas

olikraus

In three state mode, usually there is a high-impedance state. In your case this is not required, so OE should be high.

And yes, USB can power all three parts.

Oliver

Lyechee

What do you me an by "OE should be high"?
Do I have to connect it to some pin of the arduino?

Thanks,
Nicolas

olikraus

What do you me an by "OE should be high"?
Do I have to connect it to some pin of the arduino?
No, i mean it should be connected to 3.3V or 5V directly (of course it could be the Arduino 3.3V or 5V Output). But you probably need to check the datasheet of that level shifter about what voltage is required for that pin, so that the logic detects "high".

Oliver

Lyechee

Hello!
Thanks again for your kind help, and sorry for the absence, I came back to France this week!
On the datasheet is written "Referenced to VCCA" so I assume it must be connected to the same powersource as VCCA.

This brings a question: how can I connect one pin of the arduino to multiple objects without a breadboard?

I have another question: I would like to add some RGB leds piloted by the arduino (~40).

It requires 5V input and 50mA per led so 2A in common. Does the micro usb give enough power for the arduino, the level shifter, the OLED AND the RGB strip? I can connect a 5V output from a molex cable from the computer power unit if needed.

Everything has been purchased and I'm looking forward to build everything and code the arduino!

Nicolas

olikraus

Quote
This brings a question: how can I connect one pin of the arduino to multiple objects without a breadboard?
Why not using a solder iron?


Quote
It requires 5V input and 50mA per led so 2A in common.
This requires a good power source. The Arduino can only provide 100mA, but of course you can control other powersources with your arduino (MOSFETs are the usually used for this). But I guess you get better answers in the LED board of this forum.

Oliver

Lyechee

Hello!
Thanks for taking the time to answer and guide me!
I was very busy these last months but I'd like to go on with my project now.

I designed a scheme of the wiring I should do. I used fritzing and modified it on photoshop because I couldn't find a OLED (here a LCD) screen and a 20 pin level shifter (I used a 20pin chip and modified the image on photoshop).


The spec of the level shifter are these:
VA must be lower than VB
1.2<VA<3.6
1.65<VB<5.5
OE is referenced to VA (that's why I connected it to VA=3.3V)
The specs: http://www.ti.com/lit/ds/symlink/txs0108e.pdf

Can you guys tell me if I did something wrong?

Thanks,
Nicolas


borland

If your not sure about the power capability of the NANO's 3.3v supply, there is a TX0108 module available that has built-in adjustable LDO regulator which can supply more current at 3.3v.   The module is made by BLKBOXme, part number BB-0108B.  I sourced one from eBay.

The module's regulator IC is adjustable by a small pot, but also pin compatible (SOT23-5) with fixed 3.3v LDO regulator.  I used this module but substituted a Texas Instruments TLV70033DDCR regulator for fixed 3.3v to supply a 2.42" OLED.  Small form factor of SOT23-5 makes the substitution more difficult.

Per the product page, Uno's 3.3v is only good for 50mA.  Nano's product page doesn't specify.

Go Up