Temperature Sensor

../../_images/pk_temp.jpg
Temperature Sensor

Description

Can read a raw value of the temperature.

Requires some calibration to provide a specific temperature value in C or F.

Usage

Reads a raw analog temperature. With micro:bit ADC input this would range from 0 to 1023.

Voltage Range

2.7 - 5.5V

Interface Type

Analog Input

Example Usage

from microbit import *

def convert_temp_to_c(raw_temp):
  # ((max mV / 1023) * raw temp - 500 mV) / 10 deg per mV
  return 0.3167 * raw_temp - 50

while True:
  temp_val = pin0.read_analog()

  degrees_c = convert_temp_to_c(temp_val)

  # ...do something with degrees_c