//
// FILE: dht11_test.ino
// AUTHOR: Rob Tillaart
// PURPOSE: DHT library test sketch for DHT11 && Arduino
// URL: https://github.com/RobTillaart/DHTstable
http://www.arduino.cc/en/Tutorial/LiquidCrystalHelloWorld
*/
// include the library code:
#include <LiquidCrystal.h>
/*
BackLight
Author: Bonezegei (Jofel Batutay)
Date: February 2024
*/
#include <Bonezegei_LCD2004_I2C.h>
#endif Bonezegei_LCD2004_I2C lcd(0x27);
void setup() {
lcd.begin();
lcd.print("BackLight");
}
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
#include "DHTStable.h"
DHTStable DHT;
#define DHT11_PIN 5
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("LIBRARY VERSION: ");
Serial.println(DHTSTABLE_LIB_VERSION);
Serial.println();
Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
}
void loop()
{
// READ DATA
Serial.print("DHT11, \t");
int chk = DHT.read11(DHT11_PIN);
switch (chk)
{
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis() / 1000);
}
lcd.setBacklight(0);
lcd.setPosition(0, 1);
lcd.print("OFF");
delay(1000);
}
case DHTLIB_OK:
Serial.print("OK,\t");
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print("Checksum error,\t");
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print("Time out error,\t");
break;
default:
Serial.print("Unknown error,\t");
break;
}
// DISPLAY DATA
Serial.print(DHT.getHumidity(), 1);
Serial.print(",\t");
Serial.println(DHT.getTemperature(), 1);
delay(2000);
}
// -- END OF FILE --
You have multiple things wrong with “your” code. You have 3 setup functions and your calling loop() within your loop function.
Please look at example sketches and combine where needed.
There should be only one void setup() and one void loop() in your code.
This bit of code should move up before setup.
Also DHT and lcd both use pin 5.
It seems you have smacked together 2 or 3 example codes. Did you test them seperately?
Start from working code. Add new things one by one...
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.