question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong pins on sh1106 spi example

See original GitHub issue

Been trying for 2h+, and finally discovered the SPI wiring pins on the comments are wrong.

Instructions goes as (wrong): ` Sample code sections ------------ SPI ------------------ Pin Map SPI

  • 3v - xxxxxx - Vcc
  • G - xxxxxx - Gnd
  • D7 - GPIO 13 - Din / MOSI fixed *1
  • D5 - GPIO 14 - Clk / Sck fixed *2
  • D8 - GPIO 4 - CS (optional, if the only connected device)
  • D2 - GPIO 5 - D/C
  • D1 - GPIO 2 - Res `

But only works if you use (right): ` Pin Map SPI

  • GPIO 11 - Din / MOSI fixed *1
  • GPIO 10 - Clk / Sck fixed *2 `

Also may include a suggestion to use a logic level adapter, because there are 5v sh1106 displays.

Link to photo of working set, also using lg. lvl. adap. 5v

The mistake is located at: https://github.com/raspberrypi/pico-micropython-examples/blob/master/i2c/1106oled/sh1106.py

Thanks 4 the great work.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
robert-hhcommented, Apr 26, 2021

About the suggestion of note on 5V devices. That’s not needed since:

  • the logical section of the sh1106 chip itself runs at 3.3V, and so it matches the RP2040.
  • and even if it were a 5V device: Only inputs of that module are driven by the RP2040. So there is no risk of a damage. Eventually the the high level of the RP2040 could be to low to be recognized by a 5V device. But I never had problems.
1reaction
lurchcommented, Apr 26, 2021

ping @robert-hh (whose name appears in sh1106.py)

Took me a little while to figure out what was going on here, as https://github.com/raspberrypi/pico-micropython-examples/tree/master/i2c/1106oled only shows an I2C wiring-example. But then I figured out that this issue is referring to the code comments in sh1106.py rather than any actual example code? So then I managed to figure out that the SPI pins used are actually “allocated” by the line: # spi = SPI(1, baudrate=1000000). So then I found up https://github.com/micropython/micropython/blob/master/ports/rp2/machine_spi.c#L44 which confirms that for SPI interface 1, the default MOSI pin used by MicroPython is GPIO11 and the default SCK pin is GPIO10.

Which matches up with what @Garfius has written above 😁

I’ll give it a couple of days to see if Robert responds, and if he doesn’t I’ll fix up the SPI-related pin-number code-comments in https://github.com/raspberrypi/pico-micropython-examples/blob/master/i2c/1106oled/sh1106.py myself 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trouble connecting to SPI display sh1106
I was able to get external OLED displays working with a Heltec wifi ESP8266 over SPI with SH1106 as follows: from machine import...
Read more >
SH1106 SPI Displays not turning on at all - Arduino Forum
I've diligently connected CLK to 13, MOSI to 11, CS to 10, DC to 9, and RES to the 8 pins of my...
Read more >
Sh1106 SPI in Breakout Garden - can't get it working
I've installed the software as described: sudo pip install git+git://github.com/rm-hull/luma.oled.git#egg=luma.oled but can't get the bounce ...
Read more >
Recalcitrant SH1106 OLED [Solved: SCK & MOSI were ...
Then I realized the bootloader menu configured hardware SPI which I had to turn off (SPCR = 0) for bitbanging the SPI pins...
Read more >
Teensy 3.x and SH1106 OLED via SPI
Note: the CS pin on the OLED is attached to a 10k resistor which is not ... a bit more about SPI and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found