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
- Find the part number of the sensor on your board
- Find the code for driving the sensor
- 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
- Find the sensor api reference page
- Find how to include, initialize and configure the sensor
- 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 TerminalThen 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
