Package com.diozero.devices
Class TMP36
java.lang.Object
com.diozero.api.GpioDevice
com.diozero.api.GpioInputDevice<AnalogInputEvent>
com.diozero.api.AnalogInputDevice
com.diozero.devices.TMP36
- All Implemented Interfaces:
InputEventListener<AnalogInputEvent>
,SensorInterface
,ThermometerInterface
,java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Runnable
public class TMP36 extends AnalogInputDevice implements ThermometerInterface
Support for reading temperature values from a
TMP36 Temperature Sensor by Analog Devices
-
Field Summary
-
Constructor Summary
Constructors Constructor Description TMP36(AnalogInputDeviceFactoryInterface deviceFactory, int gpio, float tempOffset)
-
Method Summary
Modifier and Type Method Description float
getScaledValue()
Get the scaled value in the range 0..range (if unsigned) or -range..range (if signed)float
getTemperature()
Get the current temperature in °C.Methods inherited from class com.diozero.api.AnalogInputDevice
addListener, addListener, close, disableDeviceListener, enableDeviceListener, getRange, getUnscaledValue, run, valueChanged
Methods inherited from class com.diozero.api.GpioInputDevice
addListener, removeAllListeners, removeListener
-
Constructor Details
-
TMP36
public TMP36(AnalogInputDeviceFactoryInterface deviceFactory, int gpio, float tempOffset) throws RuntimeIOException- Parameters:
deviceFactory
- Device factory to use to construct the device.gpio
- GPIO on the ADC device.tempOffset
- Compensate for potential temperature reading variations between different TMP36 devices.- Throws:
RuntimeIOException
- If an I/O error occurred.
-
-
Method Details
-
getScaledValue
Description copied from class:AnalogInputDevice
Get the scaled value in the range 0..range (if unsigned) or -range..range (if signed)- Overrides:
getScaledValue
in classAnalogInputDevice
- Returns:
- the scaled value
- Throws:
RuntimeIOException
- if there was an I/O error
-
getTemperature
Get the current temperature in °C.- Specified by:
getTemperature
in interfaceThermometerInterface
- Returns:
- Temperature in °C.
- Throws:
RuntimeIOException
- If an I/O error occurred.
-