Lcd printing this wierd simbol

I keep getting this wierd simbol when i try printing some data.

#include <SoftwareSerial.h>
SoftwareSerial esp8266(2,3); //TX, RX

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  esp8266.begin(9600);
  lcd.begin(); //LCD BEGIN
  lcd.backlight();
}
int positions[80];
String old_data="";
String data;
int numbero;
bool unread = false;
void loop() {
  bool cond = false;
     //Check to see if anything is available in the serial receive buffer
   while (esp8266.available()) {
    data = esp8266.readString();
    cond = true;
  }
  if(data != old_data && cond == true)
  {
    old_data = data;
    unread = true;
    Serial.println(data);
    while(data.indexOf("️") != -1)
    {
      int index =  data.indexOf("️");
      data.remove(index,3);
    }
    Serial.println(data);
    hearth();
    Serial.println(data);
    print_lcd();
  }
  
}
void print_lcd()
{
  lcd.clear();
  int j =20;
  for(int i = 0;i<=data.length();i+=20)
  {
    lcd.setCursor(0,i/20);
    lcd.print(data.substring(i,j));
    Serial.println(data.substring(i,j));
    j+=20;
  }
  for(int i = 0;i< numbero;i++)
  {
    int nr = positions[i]/20;
    lcd.setCursor(positions[i] - (20*nr),nr);
    lcd.print("&");
    Serial.println(positions[i]);
  }
  numbero = 0;
  memset(positions, 0, sizeof(positions));
}
void hearth()
{
    int index =  data.indexOf("❤");
    int of = 2;
    if(index != -1)
    {
      positions[numbero] = index;
      numbero++;
    }
    //Serial.println(index);
    //Serial.println(data.lastIndexOf("❤"));
    while(index != data.lastIndexOf("❤"))
    {
      index =  data.indexOf("❤",index + 1);
      //Serial.println(index - of);
      positions[numbero] = index - of;
      of += 2;
      numbero++;
    }
    data.replace("❤"," ");
}

When I test a display I write or use an example of a program that just tests the display and nothing else. Once I know that there are no issues with the display I start making the real program.
Can you be sure that your additional code is not causing your issue?

I have no idea what that code is supposed to mean!

The characters you see are the result of attempting to display on the LCD, a character value less than 0x20, that is to say a control character. This is usually due to using the non-functional "lcd.println()" but you do not appear to be making this error. I suspect you are displaying a NUL, but it could be some other value less than 0x20.

I guess that the heart symbol is a regular Unicode character which HTML treats as an UTF8 sequence.
The LiquidCrystal class inherits from Print. And I bet that Print does not understand UTF8.

You will get much the same anomalies if you attempt to print a Chinese or Cyrillic text.

David.

Yes, maybe i should do that.

The bit of code is suposed to take some data from my esp8266 and if it has a hearth emoji it will remove it form the data, and it will just keep the rest of the data and print it and in the photo in serial monitor i was getting test test and then this wierd simbol keeps coming up.

The Hello World example works so yea i think my code is the problem but i dont understand what rly,


the data seems alright in Serial monitor

Well i found out what it was the print loop was lopping one more time then i needed it to. :)). Thanks for all the help.

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