1

I have written a simple sketch that displays temperature and humidity on a 16x2 LCD. Here's its output:

Temp: 28▒▒
Humidity: 68▒▒

The library I used for DHT11 sensor is not from Adafruit. This is the sketch:

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include<dht.h>

#define DHT11_PIN 12
#define I2C_ADDR       0x3F
#define BACKLIGHT_PIN  3
#define En_pin         2
#define Rw_pin         1
#define Rs_pin         0
#define D4_pin         4
#define D5_pin         5
#define D6_pin         6
#define D7_pin         7
#define SCL_PIN        12
#define SDO_PIN        11

dht DHT;
LiquidCrystal_I2C  lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin);

void setup() {
  pinMode(SCL_PIN, OUTPUT);
  pinMode(SDO_PIN, INPUT);
  lcd.begin (16, 2);
  lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
  lcd.setBacklight(HIGH);
  lcd.home ();
}

void loop() {
  lcd.setCursor(0, 0);
  int chk = DHT.read11(DHT11_PIN);
  lcd.print("Temp: ");
  lcd.println(DHT.temperature,0);
  lcd.setCursor(0, 1);
  lcd.print("Humidity: ");
  lcd.println(DHT.humidity,0);
  delay(2000);
}
  • You say “The library... is not from Adafruit”, which is not helpful -- instead, say which DHT11 library you are using. Without that info, one doesn't know the declarations of DHT.temperature and DHT.humidity, hence doesn't know which println() was invoked and what it does with second param which causes a character in the range 0 to 7, the custom character generator codes, to print. Please edit your question to include that info – James Waldby - jwpat7 Feb 4 '17 at 6:01
  • 2
    "The library I used for DHT11 sensor is not from Adafruit" - is it also not from Sparkfun? Give us a break and give a link to the library. – Nick Gammon Feb 4 '17 at 6:49
  • @jwpat7 The library is linked here: link – conquistador Feb 4 '17 at 8:54
2

The function println usually appends a carriage-return and linefeed to what it prints. It wouldn't surprise me if those two extra characters are its attempt to "render" that.

Try replacing println with print and see what happens.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.