Reading text from sd card is returning weird characters?

Kara 08/17/2018. 1 answers, 99 views
lcd sd-card display

I have an ebook which is converted to a .txt file saved on an sd card which is connected to the arduino. I'm trying to display the words from the book on a 16x2 lcd display on word at a time. It works mostly except when it reads a word that has an apostrophe or a pipe symbol it does not display correctly to the lcd display or the serial output.

For example the word "author's" will be displayed as "authorâs" (edit: there is actually two boxes between the "â" and the s that is not displaying on this forum) on both the lcd display and serial output.

I've spent an entire day now with this one problem hopefully there is a mistake someone can pick up on :/

#include <LiquidCrystal.h>
#include <SPI.h>
#include <SD.h>

const int chipSelect = 53;

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

char nextChar;
String wordBuffer = "";

void setup() {

  lcd.begin(16, 2);

  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only

  Serial.print("Initializing SD card...");

  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    while (1);
  Serial.println("card initialized.");

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  File dataFile ="datalog.txt");

  if (dataFile) {
    while (dataFile.available()) {

      nextChar =;
      if (isWhitespace(nextChar)){





        wordBuffer = "";


        wordBuffer = wordBuffer + nextChar;

  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening datalog.txt");

void loop() {

1 Answers

Majenko 08/17/2018.

The text file is not ASCII, it is UTF-8. You will either have to convert it to pure ASCII, or write (or obtain) a conversion routine to approximate the UTF-8 characters using ASCII on the Arduino.

Maybe this can help you. - Download Hi-Res Songs


Birthday Party flac

AJR. 2019. Writer: Adam Met;Jack Met;Ryan Met;Peter Ivers;David Lynch.
2 Loote

Your Side Of The Bed flac

Loote. 2018. Writer: ​Jesse Saint John;Jackson Foote;Emma Lov Block.

100 Bad Days flac

AJR. 2019. Writer: Jack Met;Adam Met;Ryan Met.
4 Joe Jonas

Longer Than I Thought flac

Joe Jonas. 2018. Writer: Patrick Nissley;Jackson Foote;Dave Katz.
5 Loote

Out Of My Head flac

Loote. 2018. Writer: Emma Lov Block;Michael Pollack;Jeremy Dussolliet;Jackson Foote.
6 Iselin Solheim

Anyone Out There flac

Iselin Solheim. 2019. Writer: Iselin Solheim;Max Grahn.
7 Loote

Wish I Never Met You flac

Loote. 2018. Writer: Jackson Foote;Alex Peter Koste;Jeremy Dussolliet;Emma Lov Block.
8 Kim Petras

Heart To Break flac

Kim Petras. 2018. Writer: Cirkut;Aaron Joseph;Dr. Luke;Jacob Kasher;Kim Petras.
9 A L E X

Out On The Trampoline At Night flac

A L E X. 2018. Writer: A L E X.
10 A L E X

I Want To Hold Your Hand flac

A L E X. 2018. Writer: A L E X.
11 A L E X

Field flac

A L E X. 2018. Writer: A L E X.
12 A L E X

Save Me flac

A L E X. 2018. Writer: A L E X.
13 Devin

Summer Lover flac

Devin. 2019. Writer: Tommy Lee James;Stuart Crichton;Oliver Heldens;Nile Rodgers;Devin Guisande.
14 A L E X

9 To 5 flac

A L E X. 2018. Writer: A L E X.
15 A L E X

Skirt flac

A L E X. 2018. Writer: A L E X.
16 Florian Picasso

Midnight Sun (Extended Version) flac

Florian Picasso. 2019.
17 Florian Picasso

Midnight Sun flac

Florian Picasso. 2019.
18 21 Savage

Enzo flac

21 Savage. 2019. Writer: YungLunchBox;Sheck Wes;Offset;Gucci Mane;21 Savage;DJ Snake.
19 Tales Of Ratatösk

Battle Of The Doomed Gods 320kbps

Tales Of Ratatösk. 2019.
20 Tales Of Ratatösk

Andro 320kbps

Tales Of Ratatösk. 2019.

Related questions

Hot questions


Popular Tags