Raspberry Pi Pico W LESSON 25: Getting Started with OLED 1306 in Micropython
ฝัง
- เผยแพร่เมื่อ 1 มิ.ย. 2024
- This is the OLED display we will be using in future lessons. Please go ahead and order it so you will have it for next week's lesson:
amzn.to/3nq8l4Z
You guys can help me out over at Patreon, and that will help me keep my gear updated, and help me keep this quality content coming:
/ paulmcwhorter
In this class we will be using the Sunfounder Raspberry Pi Pico W Keppler Kit. It will make things a lot easier if we are working on identical hardware. the link below is to amazon, and is for the identical hardware I will be using in this entire class.
amzn.to/3ubMRs1
In this introductory video, I will show you how to use the 1306 OLED display with the Raspberry Pi Pico W. We will show you step-by-step how to use this display. We will implement the project using micropython. Enjoy!
[Disclosure of Material Connection: I am a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com. ]
#raspberrypipicoW
#oled
#micropython - วิทยาศาสตร์และเทคโนโลยี
For those of you running into error messages. the below may help.
I solved this error message by running the I2C scanner, found my OLED is on 0x3d.
I didn't know how to specify the address which I guess in the example finds it by default.
What worked for me is:
oled = SSD1306_I2C(128,64,i2c,addr = 0x3d)
I hope this spares others the pain I had. I thank you all for your help. Much appreciated.
This is the error I was getting. Searching the internet, I see others had the same problems and all the posts I read just ended without satisfactory resolution.
MPY: soft reboot
Traceback (most recent call last):
File "", line 24, in
File "/lib/ssd1306.py", line 110, in __init__
File "/lib/ssd1306.py", line 36, in __init__
File "/lib/ssd1306.py", line 71, in init_display
File "/lib/ssd1306.py", line 115, in write_cmd
OSError: [Errno 5] EIO
Thanks for posting this very helpful solution!
Hi Paul, just quick note of thanks and encouragement. I am a retired EE trying to learn a few new tricks. I don;t normally like video tutorials - not how I learned for many years. Too many host with heavy British or Packi accents. I'm from the deep south and basically speak the King's English (the King is Elvis) We speak very slowly down here and most people don't know, we listen very slowly as well. As I age my hearing is flattening out making some dialogues difficult to follow. Yours is spot on for me!! A year or so or go I had two massive strokes. (according to brain scans - I had no idea) No motive issues - all damage inside my head - the attention span dropped dramatically and memory issues surfaced. Was writing Python code for medical products -but had to quit - added too much stress to trying to work and keep a schedule. Now that I'm coming back with the Arduino things are clearing up and making sense again. Your patient approach is very helpful. Keep it up and thanks again
I am legend. Figured out how to do this and like you I love these little displays. They have alot of capabilities to enhance projects and are fun to experiment with to boot. I don't post anything to youtube but I can assure you I was able to do this. Had to do some research. Thanks for a great series on pico w. No one on the internet can match your knowledge and teaching capabilites and explain things in a clear and concise way like you do !!!! Thanks again. You are the very BEST !!!!!
LEGEND!
Here is a solution to the non-working OLED issue many have been experiencing. After finding out that my uctronics OLED display works fine on the Arduino platform and is not discoverable (I2c.scan() returns null) on the pico w platform, I thought perhaps it is a voltage issue since Arduino runs 5V and pico 3.3V.
Problem solved by powering your OLED Vcc with 5V from any 5V source (eg. arduino board or breadboard power supply). Just remember to tie the grounds together (Pico w and other source).
This also allows you to use any of the I2C channels (0,1) ...
Bottom line its either a hardware issue specific to the UCtronics OLED which is sold on Amazon or the pico 3.3V is not quite 3.3V. The UCtronics OLED device documentation states it works 3.3 to 5V but apparently not.
Thanks Paul for your suggestion of I2C.scan()
So beautiful. The scenery. I mean The River Nile.
I replaced the OLED display with a new one and the circuit worked this time.
Thanks Paul! This was my longest lesson but most productive. Had to download the ssd1306 directly, without the tools menu and used pin 0 and 1 to make it work. Still here.
bravo Great Lesson. Thank You for taking the time to show the basic functions of the display/library.
Glad it was helpful!
great video Paul!
Thanks Paul! That was really cool.
Glad you liked it!
Loading ssd1306 does not work for me 12-07-23. Things must have changed, can anyone tell me the correct way to install? Thank you!
I just copied it and saved it as ssd1306.py
I got the same problem. not being able to download ssd1306. did you find any solution?
I AM LEGEND! I like the SSD1306 display. When I received mine I studied enough to learn its basic operation. My 50 pixel circle is missing a top and bottom, but my 25 pixel version fits the screen fine (although somewhat oval). Thanks Paul for showing us how to use this little display.
LEGEND!
Even though I think I followed all the steps exactly, my OLED display does not work and I do not know how to run the I2C scanner if that might help.
Traceback (most recent call last):
File "", line 1, in
ImportError: no module named 'ssd1306'
I have 2 dds1306(s). how do I change the address of the 2nd one so I can define both and have 2 different displays going? thank you.
Hello Paul! I have a couple of lcd displays lying around, could they work for this future lesson or should I get an oled screen instead?
I would really suggest get the OLED. It has major advantages over the LCD and is only about $5
@@paulmcwhorter Thanks, I'll get one
Looks like I messed up during my bought and got an SH1106 1.3" screen, gotta make it work with a different driver, cause my SSD1306 is really small, just 0.69"...
installing it come up with version 0.1.0 version only and error while loading it!
When I go to the package manager, and search ssd1306, I get this message. Could not find the package info from PyPl. Error code:
Your computer appears to be objecting to the security certificate of micropython. Find the library on github, ssd1306.py. Copy it and paste it into thonny. Then save the file to ssd1306.py on your pico. It should then be there for you to use.
"ImportError: no module named 'ssd1306'" does show up after copy and pasting it into thonny.
Hey Paul. A very off topic question. You appear to live in a dark sky area. Do you check out the stars, milky way, planets,nebula?
I had a telescope as a kid, but it never turned into a passion for me. So no, no atronomy going on here.
My OLED does not work with channel 1 Pins 2 and 3 (throws lots of ssd1306.py errors) but it does work channel 1 pins 6 and 7 as well as channel 0 pins 0 and 1
Great lesson!
What happened to that ant? 😂
😅
hello Paul. Do you have any courses about Django?
ssd1306 does not work by following your instructions, any help?
The installation failed in Thonny. I prefer VS Code. I created a venv in my work directory
python3.10 -m venv pico_code
cd pico_code
. bin/activate
python3.10 -m pip install pipkin
then with neither thonny or code connected
pipkin install micropython-ssd1306.
pipkin detects the Pico board and installs /lib/ssd1306.py
connect with VS Code and run the example.
it may have been my wiring but I wound up using I2C0 sda/scl on physical pins 1 and 2 so I have
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
The rest is the same.
I don't know why the install from Thonny failed There were a lot of cryptic errors. I had also downloaded ssd1306.py and copied that to the Pico. I think at that time I had a wiring problem since it failed in write_cmd()
It took a lot longer than it should have but I did learn about pipkin which seems to be a relatively easy way to install libraries without thonny.
For me channel 1 gives an [Errno 5] EIO error while channel 0 works fine.
Dont understand why, but seems some OLED only work on channel 0 for me. Not sure what is going on.
Just one symbol I want to share with you sir that is❤..
Here's my homework:
th-cam.com/video/zybl-Jmnm0I/w-d-xo.html
I made three:
th-cam.com/video/jW01OkOuoKE/w-d-xo.html
This is my favourite 👇 🌧 😌 :
th-cam.com/video/HBolAtKLQh4/w-d-xo.html
I also made this:
th-cam.com/video/EjdEA_PKU10/w-d-xo.html
I think it's cool 😎 anyhow 🤷
Here is my deep dive into ways to plot a circle. th-cam.com/video/3VroWb0Zr3g/w-d-xo.html
I show 6 different algorithms and time each to see which is fastest.
Very interesting. Lots of ways to skin this cat.
down loading ssd1306 does not work.
Looks like I am 3rd to post a video showing the the built in method. th-cam.com/video/mg9fBHhFQmw/w-d-xo.html
Charlotte and Lori got the jump on me as I was doing a deep dive into ways to code a raster circle. That video will post shortly.
Thanks Paul for all you do.
Kudos for the comprehensible explanation! But did you realize you had a bug? 😁 You can clearly see it escaping from the display to the right at th-cam.com/video/6SdNvqofWww/w-d-xo.html
Great video. Thanks.
Redid it based on Paul's suggestion. th-cam.com/video/4lWXIBPwA8c/w-d-xo.html
LEGEND!
At 17m30s I think I saw a bug in the system😁
Hi. I'm new to pi Pico. I have some successful programs running ssd1306 oleds 128*32 and 64*32. I've recently purchased some 96*32 and they appear to be ssd1316. When I treat them as 1306 the image is stretched and backwards, any help welcome. Also have some 128*64 on the way ssd1315, am I likely to see same issues on these?
Thank you for the amazing lesson! This homework took me a while. Anyways - here is my homework assignment: th-cam.com/video/yOo-CS_V3mo/w-d-xo.html
You resemble James Cameron
Hey, Paul! More great content from you, as usual. Thank you. Here is my solution to the homework:
th-cam.com/video/OzgJsiFD8aQ/w-d-xo.html
LEGEND!
Nice job. Thanks for all the mentions but I have not posted my video yet. I am digging way too deep on this. I think my comment thread on William's video might have confused you.
Didn't know the match to generate the points of a circle so had to look it up which effectively gave the whole solution - not sure that is worthy of posting a video for what would have effectively been a copy and paste...... Found 2 solutions - one for a filled circle and the other just for the outline. Here is the solution for the record th-cam.com/video/h_NTJzXIz94/w-d-xo.html
LEGEND!
I'm not uploading a video since I let BARD (Google's AI) helped me with the solution. BARD gave me a function for a filled circle. Changing the
Interesting approach, and very different than my solution. Mine is based more on simple math. This is sort of try all possibilities, and keep the ones that match the conditions.
@@paulmcwhorter OK simple as in easy math to code or simple as in NOT needing the math module? I took a deep dive and I am trying to wrap my mind around midpoint circle algorithm and the Bresenham circle algorithm that use addition, subtraction and multiplication to define the pixels for a circle.
Really, I see the simple way to do it is just step through the angles 0 to 360 and then calculate the x and y value of each pixel. x=r*cos(angle) and y=r*sin(angle). Simple as that. All the solutions I have seen so far do special cases for the different quadrants, but above approach does it all in one for loop. You do need to then adjust x and y to get the circle in the middle of the display.
@@paulmcwhorter Yes that will work ok with the more powerful mcu like the Pico. Doing 360 sin and cos functions can slow an old 8 bit mcu down even in Arduino C++. I am going to try doing some timings for the different algorithms and post a video. Someone used the sin and cos method to draw a small circle for the degree symbol. Because it was so small the circle was represented by maybe a dozen pixels. It worked but that was a lot of processing for so few dots.
@@paulmcwhorter You haven't introduced any math libraries. I was planning to give a Sunfounder kit to my 11 year old great grandson and suggest the course to him. I doubt that he has had any trig.
using identical hardware and library/ code we get library error
File "", line 7, in
File "/lib/ssd1306.py", line 110, in __init__
File "/lib/ssd1306.py", line 36, in __init__
File "/lib/ssd1306.py", line 71, in init_display
File "/lib/ssd1306.py", line 115, in write_cmd
Anyone have suggestions! I even tried a second new 1306 display!
A bit "under the weather" this week. Finally got this homework done. Thanks for the lesson Paul! th-cam.com/video/-lTU_bQyTZU/w-d-xo.html
Love these displays. Can't take credit for this homework. New the circle math involved sin and cos but could not remember it and had to google for the calculations. Then had to study them and understand before using. homework th-cam.com/video/0_cbYYYt7hg/w-d-xo.html
What a wonderful little display at the right hobby price. 🪐 Thank you.
this PRIME day 2023 sales on KEPLER kit!