#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include "DHT.h"
#define DHTPIN 5
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 24
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
unsigned long lastTime = 0;
unsigned long timerDelay = 5000;
int ldr ;
const float Rref = 10000;
const float RL10 = 50;
const float GAMMA = 0.7 ;
float volt ;
float R ;
float lux = 0.0;
float humidity ;
float temperature ;
String data ;
String Lux = "00";
void setup() {
Serial.begin(9600);
myDisplay.begin();
myDisplay.setIntensity(15);
myDisplay.displayClear();
dht.begin();
}
void loop() {
ldr = analogRead(A0);
volt = ldr / 1024. * 5;
R = Rref * (1 / ((5 / volt) - 1));
lux = pow(RL10 * 1e3 * pow(10, GAMMA) / R, (1 / GAMMA));
if (lux < 10) {
lux = 0.0;
}
Lux = String(lux);
humidity = analogRead(A1);
temperature = analogRead(A1);
data = String(humidity) + String(" ") + String(temperature) + String(" ") + String(lux, 0);
myDisplay.setTextAlignment(PA_LEFT);
myDisplay.print(data);
delay(500);
}