const int pinLED = 23;
const int pinTEMP = 12;
const float BETA = 3950;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
analogReadResolution(10);
pinMode(pinLED, OUTPUT);
pinMode(pinTEMP, INPUT);
}
void loop() {
int sensor;
sensor = analogRead(pinTEMP);
float celcius = 1 / (log(1/(1023. / sensor - 1)) / BETA + 1.0 / 298.25) - 273.15;
Serial.println(celcius);
analogWrite(pinLED, HIGH);
delay(500);
analogWrite(pinLED, LOW);
delay(500);
}