caractere non voulu sur LCD


Je voudrais lire les valeurs mesurées par mon détecteur de température/humidité DHT11 avec un écran LCD.

J’ai 2 petits problèmes.

  1. j’ai des zéro qui s’affichent en fin de ligne
    temperature :32*C0

j’ai mis un espace pour décaler les 0 “hors du lcd” et je ne les voie plus mais je ne comprend pas pourquoi ils sont là.

  1. le LCD affiche 32*C alors qu mon IDE affiche 23°C

j’ai un module DHT11 avec une résistance déja présente sur le circuit.

#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#include <LiquidCrystal.h>

#define DHTPIN 2

#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
const int rs = 12, en = 11, d4 = 6, d5 = 5, d6 = 4, d7 = 3;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

uint32_t delayMS;

void setup() {
// Initialize device.
sensor_t sensor;

// Set delay between sensor readings based on sensor details.
delayMS = sensor.min_delay / 1000;

void loop() {
// Delay between measurements.
// Get temperature event and print its value.
sensors_event_t event;
if (isnan(event.temperature)) {
Serial.println(“Error reading temperature!”);
else {
Serial.print(“Temperature: “);
Serial.println(” *C”);
// Get humidity event and print its value.
if (isnan(event.relative_humidity)) {
Serial.println(“Error reading humidity!”);
else {
Serial.print(“Humidity: “);

// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.setCursor(0, 0);
lcd.setCursor(6, 0);
lcd.setCursor(8, 0);
lcd.setCursor(0, 1);
lcd.setCursor(9, 1);
lcd.setCursor(11, 1);

Je viens de remarquer que la valeur de température lue sur le LCD est toujour égale à la valeur d’humidité…

This may not help but this code ...

 // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);

... should be in setup().


Merci pour la réponse mais malheureusement la lecture de température est toujours différente de l'IDE et est pareil que le retour d'humidité.

I don't speak French, I'm relying on Google translate!

Try this
EDIT: I redid this first part - I hope I got it right this time


  lcd.setCursor(6, 0);
  lcd.print("     ");


  lcd.setCursor(6, 0);

and insert

  lcd.setCursor(9, 1);
  lcd.print("     ");


  lcd.setCursor(9, 1);

These additions will 'erase' the old data before displaying the new data. See if that helps.


I fixed the bug with the 0, it is just that le reading is 23.00% or 23.00*C

But i tried your setup and the temperature reading value on the LCD is always egual to the humidity value,
and the temperature value on the IDE is différent.

I d'ont understand why the reading values are différent on the IDE and le LCD.

Post a copy of your revised code.

Also post either a photo or a good transcription of the corresponding values from some measurements as displayed on the serial monitor (IDE) and on your LCD.


There très a French forum elsewhere where you can also post in French

I believe your problem comes from the fact that each time you summon event.something there is a new reading of the sensor. So the sensor may provide a new value each time which may be different from the previous one. Also it seems there is a minimum delay between consecutive readings, but when you call an reading event (inside a serial.print for instance) you don't wait for this delay. Thus the sensor may not have enough time to make its reading and it provides false values. Maybe this is due to some ADC on the sensor board that requires some time...

Anyways, you should save the temperature and humidity values (that you would read only once in the loop) in specific variables, which you will then display on the LCD and the terminal.