Code
In this project code, the ADC value is still needed to be read, and the difference is that a specific formula is
used to calculate the temperature value.
C Code 11.1.1 Thermometer
First observe the project result, and then analyze the code.
Use cd command to enter 11.1.1_Thermometer directory of C code.
cd ~/Freenove_Ultimate_Starter_Kit_for_Raspberry_Pi/Code/C_Code/11.1.1_Thermometer
1. Use following command to compile “Thermometer.c” and generate executable file “Thermometer”. “-lm”
option is needed.
gcc Thermometer.c -o Thermometer -lwiringPi -lm
2. Then run the generated file “Thermometer”.
sudo ./Thermometer
After the program is executed, the terminal window will print out the current ADC value, voltage value and
temperature value. Try to pinch the thermistor (do not touch pin) with hand lasting for a while, then the
temperature value will be increased.
The following is the code: