This page provides more information about the 1-Wire API for Java.
Communication with the 1-Wire Network is through an 'adapter'
(com.dalsemi.onewire.adapter.DSPortAdapter class). The static class,
com.dalsemi.onewire.OneWireAccessProvider is used to get an adapter
class instance. All of the adapters can be enumerated or a particular
or the default adapter can be retrieved (enumerateAllAdapters(),
getAdapter(), and getDefaultAdapter()). Each adapter may support
multiple 'ports' so a 1-Wire Network consists of an adapter/port
combination. Here is a brief list of the operations needed to access
and use the 1-Wire network
Note that '1.' and '6.' are performed only once at the beginning and end of the application. '2.' through '5.' comprise the bulk of the 1-Wire operations and are performed multiple times during the execution of an application.
The default 1-Wire Network is specified with two properties:
The values for properties are retrieved in the following search order:
If these properties cannot be found then a platform dependent "Smart default" is used. For Win32 native it is the iButton-TMEX default 1- Wire Net, for TINI it is TINIExternalAdapter/serial1, and for all other platforms it is DS9097U/(first serial communications port).
To allow for multi-thread access to the 1-Wire network, a pair of
methods are provided in the adapter class to give exclusive access.
They are beginExclusive(boolean) and endExclusive(). It is recommended
that this pair wrap any access to the 1-Wire network.
Each 1-Wire device type is identified with a 1 byte 'family code'.
This family code is used to provide the appropriate container and can
also be used to limit the search of the 1-Wire Network to one or more
device types. For example the following code fragment will search for
devices with 0x10 family code. Note that 'adapter' is a working
instance of DSPortAdapter.
// clear any previous search restrictions
adapter.setSearchAllDevices();
adapter.targetAllFamilies();
adapter.setSpeed(adapter.SPEED_REGULAR);
// target 0x10 family devices
adapter.targetFamily(0x10);
// enumerate through all the 1-Wire devices found
for(Enumeration owd_enum = adapter.getAllDeviceContainers();
owd_enum.hasMoreElements(); )
{
OneWireContainer owd =
(OneWireContainer)owd_enum.nextElement();
// do something with the container
}
Note that there are other search methods (findFirstDevice() and
findNextDevice()) that do not automatically create a container and may
be quicker if speed is essential. Also see these other methods for
search options: getAddress(), getDeviceContainer(), excludeFamily(),
setSearchOnlyAlarmDevices(), and setNoResetSearch().
As described in the 'Finding 1-Wire Devices' section, each type of 1-
Wire device has a 'family code' that indicates its functionality. The
adapter uses this family code to provide a 'container' to interface to
it. The container (com.dalsemi.onewire.container.OneWireContainer) is
then used by the application to manipulate the device. Each container
class has the following format OneWireContainerXX where XX is the
'family code'. For example, the DS1920 has a family code of 0x10 so
the container to use it is OneWireContainer10. The adapter will
automatically provide the correct container. If the family code is
unknown then the adapter will provide the super-class generic
container.
Here is a list of the containers provided in this kit.
| Device Name | Family | Description | Interfaces | MemoryBanks |
|
DS1990A DS2401 |
01 | 1-Wire Address only | ||
|
DS1991 DS1425 |
02 | Secure memory device | ||
|
DS1994 DS2404 |
04 | 4K NVRAM memory and clock, timer, alarms | ClockContainer |
MemoryBank PagedMemoryBank |
| DS2405 | 05 | Single addressable switch | ||
| DS1993 | 06 | 4K NVRAM memory |
MemoryBank PagedMemoryBank |
|
| DS1992 | 08 | 1K NVRAM memory |
MemoryBank PagedMemoryBank |
|
|
DS1982 DS2502 |
09 | 1K EPROM memory |
MemoryBank PagedMemoryBank OTPMemoryBank |
|
| DS1995 | 0A | 16K NVRAM memory |
MemoryBank PagedMemoryBank |
|
|
DS1985 DS2505 |
0B | 16K EPROM memory |
MemoryBank PagedMemoryBank OTPMemoryBank |
|
| DS1996 | 0C | 64K NVRAM memory |
MemoryBank PagedMemoryBank |
|
|
DS1986 DS2506 |
0F | 64K EPROM memory |
MemoryBank PagedMemoryBank OTPMemoryBank |
|
|
DS1920 DS1820 DS18S20 |
10 | Temperature and alarm trips | TemperatureContainer | |
|
DS2406 DS2407 |
12 | 1K EPROM memory, dual switch | SwitchContainer |
MemoryBank PagedMemoryBank OTPMemoryBank |
|
DS1983 DS2503 |
13 | 4K EPROM memory |
MemoryBank PagedMemoryBank OTPMemoryBank |
|
| DS1971 | 14 | 265 bit EEPROM memory and OTP register |
MemoryBank PagedMemoryBank OTPMemoryBank |
|
| DS1954 | 16 | Java Powered Cryptographic iButton | ||
| DS1963S | 18 | 4K NVRAM memory and SHA-1 Engine |
MemoryBank PagedMemoryBank |
|
| DS1963L | 1A | 4K NVRAM memory with write cycle counters |
MemoryBank PagedMemoryBank |
|
| DS2423 | 1D | 4K NVRAM memory with external counters |
MemoryBank PagedMemoryBank |
|
| DS2409 | 1F | Dual switch, coupler | SwitchContainer | |
| DS2450 | 20 | Quad A/D | ADContainer |
MemoryBank PagedMemoryBank |
| DS1921 | 21 | Thermocron temperature logger |
TemperatureContainer ClockContainer |
MemoryBank PagedMemoryBank |
| DS1973 | 23 | 4K EEPROM memory |
MemoryBank PagedMemoryBank |
|
| DS2438 | 26 | Temperature, A/D |
ClockContainer ADContainer TemperatureContainer |
|
| DS18B20 | 28 | Adjustable resolution temperature | TemperatureContainer | |
| DS2890 | 2C | Single channel digital potentiometer | PotentiometerContainer | |
| DS2760 | 30 | Temperature, current, A/D |
ADContainer TemperatureContainer |
|
|
DS1961S DS2432 |
33 | 1K EEPROM memory with SHA-1 Engine |
MemoryBank PagedMemoryBank |
The base class of all containers OneWireContainer has a method
called getMemoryBanks() that returns an enumeration of memory
bank instances. A memory bank is a section of memory on a 1-Wire
device that has specific properties. For example the 1-Wire
Network Address of a device is a read-only bank of 8 bytes.
This technique is used to get a handle on the diverse types of
memory that comprise 1-Wire devices. There are three interfaces
that the memory bank may implement. These interfaces are
hierarchical:
See the examples 'OWDump' and 'OWMemUtil' for applications that utilize memory banks.
Any 1-Wire devices that contain memory can also use the 1-Wire File system. The following classes in the com.dalsemi.onewire.utils package can be used just like the Java equivalient:
java.io.File
java.io.FileInputStream
java.io.FileInputStream
java.io.FileDescriptor
The specification for the 1-Wire file system can be found in Application Note 114: http://www.dalsemi.com/datasheets/pdfs/app114.pdf
A 1-Wire Sensor is a device that can make a reading or change
the state of something physical (such as a DS2406 switch).
Typically the operations of 1-Wire Sensors is memory mapped so
writing to a particular location causes the state to change. To
accommodate this type of architecture and reduce the number of 1-
Wire operations that need to take place, a 'read-modify-write'
technique is used. Each Sensor interface is derived from a
super-interface (com.dalsemi.onewire.container.OneWireSensor)
that contain just two methods: readDevice(), writeDevice(). The
read returns a byte array and the write takes a byte array. The
byte array is the state of the device. The interfaces that
extend this interface have 'get' and 'set' methods that
manipulate the byte array. So a OneWireSensor operation is:
The following is a list of the interfaces and a brief description. Note that the container list above indicates the interfaces used.
The most celebrated 'other' device Dallas Semiconductor has is the Java Powered Cryptographic iButton. This is a microprocessor in an iButton package that has a Java Virtual Machine that can run Java applets. These applets typically perform highly secure cryptographic operations. See this web page for more information: http://www.ibutton.com/ibuttons/java.html
![]()
iButton Homepage: http://www.ibutton.com/
![]()