Circuit Python & RP2040
Posted by kll on October 13 2021 08:53:42
confused about status of several hard and soft - ware projects...
i want setup a other computer ( win 10 ) for work on
* Raspberry Pi PICO RP 2040
* on breadboard with a OLED display
what i got running already using CIRCUIT PYTHON

code
but failed with Arduino IDE 2.0 see here



QUICK SETUP:
https://learn.adafruit.com/welcome-to-circuitpython
https://circuitpython.org/board/raspberry_pi_pico/
https://circuitpython.org/libraries
https://codewith.mu/en/download

ok, that gives me ( in my windows 'Downloads' directory ):
RP2040_OLED_circuitpython.zip ( my above old project )
adafruit-circuitpython-raspberry_pi_pico-en_US-7.0.0.uf2
adafruit-circuitpython-bundle-7.x-mpy-20211011.zip
Mu-Editor-Win64-1.1.0b6.msi

-a- install MU
-b- connect the device
* * now here i see that i lost the last good config ( with testing Arduino IDE ) and need to
-c- flash Circuit Python again:
so disconnect USB, reconnect while pressing the PICO board 'BOOTSEL' button
( find here drive 'E:' with files INDEX.HTM and INFO_UF2.TXT )
and copy the 'adafruit-circuitpython-raspberry_pi_pico-en_US-7.0.0.uf2'
-d- copy old project
code.py
and get libs again, must use from NEW lib zip

but when from MU want restart by [Ctrl][d] get
ERROR________ try OLED
Traceback (most recent call last):
File "code.py", line 40, in
RuntimeError: No pull up found on SDA or SCL; check your wiring

hm.. check wiring,
* i do have the pull up resistors,
* but i did change the pins when i tested Arduino IDE to the so called DEFAULT PINS! what also not worked with that
code.py# flash: adafruit-circuitpython-raspberry_pi_pico-en_US-7.0.0.uf2
# from adafruit-circuitpython-bundle-7.x-mpy-20211011.zip copy

# adafruit_display_text
# adafruit_bus_device
# adafruit_register
# adafruit_ssd1306.mpy
# adafruit_framebuf.mpy

# from https://github.com/adafruit/Adafruit_CircuitPython_framebuf/blob/main/examples/font5x8.bin
# copy font5x8.bin
# to near code.py


import time
import board
print("________ Hallo World")
print(dir(board))

import digitalio

print("________ switch on PICO on board LED")
myled = digitalio.DigitalInOut(board.LED)
myled.direction = digitalio.Direction.OUTPUT
myled.value = True
time.sleep(2)
myled.value = False
time.sleep(2)
myled.value = True
#time.sleep(2)


print("________ try OLED")
import adafruit_ssd1306
import busio as io

# GP1 PICO pin2 I2C0 SCL // GP0 PICO pin1 I2C0 SDA
# i2c = io.I2C(scl=board.GP1,sda=board.GP0)
# this works from Circuit Python, but want change to DEFAULT PINS!
# GP5 PICO pin7 I2C0 SCL // GP4 PICO pin6 I2C0 SDA
i2c = io.I2C(scl=board.GP5,sda=board.GP4)

#RuntimeError: No pull up found on SDA or SCL; check your wiring
# use 10k to 3v3 each

# ,addr=0x3d #ValueError: No I2C device at address: 3d
#( for 128*64 OLED? )
oled = adafruit_ssd1306.SSD1306_I2C(128,32,i2c,addr=0x3c )
oled.fill(1)
#oled.show
#time.sleep(2)

#oled.pixel(10,0,0)
#oled.pixel(10,1,0)
#oled.pixel(10,2,0)
#oled.pixel(10,3,0)
#oled.pixel(10,4,0) # now i see that black line
oled.show()
# got first time the OLED to lit up ( and stay as long USB power )
print("________ see OLED white screen")
time.sleep(5)

oled.fill(0)
#from adafruit_display_text import label

oled.text('Line1: PICO OLED',0,0,1)
oled.text('Line2: 0123456789',0,11,1)
oled.text('Line3: qwertyuiop[]',0,22,1)
print("________ see OLED black screen with white 3 lines text")

oled.show()
time.sleep(5)

print("________ so far so good")


so, ready again, but when i see all my problems with
* project status
* hardware wiring
* code versions...
* add while copy files to PICO board AND edit THIS BLOG at the same time
** also had a 2 hour power fail and lost this text / type it again /
i wonder that i not throw it all out the window ? just having a bad day
now, isn't that normal?
but why not bother YOU with it?
actually i hate all that slick tutorial / videos
where all works after " i prepared that already for you "
and when we fail on the way, it makes us feel like idiots.



but part of this project was the also connected sensor AM2302 DHT22
what was already working prior to failing with the OLED at that time
ah, also with Circuit Python, good, so let's integrate this again.

looks like that ( new cheap ) breadboard connections ( and old cables ) not good,
but i managed to get the DHT running again,
even with a worthless humidity indication 99.9% ? raining in my room?
or dirt in the sensor?




code


now, in a next step, i try what was already working with the original PICO SDK,
a UART link to a ESP what is configured as a web server ( local LAN )


but as i first work little on the text formatting,
the idea was to copy/format the measuring numbers from Temp and Ain in to show-strings,
what i can use to send same to USB, OLED and later to WEB SERVER...

here i loose the DHT22 communication and had to stop.