Raspberry Pi Character LCD Degree Symbol

It is inevitable that you will want to write the degree symbol to your 16×2 character LCD once you have it wired to the Pi. My son wired it up, and then wanted to display the degree symbol. In the past I have solved that problem for the Arduino using the Adafruit character LCD Arduino library createChar() function. Relatively painless for the Arduino. Unfortunately, the Adafruit LCD library for GPIO not using i2c does not have an equivalent of the createChar() function. Sad.

The solution turns out to be easy. You rely on the fact that the LCD already has a degree symbol built in, and then use the write4bits() function to display it. There are other characters available, I found mine here. Here is our code.

# This is the process of importing the Adafruit library

os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')

temp_c = 23.1
temp_f = 32. + temp_c*9./5.

lcd.clear()
lcd.message(&quot;temp C&quot;)
lcd.write4bits( 0xDF, True)
lcd.message(&quot;: %.1fn&quot;%temp_c)

lcd.message(&quot;temp F&quot;)
lcd.write4bits( 0xDF, True)
lcd.message(&quot;: %.1f&quot;%temp_f)



2 thoughts on “Raspberry Pi Character LCD Degree Symbol”

1. Hi. I’m interested how you insalled the Adafruit_CharLCD library? Sound stupid but I can’t find the apt_get command for it?

Thanks

1. parkhays says:

That code is not distributed as a package that works with apt-get. The instructions on adafruit’s site show step-by-step how to get and install the software. Those instructions work even if you don’t use the LCD pi plate that adafruit sells. Try their instructions at