/* STM32 Blue Pill project using the STM32 Arduino Core (stm32duino) */
#include "EEPROM.h"
const float BETA = 3950; // should match the Beta Coefficient of the thermistor
uint16_t sayi = 0;
void setup() {
  Serial.begin(115200);
  Serial.println("STM32 analogRead() on BluePill Example");
  uint8_t deger =  EEPROM.read(0);
  Serial.println("Baslangic EEPROM:"); 
  Serial.println(deger);
}

void loop() {
 // Serial.println(analogRead(A0));
  
    int analogValue = analogRead(PB1);
  float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
  Serial.print("Temperature: ");
  Serial.print(celsius);
  Serial.println(" ℃");
  if(celsius>=35)
    digitalWrite(14, HIGH); 
  else
    digitalWrite(14, LOW);
    epromIslem(sayi++);
  delay(100);
}

void epromIslem(uint16_t sayi){
  EEPROM.write(0,sayi);
  uint8_t deger =  EEPROM.read(0);
  Serial.print("EEPROM:"); 
  Serial.println(deger);
}