Hello,
I need some help, on how to connect a lux sensor to my existing circuit, and have the readings from the sensor be on the lcd screen.
The hardware should be done, but i need help with the coding.
tutorial on the lux sensor: https://create.arduino.cc/projecthub/infoelectorials/project-017-arduino-bh1750-light-sensor-project-640075
My coding right now:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "DHT.h"
#define DHTPIN 5 //digital pin sensor
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
//#define DHTTYPE DHT21
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
DHT dht(DHTPIN, DHTTYPE);
void setup() {
lcd.begin(16, 2);
dht.begin();
}
void loop() {
delay(1000);
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
lcd.print("No connection");
return;
}
lcd.setCursor(0, 0);
lcd.print(h);
lcd.print(" % ");
lcd.print(t);
lcd.print(" C");
Attachment 1: Picture of the whole circiut.
Attachment 2: picture of where i would like the reading of lux to be ( to my best photoshop knowledge)
I hope somebody can help me, my teachers wont because of the covid-19 situation.
Thanks in advance!
Andreas