1-WIRE Commands

BEGIN

Starts the 1-Wire Master on the given IO pin. The 1-Wire protocol can be used on any of the IO pins, however it is especially convenient to use it on IO0 and IO2 as the internal pull-up resistor can be used thus eliminating the need for an external pull-up resistor.

Start the 1-WIRE Master: 1WIRE0 BEGIN [pin] [pull]

Parameters:

The pin parameter can be set to any of the IO pins 0, 1, 2, 3, or 4.

The pull parameter can be omitted if not using the internal pull-up resistors or set to PULL to enable the pull-up resistor (available on channels 0 and 2).

Response:

This function returns an ACK Response if the command succeeds in starting the 1-Wire master on the desired IO pin. If the command fails, the function will return a NAK Response.

Example Usage:

1WIRE0 BEGIN 0 PULL
-OK
1WIRE BEGIN 1
-OK

RESET

Resets the 1-Wire devices on the bus and prepares them to receive commands. This is needed before communicating with any device on the bus.

Reset: 1WIRE0 RESET

Parameters:

This command has no parameters.

Response:

This function returns an ACK Response if the device on the 1-Wire bus asserted a presence pulse as a result of the result on the 1-WIRE bus. If the command fails or no device asserts a pulse after the reset, the function will return a NAK Response.

Example Usage:

1WIRE0 RESET
-OK

WRITE

This command writes a byte to the selected 1-WIRE device.

Write byte: 1WIRE0 WRITE [data] [power]

Parameters:

The data parameter is the 8-bit integer (byte) to write on the bus.

The power parameter indicates whether or not to leave the power applied to the device after the write has completed. This parameter is optional and will turn off power by default. To leave power on after the write, set power equal to PWR.

Response:

This function returns an ACK Response if the command succeeds in writing the data. If the command fails, the function will return a NAK Response.

Example Usage:

1WIRE0 WRITE 0xAB
-OK
1WIRE0 WRITE 0xAC PWR
-OK

READ

This command reads a byte from the selected 1-WIRE device.

Read byte: 1WIRE0 READ

Parameters:

This command has no parameters.

Response:

This function returns a Data Response containing the received byte in the format of 1WIRE0 READ [data]

Example Usage:

1WIRE0 READ
-1WIRE0 READ 0xAB

SELECT

This command is used to select the device that was found as a result of the most recent SEARCH command.

Reset: 1WIRE0 SELECT

Parameters:

This command has no parameters.

Response:

This function returns an ACK Response if the command succeeds in sending the SELECT command. If the command fails, the function will return a NAK Response.

Example Usage:

1WIRE0 SELECT
-OK

SKIP

This command is used to skip the device selection process.

Reset: 1WIRE0 SKIP

Parameters:

This command has no parameters.

Response:

This function returns an ACK Response if the command succeeds in sending the SKIP command. If the command fails, the function will return a NAK Response.

Example Usage:

1WIRE0 SKIP
-OK

Searches the 1-WIRE bus for the next device.

Search: 1WIRE0 SEARCH [searchMode]

Parameters:

This command has one parameter, searchmode:

  • Set searchmode to RESET to restart the search from the first device.

  • Set searchmode to COND to begin a conditional search.

  • Set searchmode to the family code of a 1-Wire device to search for devices of the same device family.

Response:

This function returns an ACK Response if the command succeeds in searching for a device on the bus. If the command fails, the function will return a NAK Response.

Example Usage:

1WIRE0 SEARCH
-OK
1WIRE0 SEARCH RESET
-OK
1WIRE0 SEARCH COND
-OK
1WIRE0 SEARCH 0xAA
-OK

DEPOWER

Power down the 1-WIRE bus.

Depower: 1WIRE0 DEPOWER

Parameters:

This command has no parameters.

Response:

This function returns an ACK Response if the command succeeds in depowering the bus. If the command fails, the function will return a NAK Response.

Example Usage:

1WIRE0 DEPOWER
-OK

ADDR

Gets the address of the device found using the SEARCH command.

Get address: 1WIRE0 ADDR ?

Parameters:

This command has no parameters.

Response:

This function returns a Data Response containing the address of the device found using the SEARCH command.

Example Usage:

1WIRE0 ADDR ?
-1WIRE0 ADDR 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00