Skip to main content

ESP-IDF Basics - Assign. 3.2

··2 mins·
Table of Contents
WS00A - This article is part of a series.
Part 10: This Article

In this assignment, you will read the temperature values from the on-board sensor OR the on-chip sensor depending on your board.

On board sensor e.g. Rust board

  1. Find the part number of the sensor on your board
  2. Find the code for driving the sensor
  3. Read temperature from the sensor and output it on the serial port with printf.
It is not asked to develop the driver, focus on the fastest way to solve the problem and what the previous lecture was about.

On chip sensor e.g. DevkitC

  1. Find the sensor api reference page
  2. Find how to include, initialize and configure the sensor
  3. Read temperature from the sensor and output it on the serial port with printf.

Hint
#

Show hint on board sensor
  • The sensor I2C address can be found on the EVK GitHub page.

  • To install a dependency, open an ESP-IDF terminal:

    > ESP-IDF: Open ESP-IDF Terminal
    
  • Then use idf.py:

    idf.py add-dependency "repository_name_in_the_registry"
    
  • Remember to adjust the settings in menuconfig.

Show hint on chip sensor
  • The information can be found in the ESP-IDF Programming guide.

  • Configure the sensor

        temperature_sensor_config_t temp_sensor = {
            .range_min = -10, // Minimum measurable temperature
            .range_max = 80,  // Maximum measurable temperature
            .clk_src = TEMPERATURE_SENSOR_CLK_SRC_DEFAULT
        };
    
  • Install and enable it

      // Install temperature sensor driver
      temperature_sensor_install(&temp_sensor, &temp_handle);
      temperature_sensor_enable(temp_handle);
    
  • Read the temperature

      temperature_sensor_get_celsius(temp_handle, &tsens_out)
    

Conclusion
#

Now that you can read the on board sensor, you’re ready to move to the last assignment of the workshop to put everything together.

Next step
#

Next assignment → Assignment 3.3

Or go back to navigation menu

WS00A - This article is part of a series.
Part 10: This Article

Related

ESP-IDF Basics - Assign. 1.2

··2 mins
Create a new project from the blink example and change the output GPIO pin via menuconfig