Package com.dalsemi.onewire.container
Class OneWireContainer28
java.lang.Object
com.dalsemi.onewire.container.OneWireContainer
com.dalsemi.onewire.container.OneWireContainer28
- All Implemented Interfaces:
OneWireSensor
,TemperatureContainer
- Direct Known Subclasses:
OneWireContainer22
1-Wire container for temperature iButton which measures temperatures from -55@htmlonly °C @endhtmlonly to +125@htmlonly °C @endhtmlonly, DS18B20. This container encapsulates the functionality of the iButton family type 28 (hex)
Features
- Measures temperatures from -55@htmlonly °C @endhtmlonly to +125@htmlonly °C @endhtmlonly. Fahrenheit equivalent is -67@htmlonly °F @endhtmlonly to +257@htmlonly °F @endhtmlonly
- Power supply range is 3.0V to 5.5V
- Zero standby power
- +/- 0.5@htmlonly °C @endhtmlonly accuracy from -10@htmlonly °C @endhtmlonly to +85@htmlonly °C @endhtmlonly
- Thermometer resolution programmable from 9 to 12 bits
- Converts 12-bit temperature to digital word in 750 ms (max.)
- User-definable, nonvolatile temperature alarm settings
- Alarm search command identifies and addresses devices whose temperature is outside of programmed limits (temperature alarm condition)
Usage
- See the usage example in
TemperatureContainer
for temperature specific operations.
DataSheet
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byte
DS18B20 converts temperature commandstatic final byte
DS18B20 copies data from scratchpad to E-squared memory commandstatic final byte
DS18B20 reads power supply command.static final byte
DS18B20 reads data from scratchpad commandstatic final byte
DS18B20 recalls E-squared memory commandstatic final byte
DS18B20 10-bit resolution constant for CONFIG bytestatic final byte
DS18B20 11-bit resolution constant for CONFIG bytestatic final byte
DS18B20 12-bit resolution constant for CONFIG bytestatic final byte
DS18B20 9-bit resolution constant for CONFIG bytestatic final byte
DS18B20 writes data to scratchpad commandFields inherited from class com.dalsemi.onewire.container.OneWireContainer
adapter, address, speed, speedFallBackOK
Fields inherited from interface com.dalsemi.onewire.container.TemperatureContainer
ALARM_HIGH, ALARM_LOW
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an emptyOneWireContainer28
.OneWireContainer28
(DSPortAdapter sourceAdapter, byte[] newAddress) Creates aOneWireContainer28
with the provided adapter object and the address of this One-Wire device.OneWireContainer28
(DSPortAdapter sourceAdapter, long newAddress) Creates aOneWireContainer28
with the provided adapter object and the address of this One-Wire device.OneWireContainer28
(DSPortAdapter sourceAdapter, String newAddress) Creates aOneWireContainer28
with the provided adapter object and the address of this One-Wire device. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Copies the Scratchpad to the E-squared memory of the DS18B20.void
doTemperatureConvert
(byte[] state) Performs a temperature conversion onstate
information.Retrieves the alternate Maxim Integrated Products part numbers or names.Retrieves a short description of the function of thisOneWireContainer28
type.double
Gets the maximum temperature in Celsius.double
Gets the minimum temperature in Celsius.getName()
Retrieves the Maxim Integrated Products part number of thisOneWireContainer28
as aString
.double
getTemperature
(byte[] state) Gets the temperature value in Celsius from thestate
data retrieved from thereadDevice()
method.double
getTemperatureAlarm
(int alarmType, byte[] state) Gets the specified temperature alarm value in Celsius from thestate
data retrieved from thereadDevice()
method.double
Gets the temperature alarm resolution in Celsius.double
getTemperatureResolution
(byte[] state) Gets the current temperature resolution in Celsius from thestate
data retrieved from thereadDevice()
method.double[]
Gets an array of available temperature resolutions in Celsius.boolean
Checks to see if this device has selectable temperature resolution.boolean
Checks to see if this temperature measuring device has high/low trip alarms.boolean
Reads the way power is supplied to the DS18B20.byte[]
Retrieves thisOneWireContainer28
state information.byte[]
Reads the Scratchpad of the DS18B20.byte[]
recallE2()
Recalls the DS18B20 temperature trigger values (ALARM_HIGH
andALARM_LOW
) and the configuration register to the scratchpad and reads the scratchpad.void
setTemperatureAlarm
(int alarmType, double alarmValue, byte[] state) Sets the temperature alarm value in Celsius in the providedstate
data.void
setTemperatureResolution
(double resolution, byte[] state) Sets the current temperature resolution in Celsius in the providedstate
data.void
writeDevice
(byte[] state) Writes to thisOneWireContainer28
state
information that have been changed by 'set
' methods.void
writeScratchpad
(byte[] data) Writes to the Scratchpad of the DS18B20.Methods inherited from class com.dalsemi.onewire.container.OneWireContainer
doSpeed, equals, getAdapter, getAddress, getAddressAsLong, getAddressAsString, getMaxSpeed, getMemoryBanks, hashCode, isAlarming, isPresent, setSpeed, setupContainer, setupContainer, setupContainer, toString
-
Field Details
-
WRITE_SCRATCHPAD_COMMAND
public static final byte WRITE_SCRATCHPAD_COMMANDDS18B20 writes data to scratchpad command- See Also:
-
READ_SCRATCHPAD_COMMAND
public static final byte READ_SCRATCHPAD_COMMANDDS18B20 reads data from scratchpad command- See Also:
-
COPY_SCRATCHPAD_COMMAND
public static final byte COPY_SCRATCHPAD_COMMANDDS18B20 copies data from scratchpad to E-squared memory command- See Also:
-
CONVERT_TEMPERATURE_COMMAND
public static final byte CONVERT_TEMPERATURE_COMMANDDS18B20 converts temperature command- See Also:
-
RECALL_E2MEMORY_COMMAND
public static final byte RECALL_E2MEMORY_COMMANDDS18B20 recalls E-squared memory command- See Also:
-
READ_POWER_SUPPLY_COMMAND
public static final byte READ_POWER_SUPPLY_COMMANDDS18B20 reads power supply command. This command is used to determine if external power is supplied.- See Also:
-
RESOLUTION_12_BIT
public static final byte RESOLUTION_12_BITDS18B20 12-bit resolution constant for CONFIG byte- See Also:
-
RESOLUTION_11_BIT
public static final byte RESOLUTION_11_BITDS18B20 11-bit resolution constant for CONFIG byte- See Also:
-
RESOLUTION_10_BIT
public static final byte RESOLUTION_10_BITDS18B20 10-bit resolution constant for CONFIG byte- See Also:
-
RESOLUTION_9_BIT
public static final byte RESOLUTION_9_BITDS18B20 9-bit resolution constant for CONFIG byte- See Also:
-
-
Constructor Details
-
OneWireContainer28
public OneWireContainer28()Creates an emptyOneWireContainer28
. Must callsetupContainer()
before using this new container.This is one of the methods to construct a
OneWireContainer28
. The others are through creating aOneWireContainer28
with parameters. -
OneWireContainer28
Creates aOneWireContainer28
with the provided adapter object and the address of this One-Wire device. This is one of the methods to construct aOneWireContainer28
. The others are through creating aOneWireContainer28
with different parameters types.- Parameters:
sourceAdapter
- adapter object required to communicate with this One-Wire devicenewAddress
- address of this One-Wire device- See Also:
-
OneWireContainer28
Creates aOneWireContainer28
with the provided adapter object and the address of this One-Wire device. This is one of the methods to construct aOneWireContainer28
. The others are through creating aOneWireContainer28
with different parameters types.- Parameters:
sourceAdapter
- adapter object required to communicate with this One-Wire devicenewAddress
- address of this One-Wire device- See Also:
-
OneWireContainer28
Creates aOneWireContainer28
with the provided adapter object and the address of this One-Wire device. This is one of the methods to construct aOneWireContainer28
. The others are through creating aOneWireContainer28
with different parameters types.- Parameters:
sourceAdapter
- adapter object required to communicate with this One-Wire devicenewAddress
- address of this One-Wire device- See Also:
-
-
Method Details
-
getName
Retrieves the Maxim Integrated Products part number of thisOneWireContainer28
as aString
. For example 'DS18B20'.- Overrides:
getName
in classOneWireContainer
- Returns:
- this
OneWireContainer28
name
-
getAlternateNames
Retrieves the alternate Maxim Integrated Products part numbers or names. A 'family' of 1-Wire Network devices may have more than one part number depending on packaging. There can also be nicknames such as 'Crypto iButton'.- Overrides:
getAlternateNames
in classOneWireContainer
- Returns:
- this
OneWireContainer28
alternate names
-
getDescription
Retrieves a short description of the function of thisOneWireContainer28
type.- Overrides:
getDescription
in classOneWireContainer
- Returns:
OneWireContainer28
functional description
-
hasTemperatureAlarms
public boolean hasTemperatureAlarms()Checks to see if this temperature measuring device has high/low trip alarms.- Specified by:
hasTemperatureAlarms
in interfaceTemperatureContainer
- Returns:
true
if thisOneWireContainer28
has high/low trip alarms- See Also:
-
hasSelectableTemperatureResolution
public boolean hasSelectableTemperatureResolution()Checks to see if this device has selectable temperature resolution.- Specified by:
hasSelectableTemperatureResolution
in interfaceTemperatureContainer
- Returns:
true
if thisOneWireContainer28
has selectable temperature resolution- See Also:
-
getTemperatureResolutions
public double[] getTemperatureResolutions()Gets an array of available temperature resolutions in Celsius.- Specified by:
getTemperatureResolutions
in interfaceTemperatureContainer
- Returns:
- byte array of available temperature resolutions in Celsius for this
OneWireContainer28
. The minimum resolution is returned as the first element and maximum resolution as the last element. - See Also:
-
getTemperatureAlarmResolution
public double getTemperatureAlarmResolution()Gets the temperature alarm resolution in Celsius.- Specified by:
getTemperatureAlarmResolution
in interfaceTemperatureContainer
- Returns:
- temperature alarm resolution in Celsius for this
OneWireContainer28
- See Also:
-
getMaxTemperature
public double getMaxTemperature()Gets the maximum temperature in Celsius.- Specified by:
getMaxTemperature
in interfaceTemperatureContainer
- Returns:
- maximum temperature in Celsius for this
OneWireContainer28
- See Also:
-
getMinTemperature
public double getMinTemperature()Gets the minimum temperature in Celsius.- Specified by:
getMinTemperature
in interfaceTemperatureContainer
- Returns:
- minimum temperature in Celsius for this
OneWireContainer28
- See Also:
-
doTemperatureConvert
Performs a temperature conversion onstate
information.- Specified by:
doTemperatureConvert
in interfaceTemperatureContainer
- Parameters:
state
- byte array with device state information- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from thisOneWireContainer28
. 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- See Also:
-
getTemperature
Gets the temperature value in Celsius from thestate
data retrieved from thereadDevice()
method.- Specified by:
getTemperature
in interfaceTemperatureContainer
- Parameters:
state
- byte array with device state information for thisOneWireContainer28
- Returns:
- temperature in Celsius from the last
doTemperatureConvert()
- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from thisOneWireContainer28
. 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'.- See Also:
-
getTemperatureAlarm
public double getTemperatureAlarm(int alarmType, byte[] state) Gets the specified temperature alarm value in Celsius from thestate
data retrieved from thereadDevice()
method.- Specified by:
getTemperatureAlarm
in interfaceTemperatureContainer
- Parameters:
alarmType
- valid value:ALARM_HIGH
orALARM_LOW
state
- byte array with device state information- Returns:
- temperature alarm trip values in Celsius for this
OneWireContainer28
- See Also:
-
getTemperatureResolution
public double getTemperatureResolution(byte[] state) Gets the current temperature resolution in Celsius from thestate
data retrieved from thereadDevice()
method.- Specified by:
getTemperatureResolution
in interfaceTemperatureContainer
- Parameters:
state
- byte array with device state information- Returns:
- temperature resolution in Celsius for this
OneWireContainer28
- See Also:
-
setTemperatureAlarm
public void setTemperatureAlarm(int alarmType, double alarmValue, byte[] state) throws OneWireException, OneWireIOException Sets the temperature alarm value in Celsius in the providedstate
data. Use the methodwriteDevice()
with this data to finalize the change to the device.- Specified by:
setTemperatureAlarm
in interfaceTemperatureContainer
- Parameters:
alarmType
- valid value:ALARM_HIGH
orALARM_LOW
alarmValue
- alarm trip value in Celsiusstate
- byte array with device state information- Throws:
OneWireException
- Device does not support temperature alarmsOneWireIOException
- See Also:
-
setTemperatureResolution
Sets the current temperature resolution in Celsius in the providedstate
data. Use the methodwriteDevice()
with this data to finalize the change to the device.- Specified by:
setTemperatureResolution
in interfaceTemperatureContainer
- Parameters:
resolution
- temperature resolution in Celsius. Valid values areRESOLUTION_9_BIT
,RESOLUTION_10_BIT
,RESOLUTION_11_BIT
andRESOLUTION_12_BIT
.state
- byte array with device state information- Throws:
OneWireException
- Device does not support selectable temperature resolution- See Also:
-
readDevice
Retrieves thisOneWireContainer28
state information. The state information is returned as a byte array. Pass this byte array to the 'get
' and 'set
' methods. If the device state needs to be changed, then call thewriteDevice()
to finalize the changes.- Specified by:
readDevice
in interfaceOneWireSensor
- Returns:
OneWireContainer28
state information. Device state looks like this:0 : temperature LSB 1 : temperature MSB 2 : trip high 3 : trip low 4 : configuration register (for resolution) 5 : reserved 6 : reserved 7 : reserved 8 : an 8 bit CRC of the previous 8 bytes
- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from thisOneWireContainer28
. 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- See Also:
-
writeDevice
Writes to thisOneWireContainer28
state
information that have been changed by 'set
' methods. Only the state registers that changed are updated. This is done by referencing a field information appended to the state data.- Specified by:
writeDevice
in interfaceOneWireSensor
- Parameters:
state
- byte array with device state information- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from thisOneWireContainer28
. 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- See Also:
-
readScratchpad
Reads the Scratchpad of the DS18B20.- Returns:
- 9-byte buffer representing the scratchpad
- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from thisOneWireContainer28
. 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
-
writeScratchpad
Writes to the Scratchpad of the DS18B20.- Parameters:
data
- data to be written to the scratchpad. First byte of data must be the temperature High Trip Point, the second byte must be the temperature Low Trip Point, and the third must be the Resolution (configuration register).- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from thisOneWireContainer28
. 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 adapterIllegalArgumentException
- when data is of invalid length
-
copyScratchpad
Copies the Scratchpad to the E-squared memory of the DS18B20.- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from thisOneWireContainer28
. 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
-
recallE2
Recalls the DS18B20 temperature trigger values (ALARM_HIGH
andALARM_LOW
) and the configuration register to the scratchpad and reads the scratchpad.- Returns:
- byte array representing data in the device's scratchpad.
- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from thisOneWireContainer28
. 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
-
isExternalPowerSupplied
Reads the way power is supplied to the DS18B20.- Returns:
true
for external power,
false
for parasite power- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from thisOneWireContainer28
. 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
-