examples/mbed_lm35/adc_lm35.cpp
/* This task uses the high level GPIO API (esp_gpio.h) to blink an LED.
 *
 */
This task uses the high level GPIO API (esp_gpio.h) to blink an LED.
This task uses the high level GPIO API ( esp_gpio . h ) to blink an LED .
void ICACHE_FLASH_ATTR
readTask(void *pvParameters)
{
    struct userdata *user = (struct userdata *)pvParameters;
    int a;
    float temperature;
    float R;
    while(1) {
        a = LM35;
        R = (float)(1023-a)*10000/a;       
        temperature = 1 / (log(R/10000)/B+1/298.15) - 273.15;
        temperature = temperature * 100;
        xQueueSendToBack( user->xQueue, (void *) &temperature, portMAX_DELAY );
        if( user->xHandle != NULL ) {
            vTaskResume( user->xHandle );
        }
        wait(0.8);
    }
}
void ICACHE_FLASH_ATTR readTask ( void * pvParameters ) { struct userdata * user = ( struct userdata * ) pvParameters ; int a ; float temperature ; float R ; while ( 1 ) { a = LM35 ; R = ( float ) ( 1023 - a ) * 10000 / a ; temperature = 1 / ( log ( R / 10000 ) / B + 1 / 298.15 ) - 273.15 ; temperature = temperature * 100 ; xQueueSendToBack ( user -> xQueue , ( void * ) & temperature , portMAX_DELAY ) ; if ( user -> xHandle != NULL ) { vTaskResume ( user -> xHandle ) ; } wait ( 0.8 ) ; } }
This task uses the high level GPIO API (esp_gpio.h) to blink an LED.
This task uses the high level GPIO API ( esp_gpio . h ) to blink an LED .
// read from sensor output voltage // convert to Celsius temperature // precision // send to queue // Resume the suspended task ourselves.