SSD1306 using SPI

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
skymast
Posts: 2
Joined: Fri Jun 11, 2021 6:21 pm

SSD1306 using SPI

Post by skymast » Fri Jun 11, 2021 6:38 pm

Hi

I have an SSD1306 Oled 128x64
It looks identical to the one on this page https://simple-circuit.com/ssd1306-oled ... -projects/

The resistors are configured for it to be in SPI mode.

I can't get it to display anything at all. I'm not sure if it is a wiring problem or a software problem.

I am wiring it as follows:
1 GND --> GND
2 VDD --> 3.3V
3 SCX --> Raspberry Pi Pico pin 4 (GP2/SPI0 SCK)
4 SDA --> Raspberry Pi Pico pin 5 (GP3/SPI0 TX)
5 RES --> 3.3V
6 DC --> Raspberry Pi Pico pin 6 (GP4/SPI0 RX)
7 CS --> GND

I am trying to write to it using this code

import machine

spi_sck = machine.Pin(2)
spi_tx = machine.Pin(3)
spi_rx = machine.Pin(4)
spi = machine.SPI( 0, baudrate=20000, sck=spi_sck, mosi=spi_tx, miso=spi_rx)

spi.write('\x7C')
spi.write('\x2D')
spi.write("hello world")

If anyone has any ideas or suggestions please, they would be very gratefully received :)

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: SSD1306 using SPI

Post by Roberthh » Fri Jun 11, 2021 6:49 pm

Follow the examples of the documentation: https://docs.micropython.org/en/latest/ ... ht=ssd1306

skymast
Posts: 2
Joined: Fri Jun 11, 2021 6:21 pm

Re: SSD1306 using SPI

Post by skymast » Fri Jun 11, 2021 7:42 pm

Thank you very much - that's solved my problem.

I was following the tutorial for the RP2xxx - which seemed sensible!! :) The tutorial for the ESP8266 which you linked to was different, but actually worked. Go figure ...

For future reference - here is my working setup

1 GND --> GND
2 VDD --> 3.3V
3 SCX --> Raspberry Pi Pico pin 4 (GP2/SPI0 SCK)
4 SDA --> Raspberry Pi Pico pin 5 (GP3/SPI0 TX)
5 RES --> Raspberry Pi Pico pin 9 (GP6)
6 DC --> Raspberry Pi Pico pin 6 (GP4/SPI0 RX)
7 CS --> Raspberry Pi Pico pin 7 (GP5/SPI0 CSn)

import machine
import ssd1306

hspi = machine.SPI(0)
dc = machine.Pin(4)
cs = machine.Pin(5)
rst = machine.Pin(6)

display = ssd1306.SSD1306_SPI(128, 64, hspi, dc, rst, cs)
display.text('Hello World!', 0, 0, 1 )
display.show()

Post Reply