#include <TM1637Display.h>
#define CLK_PIN 2 // CLK pin of TM1637 display
#define DIO_PIN 3 // DIO pin of TM1637 display
#define THERMISTOR_PIN A0 // Analog pin connected to the NTC thermistor
TM1637Display display(CLK_PIN, DIO_PIN);
const int B = 3975; // Beta value of the thermistor
const uint8_t C[] = {
SEG_B | SEG_A | SEG_F | SEG_G,
SEG_A | SEG_D | SEG_E | SEG_F
};
void setup() {
Serial.begin(9600);
display.setBrightness(7); // Set brightness (0 to 7)
}
void loop() {
int rawValue = analogRead(THERMISTOR_PIN);
// Calculate temperature in Celsius
float resistance = (1023.0 / rawValue) - 1.0;
resistance = 10000.0 / resistance;
float temperatureC = 1.0 / (log(resistance / 10000.0) / B + 1.0 / 298.15) - 273.15;
// Display temperature on TM1637
display.showNumberDec((float)temperatureC, false, 2, 0);
display.setSegments(C,2,2);
delay(1000); // Update every second
}