working on a project that involves monitoring temperature using an LM35 sensor with an STM32F4
Hello everyone,
I'm currently working on a project that involves monitoring temperature using an LM35 sensor with an STM32F4 microcontroller. I'm utilizing FreeRTOS for task scheduling and a CAN bus library for communication. However, I'm encountering issues with inaccurate temperature readings. The readings appear to be significantly different from expected values. Could you please assist me in identifying potential issues in my code and suggest corrections to ensure accurate temperature measurements?
Here's the relevant snippet from my sensor task implementation:
@Middleware & OS
I'm currently working on a project that involves monitoring temperature using an LM35 sensor with an STM32F4 microcontroller. I'm utilizing FreeRTOS for task scheduling and a CAN bus library for communication. However, I'm encountering issues with inaccurate temperature readings. The readings appear to be significantly different from expected values. Could you please assist me in identifying potential issues in my code and suggest corrections to ensure accurate temperature measurements?
Here's the relevant snippet from my sensor task implementation:
@Middleware & OS
Solution
That's right , @Dtynin You need to take into account the reference voltage of your ADC and its resolution. For example, if you are using a 12-bit ADC with a reference voltage of 3.3V, the conversion should look something like this:
This ensures that the raw ADC value is properly converted to the voltage output by the LM35 and then to the corresponding temperature.
This ensures that the raw ADC value is properly converted to the voltage output by the LM35 and then to the corresponding temperature.