How to use the SPI interface in ESP32 to drive a 0.96 OLED 1306 screen?

Issue #457 resolved
Pengfei Liu created an issue

We are a team working on educational robots, currently planning to use Microblocks to control the ESP32. However, we have encountered a problem. When using the official OLED library, we found that it can only control the screen using microbit with SPI protocol. We want to use ESP32 to drive the 0.96 OLED screen with SPI protocol. How can we do this?

Comments (23)

  1. Turgut Guneysu

    In order to use the SPI connection with the ESP32, you need to have an SPI version of the OLED screen.
    If you do, then follow directions below.

    I don't have a 0.96in SPI display, but I have an 2.4in OLED SPI screen with pins connected as listed below.

    DISPLAY           ESP32

    CS                NOT USED
    DC                Any dig pin
    RES               Any dig pin
    SDA               23
    SCL               18
    VCC               3.3V
    GND              GND

    I found this SPI version of the OLED 0.96in:

    DISPLAY           ESP32

    CS                NOT USED
    DC               Any dig pin
    RES               Any dig pin
    SDA (DI)           23 , VSPI-MOSI
    SCL (D0)          18 , VSPI-CLK
    VCC              3.3V
    GND             GND

    You need to verify the designations for DI / DO in the display documentation as to which is SCL and MOSI (SDA).

    The 2 digital pins are used for the RESET and DC functions on the SPI config block of the OLED Library:

    d/c and reset numbers shown are for what I used. Your's may be different. Just replace as needed.

    Images of the display with connection and text (Sorry about the plastic on the display).

    Once you make the connections, click to initialize, and then click on WRITE block for text display.

    Hope it helps.

    Turgut

  2. Pengfei Liu reporter

    Thank you very much for your help, we have successfully lit it up, and in the near future, there will be a desktop-level robot dog controlled by microblocks

  3. Turgut Guneysu

    I am glad you managed to make the SPI display work. If that is the dog from Elekfreaks, I just bought the same. I was going to write the library for it. But you may beat me to it.

  4. John Maloney repo owner

    I'm marking this resolved, but you can continue to make comments here. I'd love to hear about any progress with the robotic dog!

  5. Pengfei Liu reporter

    We also will use Microblocks to programe XGO-Rider , a desktop wheel legged robot .Both the XGO-Rider and the XGO2 series robot dogs use the Raspberry Pi CM4 as the main controller for educational robots. Additionally, all the source code and structural drawings are open source. We have not yet tried virtual machines for the Raspberry Pi, but we plan to use Microblocks for programming and controlling the Raspberry Pi in the future.

  6. John Maloney repo owner

    Glad you got the XGO-nano library working in MicroBlocks! Let us know if you need help getting the MicroBlocks virtual machine running on the Raspberry Pi. We do not use that VM regularly, and the pin I/O features have not been heavily tested so it may need a few tweaks.

  7. John Maloney repo owner

    We got our XGO working with the micro:bit. Thank you for the library and the pin numbers.

  8. Log in to comment