Sunday, April 24, 2022

 RasPi Pico and an OLED Screen


My project for this morning was to connect a small I2C OLED screen to Raspberry Pi Pico and make it do something with Circuit Python. As the picture indicates, I had some success. As this post will indicate, I had some struggles as well.

My first struggle involved finding the spare Pico I had somewhere in my parts boxes. Then I needed to find my original order for the OLED screen so that I would know what sort it was. Turns out it was an I2C SSD1306 0.96" display. I had to find some breadboards. I did know where my jumper wires were and the night before I had located an appropriate USB cable.

So, with all this stuff together, I was able to learn some stuff, which I will present in order of challenge.

Installing CircuitPython on a Pico: I had done this before, but it was a good refresher. Plug the Pico in to your PC with the 'bootsel' button pressed and copy the latest CircuitPython release for the Pico unto the drive that shows up on your PC.

Wiring up a breadboard: If your stuff isn't working, maybe you forgot that the center of the board needs to be bridged if you cross it. I spent some troubleshooting time working out that the GND and 3V pins weren't connected only to end up going "Ohhhhhhhhh....."

MacOs has weird names for tty devices: I recently bought a MacBook Air M1 just to sort of have one in the tech collection. When connecting to the Pico's serial console, it shows up as /dev/tty.usbmodem1101

The Pico doesn't have SCL and SDA or I2C attributes in it's board library: Adafruit has great tutorials, but they are generally for their own boards. In their examples, they just enable I2C from the board object. I found that the busio module had the I2C class in it, but it wanted arguments that were the SCL and SDA pins from the board.

On the Pico, you reference the I2C pins by their GP numbers: So, instead of board.SCL and board.SDA it turned out to be board.GP1 and board.GP0. So, the line became 'i2c = busio.I2C(board.GP1, board.GP0). This worked great once I figured out I wasn't really connecting GND and 3V to the display.

Links I used this morning:

For info on wiring I2C OLED Display to a Pico

Adafruit tutorial on the SSD1306 display libraries

CircuitPython and I2C connections

 RasPi Pico and an OLED Screen My project for this morning was to connect a small I2C OLED screen to Raspberry Pi Pico and make it do someth...