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:
DeviceEventConsumer<AnalogInputEvent>
,SensorInterface
,ThermometerInterface
,Closeable
,AutoCloseable
,Runnable
,Consumer<AnalogInputEvent>
public class TMP36 extends AnalogInputDevice implements ThermometerInterface
Support for reading temperature values from a
TMP36 Temperature Sensor by Analog Devices
-
Field Summary
Fields inherited from class com.diozero.api.GpioDevice
gpio
-
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
accept, addListener, addListener, close, convertToScaledValue, disableDeviceListener, enableDeviceListener, getRange, getUnscaledValue, run
Methods inherited from class com.diozero.api.GpioInputDevice
addListener, removeAllListeners, removeListener
Methods inherited from class com.diozero.api.GpioDevice
getGpio
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.diozero.devices.SensorInterface
close
-
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 (-range..range)
- 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.
-