Package com.dalsemi.onewire.container
Interface HumidityContainer
- All Superinterfaces:
OneWireSensor
- All Known Implementing Classes:
OneWireContainer26
,OneWireContainer41
1-Wire Humidity interface class for basic Humidity measuring operations. This
class should be implemented for each Humidity type 1-Wire device.
The HumidityContainer methods can be organized into the following categories:
- Information
- Options
- I/O
Usage
Example
Gets humidity reading from a HumidityContainer instance 'hc
':
double lastHumidity;
// get the current resolution and other settings of the device (done only once)
byte[] state = hc.readDevice();
// loop to read the humidity
do
{
// perform a humidity conversion
hc.doHumidityConvert(state);
// read the result of the conversion
state = hc.readDevice();
// extract the result out of state
lastHumidity = hc.getHumidity(state);
...
}
while (!done);
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
high temperature alarmstatic final int
low temperature alarm -
Method Summary
Modifier and TypeMethodDescriptionvoid
doHumidityConvert
(byte[] state) Performs a Humidity conversion.double
getHumidity
(byte[] state) Gets the humidity expressed as a percent value (0.0 to 100.0) of humidity.double
getHumidityAlarm
(int alarmType, byte[] state) Gets the specified Humidity alarm value in percent from thestate
data retrieved from thereadDevice()
method.double
Gets the Humidity alarm resolution in percent.double
getHumidityResolution
(byte[] state) Gets the current Humidity resolution in percent from thestate
data retrieved from thereadDevice()
method.double[]
Get an array of available Humidity resolutions in percent humidity (0 to 100).boolean
Checks to see if this Humidity measuring device has high/low trip alarms.boolean
Checks to see if this device has selectable Humidity resolution.boolean
Checks to see if humidity value given is a 'relative' humidity value.void
setHumidityAlarm
(int alarmType, double alarmValue, byte[] state) Sets the Humidity alarm value in percent in the providedstate
data.void
setHumidityResolution
(double resolution, byte[] state) Sets the current Humidity resolution in percent in the providedstate
data.Methods inherited from interface com.dalsemi.onewire.container.OneWireSensor
readDevice, writeDevice
-
Field Details
-
ALARM_HIGH
static final int ALARM_HIGHhigh temperature alarm- See Also:
-
ALARM_LOW
static final int ALARM_LOWlow temperature alarm- See Also:
-
-
Method Details
-
isRelative
boolean isRelative()Checks to see if humidity value given is a 'relative' humidity value.- Returns:
true
if thisHumidityContainer
provides a relative humidity reading- See Also:
-
hasHumidityAlarms
boolean hasHumidityAlarms()Checks to see if this Humidity measuring device has high/low trip alarms.- Returns:
true
if thisHumidityContainer
has high/low trip alarms- See Also:
-
hasSelectableHumidityResolution
boolean hasSelectableHumidityResolution()Checks to see if this device has selectable Humidity resolution.- Returns:
true
if thisHumidityContainer
has selectable Humidity resolution- See Also:
-
getHumidityResolutions
double[] getHumidityResolutions()Get an array of available Humidity resolutions in percent humidity (0 to 100).- Returns:
- byte array of available Humidity resolutions in percent with minimum resolution as the first element and maximum resolution as the last element.
- See Also:
-
getHumidityAlarmResolution
Gets the Humidity alarm resolution in percent.- Returns:
- Humidity alarm resolution in percent for this 1-wire device
- Throws:
OneWireException
- Device does not support Humidity alarms- See Also:
-
doHumidityConvert
Performs a Humidity conversion.- Parameters:
state
- byte array with device state information- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.OneWireException
- on a communication or setup error with the 1-Wire adapter
-
getHumidity
double getHumidity(byte[] state) Gets the humidity expressed as a percent value (0.0 to 100.0) of humidity.- Parameters:
state
- byte array with device state information- Returns:
- humidity expressed as a percent
- See Also:
-
getHumidityResolution
double getHumidityResolution(byte[] state) Gets the current Humidity resolution in percent from thestate
data retrieved from thereadDevice()
method.- Parameters:
state
- byte array with device state information- Returns:
- Humidity resolution in percent for this 1-wire device
- See Also:
-
getHumidityAlarm
Gets the specified Humidity alarm value in percent from thestate
data retrieved from thereadDevice()
method.- Parameters:
alarmType
- valid value:ALARM_HIGH
orALARM_LOW
state
- byte array with device state information- Returns:
- Humidity alarm trip values in percent for this 1-wire device
- Throws:
OneWireException
- Device does not support Humidity alarms- See Also:
-
setHumidityAlarm
Sets the Humidity alarm value in percent in the providedstate
data. Use the methodwriteDevice()
with this data to finalize the change to the device.- Parameters:
alarmType
- valid value:ALARM_HIGH
orALARM_LOW
alarmValue
- alarm trip value in percentstate
- byte array with device state information- Throws:
OneWireException
- Device does not support Humidity alarms- See Also:
-
setHumidityResolution
Sets the current Humidity resolution in percent in the providedstate
data. Use the methodwriteDevice()
with this data to finalize the change to the device.- Parameters:
resolution
- Humidity resolution in percentstate
- byte array with device state information- Throws:
OneWireException
- Device does not support selectable Humidity resolution- See Also:
-