Measuring Temperature Using the Onboard Sensor
Scamp1 (Rev C) and Scamp2 computers have an onboard PCT2075 temperature sensor, at I2C address $36. The datasheet for this sensor can be found here: https://www.nxp.com/docs/en/data-sheet/PCT2075.pdf. The sensor is compatible with the common LM75 temperature sensors, but with increased accuracy. Note that the sensor measures the temperature of the PCB to which it is attached, which may not be exactly the same as local ambient weather conditions.
The word:
The word:
temp
reads the sensor over the I2C bus and returns two values to the stack. The values are the (integer) temperature in degrees Celsius, and the fractional temperature in milli degrees Celsius.
For example, if temp returned 25 750, then the temperature reading is 25.750°C.
For example, if temp returned 25 750, then the temperature reading is 25.750°C.
The absolute accuracy of the sensor is ±1°C over -25°C to +100°C range, so for most applications it makes sense to just drop the fractional component. To read the absolute temperature:
temp drop
The fractional part of the temperature reading is useful if you're interested in small differential changes over a short time, rather than an absolute reading.