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
adafruitCharLCDPath = "/home/pi/pylib/AdafruitPy/Adafruit_CharLCD"
if not adafruitCharLCDPath in sys.path:
    sys.path.append( adafruitCharLCDPath)
    from Adafruit_CharLCD import Adafruit_CharLCD

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

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

lcd = Adafruit_CharLCD()
lcd.clear()
lcd.message("temp C")
lcd.write4bits( 0xDF, True)
lcd.message(": %.1fn"%temp_c)

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

 

2 thoughts on “Raspberry Pi Character LCD Degree Symbol”

    1. 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

Comments are closed.