diff -r 52699bca6df9 -r 37788ec8e6d2 src/eric7/MicroPython/Devices/RP2Devices.py --- a/src/eric7/MicroPython/Devices/RP2Devices.py Thu Mar 20 19:31:39 2025 +0100 +++ b/src/eric7/MicroPython/Devices/RP2Devices.py Fri Mar 21 15:15:44 2025 +0100 @@ -417,6 +417,53 @@ """ ################################################################## + ## Method to determine the processor temperatur + ################################################################## + + def getBoardInformation(self): + """ + Public method to get some information data of the connected board. + + This method amends the base class result with the board temperature + determined via the built in temperature sensor of the RPi Pico. + + @return dictionary containing the determined data + @rtype dict + @exception OSError raised to indicate an issue with the device + """ + temp_command = """def get_board_temperature(): + from machine import ADC + + try: + # RP2040, RP2350A: Temp. sensor is connected to ADC channel 4 + # RP2350B: Temp. sensor is connected to ADC channel 8 + temp_sensor = ADC(ADC.CORE_TEMP) + except AttributeError: + # older MPy implementation, use 4 for RP2040 and RP2350A + temp_sensor = ADC(4) + + adc_value = temp_sensor.read_u16() # Read the raw ADC value + + # Convert ADC value to voltage + voltage = adc_value * 3.3 / 65535.0 + + # Temperature calculation based on sensor characteristics + return 27 - (voltage - 0.706) / 0.001721 + +print(get_board_temperature()) +del get_board_temperature +""" + res = super().getBoardInformation() + + # add the RPi Pico board temperature + out, err = self.executeCommands(temp_command, mode=self._submitMode) + if err: + raise OSError(self._shortError(err)) + res["mc_temp_c"] = ast.literal_eval(out.decode("utf-8")) + + return res + + ################################################################## ## Methods below implement WiFi related methods ##################################################################