Dtynin
Dtynin
DIIDevHeads IoT Integration Server
Created by Dtynin on 6/27/2024 in #middleware-and-os
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:
void sensor_task(void *pvParameters) {
while (1) {
// Read temperature sensor data using ADC library function
uint16_t raw_adc_data = read_temperature_sensor();

// Convert raw ADC data to temperature value (assuming linear conversion for now)
float temperature = raw_adc_data * 0.1;

// Send the temperature data for processing and transmission
send_temperature_data(temperature);

// Delay task for a specific period
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
void sensor_task(void *pvParameters) {
while (1) {
// Read temperature sensor data using ADC library function
uint16_t raw_adc_data = read_temperature_sensor();

// Convert raw ADC data to temperature value (assuming linear conversion for now)
float temperature = raw_adc_data * 0.1;

// Send the temperature data for processing and transmission
send_temperature_data(temperature);

// Delay task for a specific period
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
@Middleware & OS
12 replies