UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

Temperature Class

Module: temperature

Basic UPM module for analog temperature sensors. These sensors use a NTC thermistor to measure ambient temperature. This driver was developed using the Grove Temperature Sensor. The conversion formula has been updated to work with versions 1.1 and 1.2 of the sensor. For the older v1.0 sensor you will have to specify R0 and B values when initializing the device. The range of this sensor is -40 to 125 C and accuracy is +/- 1.5 C.
temp.jpg

Item Index

Methods

Temperature

(
  • pin
  • scale
  • r0
  • b
)
Number

Analog temperature sensor constructor

Parameters:

  • pin Number

    Analog pin to use

  • scale Number

    Scaling factor for raw analog value from the ADC, useful for mixed 3.3V/5V boards, default 1.0

  • r0 Number

    zero power resistance, this is 100K (default) for v1.1-v1.2 and 10K for v1.0 of the sensor

  • b Number

    thermistor nominal B constant, this is 4275 (default) for v1.1-v1.2 and 3975 for v1.0 of the sensor

Returns:

Number:

raw_value

() Number

Gets the raw value from the AIO pin

Returns:

Number:

Raw value from the ADC

name

() String

Provided for compatibility with old grove base class

Returns:

String:

Sensor name

value

() Number

Gets the temperature in Celsius from the sensor

Returns:

Number:

Normalized temperature in Celsius