Class OneWireContainer10

  • All Implemented Interfaces:
    OneWireSensor, TemperatureContainer

    public class OneWireContainer10
    extends OneWireContainer
    implements TemperatureContainer

    1-Wire container for temperature iButton which measures temperatures from -55@htmlonly °C @endhtmlonly to +100@htmlonly °C @endhtmlonly, DS1920 or DS18S20. This container encapsulates the functionality of the iButton family type 10 (hex)

    Features

    • Measures temperatures from -55@htmlonly °C @endhtmlonly to +100@htmlonly °C @endhtmlonly in typically 0.2 seconds
    • Zero standby power
    • 0.5@htmlonly °C @endhtmlonly resolution, digital temperature reading in two's complement
    • Increased resolution through interpolation in internal counters
    • 8-bit device-generated CRC for data integrity
    • Special command set allows user to skip ROM section and do temperature measurements simultaneously for all devices on the bus
    • 2 bytes of EEPROM to be used either as alarm triggers or user memory
    • Alarm search directly indicates which device senses alarming temperatures

    Usage

    See the usage example in TemperatureContainer for temperature specific operations.

    DataSheet

    http://pdfserv.maxim-ic.com/arpdf/DS1920.pdf
    http://pdfserv.maxim-ic.com/arpdf/DS18S20.pdf
    See Also:
    TemperatureContainer
    • Field Detail

      • RESOLUTION_NORMAL

        public static final double RESOLUTION_NORMAL
        default temperature resolution for this OneWireContainer10 device.
        See Also:
        Constant Field Values
      • RESOLUTION_MAXIMUM

        public static final double RESOLUTION_MAXIMUM
        maximum temperature resolution for this OneWireContainer10 device. Use RESOLUTION_MAXIMUM in setResolution() if higher resolution is desired.
        See Also:
        Constant Field Values
    • Method Detail

      • getName

        public java.lang.String getName()
        Retrieves the Maxim Integrated Products part number of this OneWireContainer10 as a String. For example 'DS1920'.
        Overrides:
        getName in class OneWireContainer
        Returns:
        this OneWireContainer10 name
      • getAlternateNames

        public java.lang.String 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 class OneWireContainer
        Returns:
        this OneWireContainer10 alternate names
      • getDescription

        public java.lang.String getDescription()
        Retrieves a short description of the function of this OneWireContainer10 type.
        Overrides:
        getDescription in class OneWireContainer
        Returns:
        OneWireContainer10 functional description
      • 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 OneWireContainer10. 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 OneWireContainer10
        Returns:
        temperature in Celsius from the last doTemperatureConvert()
        Throws:
        OneWireIOException - on a 1-Wire communication error such as reading an incorrect CRC from this OneWireContainer10. 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 OneWireContainer10
        See Also:
        hasTemperatureAlarms(), setTemperatureAlarm(int, double, byte[])
      • setTemperatureAlarm

        public void setTemperatureAlarm​(int alarmType,
                                        double alarmValue,
                                        byte[] state)
        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[])
      • readDevice

        public byte[] readDevice()
                          throws OneWireIOException,
                                 OneWireException
        Retrieves this OneWireContainer10 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:
        OneWireContainer10 state information. Device state looks like this:
           0 : temperature LSB
           1 : temperature MSB
           2 : trip high
           3 : trip low
           4 : reserved (put the resolution here, 0 for normal, 1 for max)
           5 : reserved
           6 : count remain
           7 : count per degree Celsius
           8 : an 8 bit CRC over the previous 8 bytes of data
                 
        Throws:
        OneWireIOException - on a 1-Wire communication error such as reading an incorrect CRC from this OneWireContainer10. 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 OneWireContainer10 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 OneWireContainer10. 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()
      • convertToFahrenheit

        public static double convertToFahrenheit​(double celsiusTemperature)
        Deprecated.
        Replace with call to com.dalsemi.onewire.utils.Convert.toFahrenheit()
        Converts a temperature reading from Celsius to Fahrenheit.
        Parameters:
        celsiusTemperature - temperature value in Celsius
        Returns:
        the Fahrenheit conversion of the supplied temperature
        See Also:
        Convert.toFahrenheit(double)
      • convertToCelsius

        public static double convertToCelsius​(double fahrenheitTemperature)
        Deprecated.
        Replace with call to com.dalsemi.onewire.utils.Convert.toCelsius()
        Converts a temperature reading from Fahrenheit to Celsius.
        Parameters:
        fahrenheitTemperature - temperature value in Fahrenheit
        Returns:
        the Celsius conversion of the supplied temperature
        See Also:
        Convert.toCelsius(double)