#include <Arduino.h>
#include <TM1637Display.h>
#include <DHT22.h>
// Module connection pins (Digital Pins)
#define CLK 2
#define DIO 3
// The amount of time (in milliseconds) between tests
#define TEST_DELAY 2000
TM1637Display display(CLK, DIO);
DHT22 dht22(4);
const uint8_t SEG_DEG[] = {
SEG_A | SEG_B | SEG_F | SEG_G, // o
SEG_A | SEG_D | SEG_E | SEG_F // C
};
const uint8_t SEG_HUMI[] = {
SEG_C | SEG_E | SEG_F | SEG_G // h
};
void setup()
{
Serial.begin(9600);
display.setBrightness(3); // 0 - 7
}
void loop()
{
int t = round(dht22.getTemperature());
int h = round(dht22.getHumidity());
display.clear();
display.showNumberDec(t, false, 2);
display.setSegments(SEG_DEG, 2, 2);
delay(TEST_DELAY);
display.clear();
display.showNumberDec(h, false, 2);
display.setSegments(SEG_HUMI, 1, 3);
delay(TEST_DELAY);
}