#include "BluetoothSerial.h"
#include "esp_bt_device.h"
BluetoothSerial SerialBT;
#define THERMISTOR_PIN 34 // ADC pin for MF52 thermistor
// Steinhart–Hart coefficients for MF52 thermistor (example, adjust for your thermistor)
#define SERIES_RESISTOR 10000
#define NOMINAL_RESISTANCE 10000
#define NOMINAL_TEMPERATURE 25
#define B_COEFFICIENT 3950
float readTemperature() {
int adcValue = analogRead(THERMISTOR_PIN);
float resistance = (4095.0 / adcValue - 1.0) * SERIES_RESISTOR;
float steinhart;
steinhart = resistance / NOMINAL_RESISTANCE; // (R/Ro)
steinhart = log(steinhart); // ln(R/Ro)
steinhart /= B_COEFFICIENT; // 1/B * ln(R/Ro)
steinhart += 1.0 / (NOMINAL_TEMPERATURE + 273.15);// + (1/To)
steinhart = 1.0 / steinhart; // Invert
steinhart -= 273.15; // convert to Celsius
return steinhart;
}
void setup() {
Serial.begin(115200);
SerialBT.begin("FootLeft"); // Name of this ESP32
Serial.println("Sender started. Waiting for receiver...");
}
void loop() {
float tempLeft = readTemperature();
Serial.printf("Left foot temp: %.2f °C\n", tempLeft);
// Send temperature to receiver
SerialBT.println(tempLeft);
delay(2000); // send every 2 seconds
}