Dallas Semiconductor 1-Wire API 1.00 Alpha: Class OneWireContainer22

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.dalsemi.onewire.container
Class OneWireContainer22

    java.lang.Object
      |
      +--com.dalsemi.onewire.container.OneWireContainer
            |
            +--com.dalsemi.onewire.container.OneWireContainer22

All Implemented Interfaces:
  OneWireSensor, TemperatureContainer

public class OneWireContainer22
extends OneWireContainer
implements TemperatureContainer

1-Wire container for temperature iButton which measures temperatures from -55°C to +125°C, DS1822. This container encapsulates the functionality of the iButton family type 22 (hex)

### Features

- Measures temperatures from -55°C to +125°C. Fahrenheit equivalent is -67°F to +257°F
- Power supply range is 3.0V to 5.5V
- Zero standby power
- +/- 2°C accuracy from -10°C to +85°C
- 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

SHUGHES_ERROR
  http://pdfserv.maxim-ic.com/arpdf/DS1822.pdf

Version:
  1.00, 15 September 2000
See Also:
  `TemperatureContainer`

Field Summary
`static byte` | `CONVERT_TEMPERATURE_COMMAND` DS18B20 converts temperature command
`static byte` | `COPY_SCRATCHPAD_COMMAND` DS18B20 copys data from scratchpad to E-squared memory command
`static byte` | `READ_POWER_SUPPLY_COMMAND` DS18B20 reads power supply command.
`static byte` | `READ_SCRATCHPAD_COMMAND` DS18B20 reads data from scratchpad command
`static byte` | `RECALL_E2MEMORY_COMMAND` DS18B20 recalls E-squared memory command
`static byte` | `RESOLUTION_10_BIT` DS18B20 10-bit resolution constant for CONFIG byte
`static byte` | `RESOLUTION_11_BIT` DS18B20 11-bit resolution constant for CONFIG byte
`static byte` | `RESOLUTION_12_BIT` DS18B20 12-bit resolution constant for CONFIG byte
`static byte` | `RESOLUTION_9_BIT` DS18B20 9-bit resolution constant for CONFIG byte
`static byte` | `WRITE_SCRATCHPAD_COMMAND` DS18B20 writes data to scratchpad command

Fields inherited from interface com.dalsemi.onewire.container.TemperatureContainer
`ALARM_HIGH, ALARM_LOW`

Constructor Summary
`OneWireContainer22()` Creates an empty `OneWireContainer22`.
`OneWireContainer22(DSPortAdapter sourceAdapter, byte[] newAddress)` Creates a `OneWireContainer22` with the provided adapter object and the address of this One-Wire device.
`OneWireContainer22(DSPortAdapter sourceAdapter, long newAddress)` Creates a `OneWireContainer22` with the provided adapter object and the address of this One-Wire device.
`OneWireContainer22(DSPortAdapter sourceAdapter, String newAddress)` Creates a `OneWireContainer22` with the provided adapter object and the address of this One-Wire device.

Method Summary
`float` | `convertToFahrenheit(float celsiusTemperature)` Converts a temperature reading from Celsius to Fahrenheit.
`void` | `copyScratchpad()` Copies the Scratchpad to the E-squared memory of the DS1822.
`void` | `doTemperatureConvert(byte[] state)` Performs a temperature conversion on `state` information.
`String` | `getAlternateNames()` Retrieves the alternate Dallas Semiconductor part numbers or names.
`String` | `getDescription()` Retrieves a short description of the function of this `OneWireContainer22` type.
`double` | `getMaxTemperature()` Gets the maximum temperature in Celsius.
`double` | `getMinTemperature()` Gets the minimum temperature in Celsius.
`String` | `getName()` Retrieves the Dallas Semiconductor part number of this `OneWireContainer22` as a `String`.
`double` | `getTemperature(byte[] state)` Gets the temperature value in Celsius from the `state` data retrieved from the `readDevice()` method.
`double` | `getTemperatureAlarm(int alarmType, byte[] state)` Gets the specified temperature alarm value in Celsius from the `state` data retrieved from the `readDevice()` method.
`double` | `getTemperatureAlarmResolution()` Gets the temperature alarm resolution in Celsius.
`double` | `getTemperatureResolution(byte[] state)` Gets the current temperature resolution in Celsius from the `state` data retrieved from the `readDevice()` method.
`double[]` | `getTemperatureResolutions()` Gets an array of available temperature resolutions in Celsius.
`boolean` | `hasSelectableTemperatureResolution()` Checks to see if this device has selectable temperature resolution.
`boolean` | `hasTemperatureAlarms()` Checks to see if this temperature measuring device has high/low trip alarms.
`boolean` | `isExternalPowerSupplied()` Reads the way power is supplied to the DS1822.
`byte[]` | `readDevice()` Retrieves this `OneWireContainer22` state information.
`byte[]` | `readScratchpad()` Reads the Scratchpad of the DS1822.
`byte[]` | `recallE2()` Recalls the DS1822 temperature trigger values (`ALARM_HIGH` and `ALARM_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 provided `state` data.
`void` | `setTemperatureResolution(double resolution, byte[] state)` Sets the current temperature resolution in Celsius in the provided `state` data.
`void` | `writeDevice(byte[] state)` Writes to this `OneWireContainer22` `state` information that have been changed by '`set`' methods.
`void` | `writeScratchpad(byte[] data)` Writes to the Scratchpad of the DS1822.

Methods inherited from class com.dalsemi.onewire.container.OneWireContainer
`doSpeed, getAdapter, getAddress, getAddressAsLong, getAddressAsString, getMaxSpeed, getMemoryBanks, isAlarming, isPresent, setSpeed, setupContainer, setupContainer, setupContainer`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### WRITE_SCRATCHPAD_COMMAND

    public static final byte WRITE_SCRATCHPAD_COMMAND

  DS18B20 writes data to scratchpad command

### READ_SCRATCHPAD_COMMAND

    public static final byte READ_SCRATCHPAD_COMMAND

  DS18B20 reads data from scratchpad command

### COPY_SCRATCHPAD_COMMAND

    public static final byte COPY_SCRATCHPAD_COMMAND

  DS18B20 copys data from scratchpad to E-squared memory command

### CONVERT_TEMPERATURE_COMMAND

    public static final byte CONVERT_TEMPERATURE_COMMAND

  DS18B20 converts temperature command

### RECALL_E2MEMORY_COMMAND

    public static final byte RECALL_E2MEMORY_COMMAND

  DS18B20 recalls E-squared memory command

### READ_POWER_SUPPLY_COMMAND

    public static final byte READ_POWER_SUPPLY_COMMAND

  DS18B20 reads power supply command. This command is used to determine if external power is supplied.

### RESOLUTION_12_BIT

    public static final byte RESOLUTION_12_BIT

  DS18B20 12-bit resolution constant for CONFIG byte

### RESOLUTION_11_BIT

    public static final byte RESOLUTION_11_BIT

  DS18B20 11-bit resolution constant for CONFIG byte

### RESOLUTION_10_BIT

    public static final byte RESOLUTION_10_BIT

  DS18B20 10-bit resolution constant for CONFIG byte

### RESOLUTION_9_BIT

    public static final byte RESOLUTION_9_BIT

  DS18B20 9-bit resolution constant for CONFIG byte

Constructor Detail

### OneWireContainer22

    public OneWireContainer22()

  Creates an empty `OneWireContainer22`. Must call `setupContainer()` before using this new container.

  This is one of the methods to construct a `OneWireContainer22`. The others are through creating a `OneWireContainer22` with parameters.

  See Also:
    `OneWireContainer22(DSPortAdapter,byte[])`, `OneWireContainer22(DSPortAdapter,long)`, `OneWireContainer22(DSPortAdapter,String)`

### OneWireContainer22

    public OneWireContainer22(DSPortAdapter sourceAdapter,
                              byte[] newAddress)

  Creates a `OneWireContainer22` with the provided adapter object and the address of this One-Wire device. This is one of the methods to construct a `OneWireContainer22`. The others are through creating a `OneWireContainer22` with different parameters types.
  Parameters:
    `sourceAdapter` - adapter object required to communicate with this One-Wire device
    `newAddress` - address of this One-Wire device
  See Also:
    `Address`, `OneWireContainer22()`, `OneWireContainer22(DSPortAdapter,long)`, `OneWireContainer22(DSPortAdapter,String)`

### OneWireContainer22

    public OneWireContainer22(DSPortAdapter sourceAdapter,
                              long newAddress)

  Creates a `OneWireContainer22` with the provided adapter object and the address of this One-Wire device. This is one of the methods to construct a `OneWireContainer22`. The others are through creating a `OneWireContainer22` with different parameters types.
  Parameters:
    `sourceAdapter` - adapter object required to communicate with this One-Wire device
    `newAddress` - address of this One-Wire device
  See Also:
    `Address`, `OneWireContainer22()`, `OneWireContainer22(DSPortAdapter,byte[])`, `OneWireContainer22(DSPortAdapter,String)`

### OneWireContainer22

    public OneWireContainer22(DSPortAdapter sourceAdapter,
                              String newAddress)

  Creates a `OneWireContainer22` with the provided adapter object and the address of this One-Wire device. This is one of the methods to construct a `OneWireContainer22`. The others are through creating a `OneWireContainer22` with different parameters types.
  Parameters:
    `sourceAdapter` - adapter object required to communicate with this One-Wire device
    `newAddress` - address of this One-Wire device
  See Also:
    `Address`, `OneWireContainer22()`, `OneWireContainer22(DSPortAdapter,byte[])`, `OneWireContainer22(DSPortAdapter,long)`

Method Detail

### getName

    public String getName()

  Retrieves the Dallas Semiconductor part number of this `OneWireContainer22` as a `String`. For example 'DS1822'.
  Overrides:
    `getName` in class `OneWireContainer`
  Returns:
    this `OneWireContainer22` name

### getAlternateNames

    public String getAlternateNames()

  Retrieves the alternate Dallas Semiconductor 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 class `OneWireContainer`
  Returns:
    this `OneWireContainer22` alternate names

### getDescription

    public String getDescription()

  Retrieves a short description of the function of this `OneWireContainer22` type.
  Overrides:
    `getDescription` in class `OneWireContainer`
  Returns:
    `OneWireContainer22` functional description

### hasTemperatureAlarms

    public boolean hasTemperatureAlarms()

  Checks to see if this temperature measuring device has high/low trip alarms.
  Specified by:
    `hasTemperatureAlarms` in interface `TemperatureContainer`
  Returns:
    `true` if this `OneWireContainer22` has high/low trip alarms
  See Also:
    `getTemperatureAlarm(int, byte[])`, `setTemperatureAlarm(int, double, byte[])`

### hasSelectableTemperatureResolution

    public boolean hasSelectableTemperatureResolution()

  Checks to see if this device has selectable temperature resolution.
  Specified by:
    `hasSelectableTemperatureResolution` in interface `TemperatureContainer`
  Returns:
    `true` if this `OneWireContainer22` has selectable temperature resolution
  See Also:
    `getTemperatureResolution(byte[])`, `getTemperatureResolutions()`, `setTemperatureResolution(double, byte[])`

### getTemperatureResolutions

    public double[] getTemperatureResolutions()

  Gets an array of available temperature resolutions in Celsius.
  Specified by:
    `getTemperatureResolutions` in interface `TemperatureContainer`
  Returns:
    byte array of available temperature resolutions in Celsius for this `OneWireContainer22`. The minimum resolution is returned as the first element and maximum resolution as the last element.
  See Also:
    `hasSelectableTemperatureResolution()`, `getTemperatureResolution(byte[])`, `setTemperatureResolution(double, byte[])`

### getTemperatureAlarmResolution

    public double getTemperatureAlarmResolution()

  Gets the temperature alarm resolution in Celsius.
  Specified by:
    `getTemperatureAlarmResolution` in interface `TemperatureContainer`
  Returns:
    temperature alarm resolution in Celsius for this `OneWireContainer22`
  See Also:
    `hasTemperatureAlarms()`, `getTemperatureAlarm(int, byte[])`, `setTemperatureAlarm(int, double, byte[])`

### getMaxTemperature

    public double getMaxTemperature()

  Gets the maximum temperature in Celsius.
  Specified by:
    `getMaxTemperature` in interface `TemperatureContainer`
  Returns:
    maximum temperature in Celsius for this `OneWireContainer22`
  See Also:
    `getMinTemperature()`

### getMinTemperature

    public double getMinTemperature()

  Gets the minimum temperature in Celsius.
  Specified by:
    `getMinTemperature` in interface `TemperatureContainer`
  Returns:
    minimum temperature in Celsius for this `OneWireContainer22`
  See Also:
    `getMaxTemperature()`

### doTemperatureConvert

    public void doTemperatureConvert(byte[] state)
                              throws OneWireIOException,
                                     OneWireException

  Performs a temperature conversion on `state` information.
  Specified by:
    `doTemperatureConvert` in interface `TemperatureContainer`
  Parameters:
    `state` - byte array with device state information
  Throws:
    `OneWireIOException` - on a 1-Wire communication error such as reading an incorrect CRC from this `OneWireContainer22`. 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(byte[])`

### getTemperature

    public double getTemperature(byte[] state)
                          throws OneWireIOException

  Gets the temperature value in Celsius from the `state` data retrieved from the `readDevice()` method.
  Specified by:
    `getTemperature` in interface `TemperatureContainer`
  Parameters:
    `state` - byte array with device state information for this `OneWireContainer22`
  Returns:
    temperature in Celsius from the last `doTemperatureConvert()`
  Throws:
    `OneWireIOException` - on a 1-Wire communication error such as reading an incorrect CRC from this `OneWireContainer22`. 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:
    `doTemperatureConvert(byte[])`

### getTemperatureAlarm

    public double getTemperatureAlarm(int alarmType,
                                      byte[] state)

  Gets the specified temperature alarm value in Celsius from the `state` data retrieved from the `readDevice()` method.
  Specified by:
    `getTemperatureAlarm` in interface `TemperatureContainer`
  Parameters:
    `alarmType` - valid value: `ALARM_HIGH` or `ALARM_LOW`
    `state` - byte array with device state information
  Returns:
    temperature alarm trip values in Celsius for this `OneWireContainer22`
  See Also:
    `hasTemperatureAlarms()`, `setTemperatureAlarm(int, double, byte[])`

### getTemperatureResolution

    public double getTemperatureResolution(byte[] state)

  Gets the current temperature resolution in Celsius from the `state` data retrieved from the `readDevice()` method.
  Specified by:
    `getTemperatureResolution` in interface `TemperatureContainer`
  Parameters:
    `state` - byte array with device state information
  Returns:
    temperature resolution in Celsius for this `OneWireContainer22`
  See Also:
    `RESOLUTION_9_BIT`, `RESOLUTION_10_BIT`, `RESOLUTION_11_BIT`, `RESOLUTION_12_BIT`, `hasSelectableTemperatureResolution()`, `getTemperatureResolutions()`, `setTemperatureResolution(double, byte[])`

### setTemperatureAlarm

    public void setTemperatureAlarm(int alarmType,
                                    double alarmValue,
                                    byte[] state)
                             throws OneWireException,
                                    OneWireIOException

  Sets the temperature alarm value in Celsius in the provided `state` data. Use the method `writeDevice()` with this data to finalize the change to the device.
  Specified by:
    `setTemperatureAlarm` in interface `TemperatureContainer`
  Parameters:
    `alarmType` - valid value: `ALARM_HIGH` or `ALARM_LOW`
    `alarmValue` - alarm trip value in Celsius
    `state` - byte array with device state information
  See Also:
    `hasTemperatureAlarms()`, `getTemperatureAlarm(int, byte[])`

### setTemperatureResolution

    public void setTemperatureResolution(double resolution,
                                         byte[] state)
                                  throws OneWireException

  Sets the current temperature resolution in Celsius in the provided `state` data. Use the method `writeDevice()` with this data to finalize the change to the device.
  Specified by:
    `setTemperatureResolution` in interface `TemperatureContainer`
  Parameters:
    `resolution` - temperature resolution in Celsius. Valid values are `RESOLUTION_9_BIT`, `RESOLUTION_10_BIT`, `RESOLUTION_11_BIT` and `RESOLUTION_12_BIT`.
    `state` - byte array with device state information
  See Also:
    `RESOLUTION_9_BIT`, `RESOLUTION_10_BIT`, `RESOLUTION_11_BIT`, `RESOLUTION_12_BIT`, `hasSelectableTemperatureResolution()`, `getTemperatureResolution(byte[])`, `getTemperatureResolutions()`

### readDevice

    public byte[] readDevice()
                      throws OneWireIOException,
                             OneWireException

  Retrieves this `OneWireContainer22` 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 the `writeDevice()` to finalize the changes.
  Specified by:
    `readDevice` in interface `OneWireSensor`
  Returns:
    `OneWireContainer22` 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 this `OneWireContainer22`. 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(byte[])`

### writeDevice

    public void writeDevice(byte[] state)
                     throws OneWireIOException,
                            OneWireException

  Writes to this `OneWireContainer22` `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 interface `OneWireSensor`
  Parameters:
    `state` - byte array with device state information
  Throws:
    `OneWireIOException` - on a 1-Wire communication error such as reading an incorrect CRC from this `OneWireContainer22`. 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:
    `readDevice()`

### readScratchpad

    public byte[] readScratchpad()
                          throws OneWireIOException,
                                 OneWireException

  Reads the Scratchpad of the DS1822.
  Returns:
    9-byte buffer representing the scratchpad
  Throws:
    `OneWireIOException` - on a 1-Wire communication error such as reading an incorrect CRC from this `OneWireContainer22`. 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

    public void writeScratchpad(byte[] data)
                         throws OneWireIOException,
                                OneWireException

  Writes to the Scratchpad of the DS1822.
  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 this `OneWireContainer22`. 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
    `IllegalArgumentException` - when data is of invalid length

### copyScratchpad

    public void copyScratchpad()
                        throws OneWireIOException,
                               OneWireException

  Copies the Scratchpad to the E-squared memory of the DS1822.
  Throws:
    `OneWireIOException` - on a 1-Wire communication error such as reading an incorrect CRC from this `OneWireContainer22`. 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

    public byte[] recallE2()
                    throws OneWireIOException,
                           OneWireException

  Recalls the DS1822 temperature trigger values (`ALARM_HIGH` and `ALARM_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 this `OneWireContainer22`. 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

    public boolean isExternalPowerSupplied()
                                    throws OneWireIOException,
                                           OneWireException

  Reads the way power is supplied to the DS1822.
  Returns:
    `true` for external power,
    `false` for parasite power
  Throws:
    `OneWireIOException` - on a 1-Wire communication error such as reading an incorrect CRC from this `OneWireContainer22`. 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

### convertToFahrenheit

    public float convertToFahrenheit(float celsiusTemperature)

  Converts a temperature reading from Celsius to Fahrenheit.
  Parameters:
    `celsiusTemperature` - temperature value in Celsius
  Returns:
    the Fahrenheit conversion of the supplied temperature

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD