{"id":4986,"date":"2026-08-30T01:40:38","date_gmt":"2026-08-29T16:40:38","guid":{"rendered":"https:\/\/donguri3.net\/server-tech\/ssd1306-oled-display-hello-world-rp2040-zero-2\/"},"modified":"2026-08-30T01:40:40","modified_gmt":"2026-08-29T16:40:40","slug":"ssd1306-oled-display-hello-world-rp2040-zero","status":"publish","type":"post","link":"https:\/\/donguri3.net\/en\/diy-repair\/electronics-microcontroller\/ssd1306-oled-display-hello-world-rp2040-zero\/","title":{"rendered":"Displaying &#8220;Hello, World!&#8221; on an SSD1306 OLED Display with an RP2040-Zero Compatible Board"},"content":{"rendered":"<p>In this article, we will introduce how to display &#8220;Hello, World!&#8221; on an SSD1306 OLED display using MicroPython with a Raspberry Pi Pico (or RP2040-zero) powered by the RP2040. Additionally, as a troubleshooting case study, we will explain an error that occurred due to insufficient soldering on the RP2040-zero pins, which prevented power from reaching the display.<\/p>\n<hr \/>\n<h2>Prerequisites<\/h2>\n<ul>\n<li>\n<p><strong>Raspberry Pi Pico \/ RP2040-zero<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>SSD1306 OLED Display<\/strong><br \/>*Uses I2C connection.<\/p>\n<\/li>\n<li>\n<p><strong>Jumper Wires, Breadboard<\/strong> (or an environment for direct wiring)<\/p>\n<\/li>\n<li>\n<p><strong>Thonny IDE<\/strong> (IDE for MicroPython)<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h2>Installing the SSD1306 Library<\/h2>\n<p>The MicroPython standard library does not include the SSD1306 library by default. Therefore, we will use Thonny to install the library.<\/p>\n<ol>\n<li>\n<p><strong>Launch Thonny<\/strong><br \/>Connect your Raspberry Pi Pico to your PC and launch Thonny.<\/p>\n<\/li>\n<li>\n<p><strong>Tools &gt; Manage packages<\/strong><br \/>Select &#8220;Tools&#8221; &rarr; &#8220;Manage packages&#8230;&#8221; from the top menu.<br \/>\n<a href=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/4fb951c4d6d5b44ce4f6c0df1f98198f.png\"><img decoding=\"async\" class=\"aligncenter wp-image-875 size-full\" src=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/4fb951c4d6d5b44ce4f6c0df1f98198f.png\" alt=\"Manage packages in Thonny\" width=\"867\" height=\"619\" srcset=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/4fb951c4d6d5b44ce4f6c0df1f98198f.png 867w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/4fb951c4d6d5b44ce4f6c0df1f98198f-300x214.png 300w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/4fb951c4d6d5b44ce4f6c0df1f98198f-768x548.png 768w\" sizes=\"(max-width: 867px) 100vw, 867px\" \/><\/a><\/p>\n<\/li>\n<li>\n<p><strong>Type &#8220;ssd1306&#8221; in the search box<\/strong><br \/>Type &#8220;ssd1306&#8221; into the search box and run the search.<br \/>\n<a href=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/1181badc044b1a43985a89054fa7d8c0.png\"><img decoding=\"async\" class=\"aligncenter wp-image-876 size-full\" src=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/1181badc044b1a43985a89054fa7d8c0.png\" alt=\"Search for ssd1306 package\" width=\"639\" height=\"461\" srcset=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/1181badc044b1a43985a89054fa7d8c0.png 639w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/1181badc044b1a43985a89054fa7d8c0-300x216.png 300w\" sizes=\"(max-width: 639px) 100vw, 639px\" \/><\/a><\/p>\n<\/li>\n<li>\n<p><strong>Select and Install the Library<\/strong><br \/>Select &#8220;ssd1306&#8221; from the search results and click the install button.<br \/>\n<a href=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/94d9e3124af85bb2bb7c3c0907eee166.png\"><img decoding=\"async\" class=\"aligncenter wp-image-877 size-full\" src=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/94d9e3124af85bb2bb7c3c0907eee166.png\" alt=\"Install ssd1306 package\" width=\"639\" height=\"461\" srcset=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/94d9e3124af85bb2bb7c3c0907eee166.png 639w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/94d9e3124af85bb2bb7c3c0907eee166-300x216.png 300w\" sizes=\"(max-width: 639px) 100vw, 639px\" \/><\/a><br \/>Once the installation is complete, verify that <code>lib\/ssd1306.py<\/code> has been created by going to &#8220;View &gt; Files&#8221; on the Raspberry Pi Pico.<br \/>\n<a href=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/1da92789a8347e329869bfa94985c432-e1741584145973.png\"><img decoding=\"async\" class=\"aligncenter wp-image-880 size-full\" src=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/1da92789a8347e329869bfa94985c432-e1741584145973.png\" alt=\"ssd1306 library\" width=\"272\" height=\"464\" srcset=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/1da92789a8347e329869bfa94985c432-e1741584145973.png 272w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/1da92789a8347e329869bfa94985c432-e1741584145973-176x300.png 176w\" sizes=\"(max-width: 272px) 100vw, 272px\" \/><\/a><\/p>\n<\/li>\n<\/ol>\n<hr \/>\n<h2>Creating main.py and Writing the Code<\/h2>\n<p>Copy the following code into a new file in Thonny and save it as <code>main.py<\/code> on the Raspberry Pi Pico.<\/p>\n<pre>from machine import Pin, I2C\nimport ssd1306\n\n# using default address 0x3C\ni2c = I2C(1, sda=Pin(14), scl=Pin(15))\ndisplay = ssd1306.SSD1306_I2C(128, 32, i2c, addr=0x3C)\n\n# Print Hello World on the first line\ndisplay.text('Hello, World!', 0, 0, 1)\ndisplay.show()<\/pre>\n<p>Key points of this code:<\/p>\n<ul>\n<li>\n<figure id=\"attachment_866\" aria-describedby=\"caption-attachment-866\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/1-1.png\"><img decoding=\"async\" class=\"wp-image-866 size-full\" src=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/1-1.png\" alt=\"Pin assignment of the RP2040-zero clone\" width=\"1024\" height=\"768\" srcset=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/1-1.png 1024w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/1-1-300x225.png 300w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/1-1-768x576.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-866\" class=\"wp-caption-text\">Pin assignment of the RP2040-zero clone<\/figcaption><\/figure>\n<p><strong>I2C Initialization<\/strong><br \/>Uses I2C ID 1, with <code>Pin(14)<\/code> and <code>Pin(15)<\/code> as SDA and SCL respectively. Please check the pin assignments for your specific board; pins 14 and 15 on the RP2040-zero correspond to I2C1, hence the value 1. The display&#8217;s I2C address is <code>0x3C<\/code> (you can verify this with <code>i2c.scan()<\/code> if necessary).<\/p>\n<\/li>\n<li>\n<p><strong>Using the ssd1306 Library<\/strong><br \/>Imports the installed library and creates an SSD1306 display object.<\/p>\n<\/li>\n<li>\n<p><strong>Displaying Text<\/strong><br \/>Displays &#8220;Hello, World!&#8221; on the first line using <code>display.text<\/code> and updates the display with <code>display.show()<\/code>.<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h2>Execution Results<\/h2>\n<p>Running this <code>main.py<\/code> will display the text &#8220;Hello, World!&#8221; on the SSD1306 display.<br \/>\n<a href=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/IMG_15791-scaled-e1741655802989.jpg\"><img decoding=\"async\" class=\"aligncenter wp-image-878 size-large\" src=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/IMG_15791-scaled-e1741655802989-1024x768.jpg\" alt=\"I2C display with RP2040-zero\" width=\"1024\" height=\"768\" srcset=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/IMG_15791-scaled-e1741655802989-1024x768.jpg 1024w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/IMG_15791-scaled-e1741655802989-300x225.jpg 300w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/IMG_15791-scaled-e1741655802989-768x576.jpg 768w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/IMG_15791-scaled-e1741655802989-1536x1152.jpg 1536w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/IMG_15791-scaled-e1741655802989-2048x1536.jpg 2048w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/IMG_15791-scaled-e1741655802989-530x398.jpg 530w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/IMG_15791-scaled-e1741655802989-565x424.jpg 565w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/IMG_15791-scaled-e1741655802989-710x533.jpg 710w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/IMG_15791-scaled-e1741655802989-725x544.jpg 725w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/IMG_15791-scaled-e1741655802989.jpg 1920w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<hr \/>\n<h2>Troubleshooting<\/h2>\n<p>Actually, when I initially skipped soldering the RP2040-zero pins and just plugged it into a breadboard, I encountered the following error:<\/p>\n<pre>Traceback (most recent call last):\n  File \"\", line 6, in \n  File \"\/lib\/ssd1306.py\", line 119, in __init__\n  File \"\/lib\/ssd1306.py\", line 38, in __init__\n  File \"\/lib\/ssd1306.py\", line 75, in init_display\n  File \"\/lib\/ssd1306.py\", line 124, in write_cmd\nOSError: [Errno 5] EIO<\/pre>\n<p>The cause was that the OLED display was not receiving power. By soldering properly and ensuring that each pin is securely connected, the error will be resolved and it will function correctly.<\/p>\n<h2>References<\/h2>\n<ul>\n<li>class I2C<br \/>\n<a href=\"https:\/\/docs.micropython.org\/en\/latest\/library\/machine.I2C.html\">class I2C \u2013 a two-wire serial protocol \u2014 MicroPython latest documentation<\/a><\/li>\n<li>SSD1306 OLED Library<br \/>\n<a href=\"https:\/\/micropython-docs-ja.readthedocs.io\/ja\/latest\/esp8266\/tutorial\/ssd1306.html\">14. Using the SSD1306 OLED Display \u2014 MicroPython latest documentation (Japanese)<\/a><\/li>\n<\/ul>\n<hr \/>\n<h2>Summary<\/h2>\n<ol>\n<li>\n<p><strong>Installing the ssd1306 Library<\/strong><br \/>Easily installed using Thonny&#8217;s package management feature.<\/p>\n<\/li>\n<li>\n<p><strong>Writing main.py<\/strong><br \/>Initializing I2C, creating the display object, and displaying text is very straightforward.<\/p>\n<\/li>\n<li>\n<p><strong>Troubleshooting<\/strong><br \/>It is important to carefully check the hardware side (soldering, wiring, pull-up resistors).<\/p>\n<\/li>\n<\/ol>\n<p>This completes the basic steps for displaying &#8220;Hello, World!&#8221; on an SSD1306 OLED display using the Raspberry Pi Pico. Feel free to use this content as a base to try out various display contents!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will introduce how to display &#8220;Hello, World!&#8221; on an SSD1306 OLED display using [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":878,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"en_US","_original_post":"https:\/\/donguri3.net\/?p=879","footnotes":""},"categories":[1163],"tags":[265,47,277,262,321,272,325,274],"class_list":["post-4986","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-electronics-microcontroller","tag-micropython","tag-python","tag-raspberry-pi-pico","tag-rp2040-zero","tag-ssd1306","tag-thonny","tag-325","tag-274","en-US"],"_links":{"self":[{"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/posts\/4986","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/comments?post=4986"}],"version-history":[{"count":1,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/posts\/4986\/revisions"}],"predecessor-version":[{"id":4989,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/posts\/4986\/revisions\/4989"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/media\/878"}],"wp:attachment":[{"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/media?parent=4986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/categories?post=4986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/tags?post=4986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}