#include <Arduino.h>
#include <TM1637Display.h>
#include <DHT.h>


#define CLK 2
#define DIO 3
#define DHTPIN 4

#define DHTTYPE DHT22//11

DHT dht(DHTPIN, DHTTYPE);
TM1637Display display(CLK, DIO);

#define o SEG_A | SEG_B | SEG_F | SEG_G
#define LIT_C SEG_A | SEG_F | SEG_E | SEG_D
#define q SEG_A | SEG_B | SEG_C | SEG_F | SEG_G
#define b SEG_G | SEG_C | SEG_D | SEG_E | SEG_F

const uint8_t failed[] = {SEG_G | SEG_G | SEG_G | SEG_G};
const uint8_t percent[] = {q, b};
const uint8_t celsium[] = {o, LIT_C};

void setup() {
//dht sensor starts running
  dht.begin();
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(2000);
  display.setBrightness(3);
  float t = dht.readTemperature();

  if(!isnan(t))
    {
      display.showNumberDec(round(t), false, 2, 0);
      display.setSegments(celsium, 2, 2);
    }
  else
    //вывод "----"
    display.setSegments(failed);
  
  delay(2000);
  float h= dht.readHumidity();
  if(!isnan(h))
    {
      //int k = round(t);
      display.showNumberDec(round(h), false, 2, 0);
      display.setSegments(percent, 2, 2);
    }
  else
    //вывод "----"
    display.setSegments(failed);

}
4-Digit Display