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:
DeviceInterface
,DeviceEventConsumer<AnalogInputEvent>
,SensorInterface
,ThermometerInterface
,AutoCloseable
,Runnable
,Consumer<AnalogInputEvent>
public class TMP36 extends AnalogInputDevice implements ThermometerInterface
Support for reading temperature values from a TMP36 Temperature Sensor by Analog Devices
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.diozero.api.AnalogInputDevice
AnalogInputDevice.Builder
-
-
Field Summary
-
Fields inherited from class com.diozero.api.GpioDevice
pinInfo
-
-
Constructor Summary
Constructors Constructor Description TMP36(AnalogInputDeviceFactoryInterface deviceFactory, int gpio, float tempOffset)
-
Method Summary
All Methods Instance Methods Concrete Methods 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, hasListeners, 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.api.DeviceInterface
close
-
-
-
-
Constructor Detail
-
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 Detail
-
getScaledValue
public float getScaledValue() throws RuntimeIOException
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
public float getTemperature() throws RuntimeIOException
Get the current temperature in °C.- Specified by:
getTemperature
in interfaceThermometerInterface
- Returns:
- Temperature in °C.
- Throws:
RuntimeIOException
- If an I/O error occurred.
-
-