from machine import ADC

# Internal temperature sensor is connected to ADC channel 4
temp_sensor = ADC(4)

def read_internal_temperature():
    # Read the raw ADC value
    adc_value = temp_sensor.read_u16()

    # Convert ADC value to voltage
    voltage = adc_value * (3.3 / 65535.0)

    # Temperature calculation based on sensor characteristics
    temperature_celsius = 27 - (voltage - 0.706) / 0.001721

    return temperature_celsius

def celsius_to_fahrenheit(temp_celsius):
    temp_fahrenheit = temp_celsius * (9/5) + 32
    return temp_fahrenheit

# Reading and printing the internal temperature
temperature_c = read_internal_temperature()
temperature_f = celsius_to_fahrenheit(temperature_c)
print("Internal Temperature:", temperature_c, "°C")
print("Internal Temperature:", temperature_f, "°F")
PWM brightness not simulated...