Can't write º symbol on ºC temperature on TFT Shield

Hi
Just write a sketch to write on the lcd touchscreen the temperature sensor readings. All works fine except for this symbol " º " . Only for testing I use tft.print("-88,88 ºC"); and only prints "-88.88 C" How can I write this symbol on the screen?

My hardware: Arduino Uno V3 ; TFT touchscreen mcufriend.

Thanks!

I think that the TFT display is only a graphical display and the font is in software. Perhaps the libraries that you use have an option to select an other font with special characters.

2 Likes

Try:

  tft.print(char(248));

More extended ASCII:

void setup() {
  tft.begin();
  int j = 0;
  for (int i = 127; i < 288; i++) {
    if (i < 100)
      tft.print(" ");
    if (i < 10)
      tft.print(" ");
    tft.print(i);
    tft.print("=");
    if (i == 266) // linefeed
      tft.print(" ");
    else
      tft.print(char(i));
    if (j++ == 5) {
      j = 0;
      tft.print("\n");
    } else {
      tft.print("  ");
    }
  }
}
void loop() {}
1 Like

@horacles111 @xfpd Hi there,
I also had the same problem with my tft, I'm using an ILI9341 320x240 from Adafruit and couldn't write the ° on the tft, there are a few ways to draw it depending on the library used or the tft I guess, try this:

  tft.setCursor(20, 40, 2);
  tft.print("`");  // prints ° sometimes
  tft.print("÷");  // prints ° sometimes
  tft.print(0xDF); 
  tft.print("\xC2\xB0");
  tft.print(char(174));
  tft.print("C");

I'm using the tft_eSPI library

#include <TFT_eSPI.h>     // Graphics and fonts library for 32 bit processors
TFT_eSPI tft = TFT_eSPI();

One of these will have to do the job :slightly_smiling_face:

1 Like

When the Adafruit GFX library is used, then here is a picture that shows all the characters of the default font: https://learn.adafruit.com/adafruit-gfx-graphics-library/graphics-primitives#extended-characters-cp437-and-a-lurking-bug-3100368 (scroll down a little more).

Character 0xF7 is the degrees symbol.

Sketch:

#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>

Adafruit_ILI9341 tft = Adafruit_ILI9341(10, 9);

void setup() 
{
  tft.begin();
  tft.setTextSize(2);
  tft.print("+23.45 ");
  tft.write(0xF7);     // or tft.print("\xF7");
  tft.println("C");
}

void loop() {}

Result (with help of Wokwi):
afbeelding

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.