0

PICO and pioled 1306
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

PICO and pioled 1306

by genus1 on Sun Apr 04, 2021 9:56 pm

I have been attempting to integrate the 1306 with circuitpython and specifically the pioled on the PICO. It appears the ssd1306 mpy and support files are not ready for pico yet. Am I doing something wrong. I was trying to load the framebuffer and display io and 1306 into my pico LIB.

genus1
 
Posts: 15
Joined: Wed Sep 26, 2018 11:54 pm

Re: PICO and pioled 1306

by neradoc on Mon Apr 05, 2021 8:41 am

Hi, how did you connect the pico and the hat ? What is your code, does it give you errors ?

The following Circuitpython code works on a ssd1306 128x32 OLED display. (This one https://www.adafruit.com/product/4440 )
It should work the same when connecting to the correct pins on the pioled.

Note that the Raspberry pico requires a little bit of care in selecting the I2C pins, they need to make a pair as per the names in the blue boxes in the pinout card:
https://learn.adafruit.com/getting-star ... on/pinouts

The latest versions of the adafruit_displayio_ssd1306 and adafruit_display_text libraries can be found in the library bundle: https://circuitpython.org/libraries
The latest version of circuitpython can be found here: https://circuitpython.org/board/raspberry_pi_pico/

Code: Select all | TOGGLE FULL SIZE
import board
import busio
import displayio
import terminalio
import time
import adafruit_displayio_ssd1306
from adafruit_display_text import label

displayio.release_displays()

# the 128x32 ssd1306 are 0x3c (including the pioled)
oled_addr = 0x3c
i2c =  busio.I2C(board.GP17, board.GP16)
# connect to display
display_bus = displayio.I2CDisplay(i2c, device_address=oled_addr)
oled = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=32)

# text
splash = displayio.Group(max_size=10,)
oled.show(splash)
text_area = label.Label(terminalio.FONT, x=8, y=4,
   text="My name is SSD1306\nI speak I2C")
splash.append(text_area)
counter = label.Label(terminalio.FONT, x=100, y=24, text="0")
splash.append(counter)

counter_val = 0
while True:
   counter.text = f"{counter_val:4d}"
   counter_val += 1
   time.sleep(1)

neradoc
 
Posts: 11
Joined: Wed Apr 27, 2016 2:38 pm

Re: PICO and pioled 1306

by adafruit_support_carter on Mon Apr 05, 2021 2:23 pm

Yep, agree with everything above. I think a photo showing how you actually connected the Pi OLED to the PICO would help to start.

adafruit_support_carter
 
Posts: 20374
Joined: Tue Nov 29, 2016 2:45 pm

Re: PICO and pioled 1306

by genus1 on Wed Apr 07, 2021 2:00 pm

I had not connected the pioled 128x32 yet because the I was not sure of the power requirements of the part. I use it with the pi zero w simply fine because the header is on the part to connect to the riser on the pi zero. I read all the info on the 1306 and it is a 3.3v device. So, are the 5V pins 2 and 4 not connected in on the pioled or do they have a converter to ensure any input is converted to 3.3 for the pioled? If so, I would connect pin 2 and 4 of the pioled to pin 39 of the pico and pin 1 of the pioled to pin 36 of the pico. It is my understanding that the pico can take 1.8 to 5.5 volts on the USB which I plan to drive with a 3.3v battery to provide the system power. If no I will boost the battery to 5.2v before running into the USB.

My problem was in installing the correct libraries for the pico. I see no examples on Adafruit or elsewhere for the pico and pioled.

I initially tried to install adafruit-circuitpython-ssd1306 CircuitPython library for SSD1306 OLED displays in Thonny but got the error:
C:\Users\***\AppData\Local\Temp\tmp8o4k2rmb\
micropip returned with error code 1

I then tried using https://pypi.org/project/adafruit-circu ... n-ssd1306/ which I could not get the support software to load. I have looked at your example code and will try to implement to get the display working before going to my code. I have the newest circuit python for pico. but this implies you additionally need Bus_Device, Adafruit_framebuf, in addition to CircuitPython DisplayIO SSD1306. I am not sure if all these libraries are built into the circuitpython uf2.

More important than the software is the connection of the pioled pins to the pico pins. Please advise which pins and if I can run the USB with 3.3v battery.

genus1
 
Posts: 15
Joined: Wed Sep 26, 2018 11:54 pm

Re: PICO and pioled 1306

by adafruit_support_carter on Wed Apr 07, 2021 2:34 pm

Correct, the 5V pins are not used. Basic connections would be:

OLED 3.3V to PICO 3.3V
OLED GND to PICO GND
OLED SDA to *any* PICO I2Cx SDA
OLED SCL to *any* PICO I2Cx SCL

For the PICO SDA/SCL pins, just pick any two next to each other to make it easy. Like I2C0 SDA on Pin 1 and I2C0 SCL on Pin 2.

This is the correct CircuitPython library to use:
https://github.com/adafruit/Adafruit_Ci ... IO_SSD1306
More info:
https://learn.adafruit.com/monochrome-o ... thon-usage

adafruit_support_carter
 
Posts: 20374
Joined: Tue Nov 29, 2016 2:45 pm

Re: PICO and pioled 1306

by ralfada on Thu Apr 08, 2021 11:44 am

When compiling the Adafruit_SSD1306 lib in Arduino, the *Pico* compiler issues tons of the following warning:

In file included from ..\Arduino\libraries\Adafruit_SSD1306\Adafruit_SSD1306.cpp:54:
..\Arduino\libraries\Adafruit_SSD1306\splash.h:181:16: warning: 'B10110101' is deprecated: use 0b10110101 instead [-Wdeprecated-declarations]
181 | B11101101, B10110101, B01111110, B11100000,
| ^~~~~~~~~


best regards!

ralfada
 
Posts: 2
Joined: Thu Apr 08, 2021 11:40 am

Re: PICO and pioled 1306

by adafruit_support_carter on Thu Apr 08, 2021 12:10 pm

@ralfada Please start a new thread for your issue. That looks like Arduino, for which RP2040 support is still in works. This thread is about using the Pico and PiOLED with CircuitPython.

adafruit_support_carter
 
Posts: 20374
Joined: Tue Nov 29, 2016 2:45 pm

Re: PICO and pioled 1306

by genus1 on Thu Apr 08, 2021 8:09 pm

adafruit_support_carter wrote:Correct, the 5V pins are not used. Basic connections would be:

OLED 3.3V to PICO 3.3V
OLED GND to PICO GND
OLED SDA to *any* PICO I2Cx SDA
OLED SCL to *any* PICO I2Cx SCL

For the PICO SDA/SCL pins, just pick any two next to each other to make it easy. Like I2C0 SDA on Pin 1 and I2C0 SCL on Pin 2.

This is the correct CircuitPython library to use:
https://github.com/adafruit/Adafruit_Ci ... IO_SSD1306
More info:
https://learn.adafruit.com/monochrome-o ... thon-usage


Thank you for your support. This is exactly what I was looking for and needed confirmed.

genus1
 
Posts: 15
Joined: Wed Sep 26, 2018 11:54 pm

Re: PICO and pioled 1306

by genus1 on Sat Apr 10, 2021 10:31 pm

adafruit_support_carter wrote:Yep, agree with everything above. I think a photo showing how you actually connected the Pi OLED to the PICO would help to start.


This code does not run on the PICO.
Traceback (most recent call last):
File "<stdin>", line 13, in <module>
RuntimeError: No pull up found on SDA or SCL; check your wiring

Either the code needs correction OR the PiOLDE needs external pullup which are not indicated by directly plugging in the PiOLED to other 40 pin Raspberry Pi.

It should be noted the example for the PICO - Pico does not provide board.I2C(), board.SPI(), or board.UART() because nebulus.
i2c = busio.I2C(scl=board.GP17, sda=board.GP16) returns above wiring error.
Trying to define the pins as input with pull up does not work and because multiple masters are possible using OUTPUT is not an option.

Could someone please confirm they can run the above code as listed on a real PICO? Also this would lead to problems with uart and spi.

genus1
 
Posts: 15
Joined: Wed Sep 26, 2018 11:54 pm

Re: PICO and pioled 1306

by neradoc on Sun Apr 11, 2021 3:28 am

genus1 wrote:Either the code needs correction OR the PiOLDE needs external pullup which are not indicated by directly plugging in the PiOLED to other 40 pin Raspberry Pi.

Oooooh yeah, the raspberry Pis have pullups on their I2C pins, so the pioled doesn't have any it seems.
So yes you would need external pullups.

neradoc
 
Posts: 11
Joined: Wed Apr 27, 2016 2:38 pm

Re: PICO and pioled 1306

by genus1 on Sun Apr 11, 2021 9:03 pm

neradoc wrote:
genus1 wrote:Either the code needs correction OR the PiOLDE needs external pullup which are not indicated by directly plugging in the PiOLED to other 40 pin Raspberry Pi.

Oooooh yeah, the raspberry Pis have pullups on their I2C pins, so the pioled doesn't have any it seems.
So yes you would need external pullups.


However, the PICO has programmable pullup and down but I cannot get the code to work with i2c to the Pioled. I guess when declared as 12c the Pico expects a pullup. I guess the way to do it is just put them in and see if it works without programming pullups. Unfortunately I am on travel and will be a couple weeks before I can try it. Maybe someone can figure out if the code above is correct and just need to add physical pullups on the i2c pins.

genus1
 
Posts: 15
Joined: Wed Sep 26, 2018 11:54 pm

Please be positive and constructive with your questions and comments.