Sh1106 on pi pico rp2040

Hi!
I already tested my sh1106 using the microPython example, and works great. But i want to use this display on arduino IDE because it’s where all my projects are. And i am wiling to take profit of the RP2040 pi pico which is an amaziing board.

Already tried using Adafruit_SH1106 library, which leads to: fatal error: util/delay.h: No such file or directory
Already tried using U8g2lib library, which leads to: fatal error: avr/io.h: No such file or directory
Already tried using lcdgfx library, which leads to: fatal error: avr/io.h: No such file or directory

Any success over there?

Thanks.

First off. Are you using the correct Arduino Mbed OS RP2040: Raspberry Pi Pico Board in the IDE ?

It is not a “public” library but you can try

It is running on my Pico board.

David.

1 Like

Reconfigured for API, doesn't seem to work.

Just replaced:
Adafruit_SH1106_kbv display(128, 64, &Wire);
For:
Adafruit_SH1106_kbv display(128, 64, 7, 6,5, 2, 4);

Any idea?

From Adafruit_SH1106_kbv.h:

class Adafruit_SH1106_kbv : public Adafruit_GFX {
public:
  // NEW CONSTRUCTORS -- recommended for new projects
  Adafruit_SH1106_kbv(uint8_t w, uint8_t h, TwoWire *twi = &Wire,
                   int8_t rst_pin = -1, uint32_t clkDuring = 400000UL,
                   uint32_t clkAfter = 100000UL);
  Adafruit_SH1106_kbv(uint8_t w, uint8_t h, int8_t mosi_pin, int8_t sclk_pin,
                   int8_t dc_pin, int8_t rst_pin, int8_t cs_pin);
  Adafruit_SH1106_kbv(uint8_t w, uint8_t h, SPIClass *spi, int8_t dc_pin,
                   int8_t rst_pin, int8_t cs_pin, uint32_t bitrate = 8000000UL);

So you have replaced the I2C display constructor with a bit-banged SPI constructor.

Note that the Arduino Mbed OS RP2040: Raspberry Pi Pico Board expects hardware SPI and hardware I2C on:

// SPI
#define PIN_SPI_MISO  (4u)
#define PIN_SPI_MOSI  (3u)
#define PIN_SPI_SCK   (2u)
#define PIN_SPI_SS    (5u)

// Wire
#define PIN_WIRE_SDA        (6u)
#define PIN_WIRE_SCL        (7u)

Note that Earlphilhower and the SDK choose different GPnn pins for default SPI and I2C

I don't think that I have tried a SPI SH1106 display with hardware or bit-banged constructor. Only with I2C on GP6, GP7 pins.

Which pins did you use for I2C display ?
You can select an alternate TwoWire object.

If you have trouble with I2C display, I will try my SPI display.

David.

Edit. Tried both hardware SPI and bit-bashed on a 7-pin SH1106 display. Both worked fine.

Please let me know how you get on.

1 Like

BINGO!
I have found enough spare time to check all the stuff and made it work.

1st: Guess the spi port pins.
-The official SPI pin specification from the vendor is a mess of dupicated/triplicated SPI pins. So, i used: How To Test The SPI Module Of Arduino- (Part 32/49) to find the right pins.
The SPI right pins are as follows: piPicoPins.jpg - Google Drive (i see you posted the right ones above)

-Finally worked using instance:
Adafruit_SH1106_kbv display(128, 64, &SPI,15, 13, 14);// GP13 reset, GP14 cs, GP15 dc

The exact display i am using is: sh1106_SPI.jpg - Google Drive

Refresh is REALLY FAST, might consider small video :stuck_out_tongue:

Thank you very much 4 the library.

You should never guess. You should look at the official documentation.
Or view the variant files.

Although the Pico can use multiple UART, SPI, I2C, ... the Arduino release just specifies a single Serial, SPI, Wire, ...

I suggest that you always use hardware SPI whenever possible. But it is wise to start with bit-banging the pins.

It is seldom worth posting a photo of the front of a screen. The pcb is far more useful.

Incidentally, you can use any legal hardware SPI or I2C. You just create the appropriate SPI object and use its address.

David.