#include <TM1637.h>
#include <DHTesp.h>
#define CLK 26
#define DIO 14
#define DHT_PIN 27
TM1637 tm(CLK,DIO);
DHTesp dhtSensor;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
tm.init();
tm.set(BRIGHT_TYPICAL);
dhtSensor.setup(DHT_PIN,DHTesp::DHT22);
}
void loop() {
// put your main code here, to run repeatedly:
TempAndHumidity data = dhtSensor.getTempAndHumidity();
int currentTemp = int(data.temperature);
static int prevTemp = 0;
if (currentTemp > prevTemp) {
tm.display(0, '+'); // Display the "+" sign for increase
} else if (currentTemp < prevTemp) {
tm.display(0, '-'); // Display the "-" sign for decrease
} else {
tm.display(0, ' '); // Display a blank space if no change
}
tm.display(2,((currentTemp/10) % 10));
tm.display(3,(currentTemp % 10));
prevTemp = currentTemp;
delay(10); // this speeds up the simulation
}