Go Down

Topic: C° - How to get a degree sign on a text LCD screen? (Read 12181 times) previous topic - next topic


And on the lcd display that I have currently hooked up, the degree symbol is 0xF7.  0xDF gives me some strange character.

On the subject of piggybacking strings, you can always use sprintf().  eg:

char buf[80];
sprintf(buf,"The temperature is:  %d %c",temperature, 0xDF);

Strangely enough, on 1.6.7 the sprintf() function won't do floats.  %f only gives a question mark.  I haven't tried any other version.


Apr 21, 2016, 02:09 am Last Edit: Apr 21, 2016, 02:26 am by OldSteve
Strangely enough, on 1.6.7 the sprintf() function won't do floats.  %f only gives a question mark.  I haven't tried any other version.
Don't bother trying it with other versions - floats aren't automatically supported by Arduino for 'sprintf()', 'sprintf_P()' and other related functions.
The best way around this is to use 'dtostrf()' -> dtostrf()

Code: [Select]
void setup()
    float pi = 3.14;
    char buffer[50];
    char piTemp[5];
    char firstString[] = "This is";
    sprintf_P(buffer,PSTR("%s 'pi': %s"),firstString,piTemp);

void loop(){}
Please do not PM me for help. I am not a personal consultant.
And others will benefit as well if you post your question publicly on the forums.



More intrigue! I tried 0xF7 and got a wierd symbol. I have looked at what other people have used and most don't bother with the degree symbol. I have come to the conclution that the most professional looking symbol is a small octagonal in the right hand top corner (looks good) but this is a custom character. I have tried to include it in my code but I just keep getting a  0 so will have to be content with 223. I'm not sure why it won't work for me but suspect that it is because I am using the I2C modual and the LCD chip needs to be programed before this is added. Anyhow its all interesting stuff

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

byte degees[8] = {

void setup() {
  lcd.createChar(0, degrees);
  lcd.begin(16, 2); 

void loop() {}


The way I found it is writing each ascii code to the screen.

for(ii=128;ii<255;ii++) {
  sprintf(buf,"%d %c   ",ii,char(ii));

Now it would only show about 20 or so at a time, so I looked at each one then redid the start of the loop with the next number of what was displayed last.  0xF7 was the degree sign on this display.  No idea what it is on others I have here so it's not the most portable way to do it.


Strangely enough, on 1.6.7 the sprintf() function won't do floats.  %f only gives a question mark.  I haven't tried any other version.
Yes it does. And this really doesn't have to do with Arduino or the IDE.
However, the way the avr-gcc AVR libC was implemented, there are multiple versions of xxprintf() functions and by default the linker links in a version that does not support floating point formatting to save space.
You can change this by modifying the linker rules in the platform.txt file.
You just change the linker command options to tell it to link in the floating point version. See the avr libC documentation for the appropriate command options.
Just be aware that if you do this, you will add about 2k or so of code that will be pulled in regardless of whether you use floating point formatting or not whenever you use a xxprintf() function.

--- bill


It's getting a little too complicated for me bill.
My conclusion for any one who struggles to get a degree symbol is try the different character addresses
 223   0xDF   0xF7  and the different styles of writing the code    ((char)223);  etc. It seems that different LCDs use different addresses But you will find the right one with help from this forum. I'll keep trying to get that cute little octagonal. Also if your short of space you can actually fit both the degree and a smaller c or f into one segment.
My Lcd is now showing           21/04/2016
                                     16.50*C 05:12:50       I started off badly by using the wrong codes with the wrong libraries but managed to hack a code together which now has my RTC3231 and 16x2 LCD using the I2C to displaying Date, Temp & Time. The next step is to figure out how to switch some lights on and off at different times. I'll let my head cool down before starting on that one.     


"It seems that different LCDs use different addresses But you will find the right one . . ." by starting with the datasheet for your controller and following the technique explained in post #3.



Thanks Don, done it got the degree character I wanted it looks better than character 223. I created a custom character 0x6, 0x9, 0x9, 0x6, 0x0, 0x0, 0x0, with an address of 0

One thing is puzzling me how has michvhf got 0xF7 (247) to look anything like a degree sign? is it something I need to puzzle about?
Karma to you


Apr 22, 2016, 03:02 pm Last Edit: Apr 22, 2016, 03:37 pm by david_prentice
It just depends on which particular built-in Font ROM you have in your LCD module.

Every 16x2 or 20x4 that I have ever bought has got the standard "Japanese" character set in 128-255 (ROM Code A00).
It seems unfortunate that there are so many empty locations.

If you look at the HD44780 data sheet,   you can see the extended-Latin (ROM Code A02).    I guess that Russians might get Cyrillic characters.   Likewise Arabic,   Greek,  Chinese,  ...    OTOH,    you probably have to pay through the nose for the less common ROMs.

The A02 ROM looks like 0xB0 would be a reasonable degree symbol.   0xDF looks like a "Beta".
Nowadays,  you might just as will use custom Fonts with a small GLCD.



I've used the LCD character displays and successfully displayed the degree character. I created a string variable that I then used wherever I needed it:
Code: [Select]
//***special degree symbol
String degreeChar = String(char(223));// degree symbol needed for display

Additionally, if you want to see what shows up on your display as a function of the ascii character, try this code snippet:
Code: [Select]
     for(int i = 0;i < 256; ++i){
        Serial.print(" : ");
        Serial.println(char(i)); // so you can see the special character in your serial display
        lcd.print(char(i)); // this will print the special character to the lcd
        delay(250); // so you have time to look at the display

This will also give you an idea of the difference between what you see on the serial monitor and on the character LCD. Also, as was said previously there are a number of symbols built into the ROM of these displays, as well as being able to create your own custom symbol.

Go Up