//this task covers how to use the on-board temperature sensor in the RP2040 chip on the Raspberry pi Pico
//it uses the analogue to digital converter (ADC) in the Pico to read the internal temperature of the RP2040 and
//does the necessary data conversion to output the temperature of the chip
//covers how to perform the required data processing to take the raw ADC output and convert it
//into a voltage and then into temperature
//the temperature sensor might not be calibrated so temperatures might differ in different
//boards due to manufacturing inconsistencies
//as such, if you will be using this in a serious project that requires an accurate temperature value,
//I would recommend using an external sensor.
intmain(){
//Configure ADC
adc_init();
//Task starts here
//Enable temperature sensor
//Select fifth channel of the adc as the input (0 is considered as the first channel)
sleep_ms(1000);// Wait 1 sec (not necessary)
// Initialise the screen (use ST7735_Init() function from the st7735 library)
//Infinite loop to update temperature display every second
while(1){
//store the raw output value from the adc
constfloatconversion=3.3f/(1<<12);//Use this conversion to go from raw value to voltage
//convert raw value to voltage (multiply conversion with the raw value)
//convert voltage to temperature value (temp = 27 - (voltage - 0.706) / 0.001721)
//create char buffer
//store temperature output on char buffer
//use the fillScreen(uint16_t color) to set the screen color
//use the ST7735_WriteString(uint16_t x, uint16_t y, const char* str, FontDef font, uint16_t color, uint16_t bgcolor) function to write the temperature to the screen
//can also use any other function from the library to display the temperature differently