---
slug: "RaspberryPiで、128x64OLEDLCDディスプレイを動作させる"
title: "Operating a 128x64 OLED LCD Display with Raspberry Pi"
description: "\n\n\n\nAn impulse purchase from Amazon: a 128x64 OLED LCD display"
url: "https://www.ytyng.com/en/blog/RaspberryPiで、128x64OLEDLCDディスプレイを動作させる"
publish_date: "2015-08-16T15:19:47Z"
created: "2015-08-16T15:19:47Z"
updated: "2026-02-27T10:43:51.660Z"
categories: ["Raspberry-Pi"]
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20230812/7cada2dec88e47babc77e0938dbf4c41.png.webp?width=768"
has_video: false
has_music: false
video_urls: []
music_urls: []
lang: "en"
---

# Operating a 128x64 OLED LCD Display with Raspberry Pi

<div class="document">


<img alt="http://ytyng.com/picture/raspberry-pi/u8g/IMG_4613.jpg" src="http://ytyng.com/picture/raspberry-pi/u8g/IMG_4613.jpg"/>
<p>An impulse purchase from Amazon: a 128x64 OLED LCD display</p>
<p><a class="reference external" href="http://www.amazon.co.jp/dp/B00XDY2SR8">http://www.amazon.co.jp/dp/B00XDY2SR8</a></p>
<p>Connecting it to a Raspberry PI via I2C and getting it to work.</p>
<p>SSD1306?</p>
<div class="section" id="raspberry-pi-i2c">
<h3>1. Enabling I2C on the Raspberry PI</h3>
<pre class="literal-block">$ sudo raspi-config
</pre>
<p>→ Advanced Options → I2C → Yes</p>
<p>After setting, restart the device</p>
<p>There are various methods depending on the model and the time period, so choose the one that suits your setup.</p>
<p>Reference: `Enabling I2C on recent Raspberry Pis - Rabbit Note &lt;<a class="reference external" href="http://rabbit-note.com/2015/02/08/raspberry-pi-i2c-activation/">http://rabbit-note.com/2015/02/08/raspberry-pi-i2c-activation/</a>&gt;`_</p>
<p>Also, install i2c-tools</p>
<pre class="literal-block">$ sudo apt-get install i2c-tools
</pre>
</div>
<div class="section" id="lcd">
<h3>2. Connect and Verify the LCD Display</h3>
<p>2-1. Run i2cdetect with the display not connected</p>
<pre class="literal-block">$ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
</pre>
<p>2-2. Connect the display. There are various images showing which pins to use; for instance, refer to this:</p>
<p>Using I2C on the Raspberry Pi: Using a Temperature Sensor - Neko Punch!</p>
<p><a class="reference external" href="http://d.hatena.ne.jp/penkoba/20131215/1387119945">http://d.hatena.ne.jp/penkoba/20131215/1387119945</a></p>
<p>2-3. Run i2cdetect after connecting the display</p>
<pre class="literal-block">$ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- UU 3c -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
</pre>
<p>It is recognized at 3c.</p>
</div>
<div class="section" id="wiring-pi">
<h3>3. Install wiringPi</h3>
<pre class="literal-block">$ git clone git://git.drogon.net/wiringPi
$ ./build
</pre>
<p>Testing</p>
<pre class="literal-block">$ gpio -v
$ gpio readall
</pre>
</div>
<div class="section" id="u8glib">
<h3>4. Install u8glib</h3>
<p>Build and use the commonly used Arduino library on the Raspberry Pi</p>
<p>Issue 171 - u8glib - Port U8glib to Raspberry Pi - Universal Graphics Library for 8 Bit Embedded Systems - Google Project Hosting</p>
<p><a class="reference external" href="https://code.google.com/p/u8glib/issues/detail?id=171">https://code.google.com/p/u8glib/issues/detail?id=171</a></p>
<p>Refer to the page above.</p>
<pre class="literal-block">$ cd /tmp/
$ wget http://dl.bintray.com/olikraus/u8glib/u8glib_arduino_v1.16.zip
$ unzip u8glib_arduino_v1.16.zip
</pre>
<p>Get the patch posted on the site below (the same page as above)</p>
<p><a class="reference external" href="https://code.google.com/p/u8glib/issues/detail?id=171">https://code.google.com/p/u8glib/issues/detail?id=171</a></p>
<p>Get the #24 patch u8glib_1.16.RaspberryPi.patch.</p>
<p>Copy the URL and use wget on the Raspberry Pi, or download it on your PC and send it via sftp etc.</p>
<p>Save it as /tmp/u8glib_1.16.RaspberryPi.patch.</p>
<pre class="literal-block">$ cd /tmp/U8glib/
$ patch -p1 &lt; /tmp/u8glib_1.16.RaspberryPi.patch
$ make
$ sudo cp libU8glib.a /usr/lib
$ sudo cp U8glib.h /usr/include
$ sudo mkdir /usr/include/utility
$ sudo cp /tmp/U8glib/utility/u8g.h /usr/include/utility/
</pre>
</div>
<div class="section" id="id1">
<h3>5. Run the Demo</h3>
<pre class="literal-block">$ cd /tmp/U8glib/examples/U8gLogo
$ vim Makefile
</pre>
<pre class="literal-block"># INCLUDE=/opt/U8glib/include
INCLUDE=/tmp/U8glib/include
</pre>
<p>↑ Rewrite the INCLUDE line</p>
<pre class="literal-block">$ make
$ ./logo
</pre>
<img alt="http://ytyng.com/picture/raspberry-pi/u8g/IMG_4613.jpg" src="http://ytyng.com/picture/raspberry-pi/u8g/IMG_4613.jpg"/>
</div>
<div class="section" id="python">
<h3>6. Using it with Python...</h3>
<p>Code writing in progress</p>
</div>
</div>
