Skip to content

Character encoding problem with Serial Monitor #1405

Closed as not planned
Closed as not planned
@nbourre

Description

@nbourre

Describe the problem

When using serial printing accented characters or ASCII higher than 127, the serial monitor mostly shows a "�", but not always.

Arduino_IDE_VKSKSsA35p

To reproduce

Serial.print accented characters or ASCII with values higher than 127.

E.g.:

    Serial.print("Humidité: ");
    Serial.print(h);
    Serial.print(("%  Température: "));
    Serial.print(t);
    Serial.print(("° C "));
    Serial.print(("Humidex : "));
    Serial.print(humidex);
    Serial.println(("° C "));

Expected behavior

The serial monitor should show the characters in the right encoding or at least UTF-8.

Arduino IDE version

2.0.0-rc9.3

Operating system

Windows

Operating system version

11

Additional context

Full code example :

#include <DHT.h>

// Broche de données
#define DHTPIN 2

// Type de capteur pour la librairie
#define DHTTYPE DHT11  // DHT 11

// Déclaration de l'objet
DHT dht(DHTPIN, DHTTYPE);

long currentTime = 0;
long dhtPrevious = 0;
long dhtDelay = 1000;

void setup() {
  Serial.begin(9600);
  Serial.println(F("DHTxx test!"));

  dht.begin();  // Initialisation

  currentTime = millis();
}

void loop() {
  currentTime = millis();

  if (currentTime - dhtPrevious >= dhtDelay) {
    dhtPrevious = currentTime;

    float h = dht.readHumidity();
    float t = dht.readTemperature();
    float humidex = dht.computeHeatIndex(t, h, false);

    Serial.print("Humidité: ");
    Serial.print(h);
    Serial.print(("%  Température: "));
    Serial.print(t);
    Serial.print(("° C "));
    Serial.print(("Humidex : "));
    Serial.print(humidex);
    Serial.println(("° C "));
  }
}

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions