Skip to content

jjsch-dev/esp32-thermistor

Repository files navigation

ESP32 Thermistor Example

This is an example of using the component esp32-thermistor to measure the temperature using a thermistor connected to an ADC channel of ESP32-C3.

alt text

Although the implementation has been demonstrated with the Murata NXRT15WF104FA1B, knowing the beta coefficient published by the manufacturer, any other available on the market can be used, an example could be those that use 3D printers for the bed or the hot-end.

Circuit

The thermistor is part of a resistive divider, where one of its ends is connected to GND and the other to the digital analog channel of ESP32-C3 plus the series resistor whose end is connected to 3.3 V.

alt text

It is important to note that the series resistance has to have a tolerance of 1% or better, and if the footprint allows the dissipated power to be better than an order of magnitude than the maximum current through it, then the stability improves.

Espressif recomend a 0.1uF capacitor to the ADC input to minimize noise.

alt text

Prototype

This component is the thermostat of an IOT project of the ceiling fan, so I started testing it on the next development board.

alt text

Behavior analysis

To evaluate the performance of a thermistor that is connected to an analog digital converter, (in addition to the quality and precision of the same), many things can alter the result, for example, the stability of the power supply, the Ripple of VDD 3.3 V. , the precision of the series resistor, but especially the linearity of the ADC converter that Espressif has implemented in ESP32. I must say that the quality of the ESP32-C3 has surprised me, after using the characterization function of the ADC, the mV measurement is extremely accurate for a processor of this price.

In the following images you can compare the measurement made with the oscilloscope at the analog channel input of the ESP32-C3 and the monitor output where the measured thermistor temperature is logged, as you can see the difference is a few mV.

alt text alt text

AC noise with wifi / bluetooth off is better than 15mV.

alt text

Brief description of the API

To use the component, you need to get the handle of the instance thermistor_handle_t with the function thermistor_init, which takes as parameters the series resistance, the nominal resistance of the thermistor, the adc channel, the voltage of the source and the nominal temperature of thermistor.

To get the temperature in degrees Celsius, you must call the thermistor_get_celsius function that returns a float, and to convert it to Fahrenheit you can use the thermistor_celsius_to_fahrenheit function that also returns a float.

Note: With the sample application, it is possible to configure these parameters with idf.py menuconfig.

Usage Example

    thermistor_handle_t th = {0};
    ESP_ERROR_CHECK(thermistor_init(&th, ADC_CHANNEL_2, 
                                    CONFIG_SERIE_RESISTANCE, 
                                    CONFIG_NOMINAL_RESISTANCE, 
                                    CONFIG_NOMINAL_TEMPERATURE,
                                    CONFIG_BETA_VALUE, 
                                    CONFIG_VOLTAGE_SOURCE));
    while (1) {
        float celsius = thermistor_get_celsius(&th);
        float fahrenheit = thermistor_celsius_to_fahrenheit(celsius);

        ESP_LOGI(TAG,"Voltage: %d mV\tTemperature: %2.1f C / %2.1f F:\tResistance: %.0f ohm", 
                 th.vout, celsius, fahrenheit, th.t_resistance);

        vTaskDelay(200 / portTICK_PERIOD_MS);
    }

Operation video

The following section shows the operation of the App thermistor. The video shows the temperature logged on the monitor in degrees Celsius and Fahrenheith along with the divider voltage and the calculated resistance of the thermistor. It also displays the voltage read on an oscilloscope and tester for comparison.

The video shows the temperature recorded on the monitor in degrees Celsius and Fahrenheith when the thermistor is heated by hand.

About

esp32 thermistor component example

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published