owiButtonGetID (Function) |
Top Previous Next |
owiButtonGetID returns a string with the unique serial number of a Maxim 1-Wire iButton. The iButton is a unique, factory-lasered and tested 48-bit registration number that assures absolute trace ability because not two parts are alike. It comes in a small metal MicroCan that is very robust even in harsh environments. In order to read the iButton, a special iButton reader must be used. The reader is attached to the 1-Wire bus and connects the iButton to the 1-Wire bus. A small keyring (iButton Fob) adapter is available so that the iButton is easier to carry and place in the reader.
Please consult the Logic IO 1-Wire Basics application note for information on 1-Wire devices.
In order to use the function it is necessary to know the ROM-number of the iButton. The ROM-number can be read on the top of the iButton. Please see the figure below. All twelve digits have to be read.
The serial number from the above figure is "000000FBD8B3". When the ROM-number is known, a string compare can be done to clarify if the iButton has a valid serial number or not.
It cannot be determined when a user places an iButton in the reader, and it is therefore important to call the owiButtonGetID function very often so that the user will not experience a delay before the iButton is read. Make sure not to have any more time consuming tasks in the main program loop than necessary alternatively implement the owiButtonGetID function as a thread (please see the chapter about multithreading for more information).
The iButton reader is supplied with an LED that can easily be used to inform the user whether the iButton placed in the reader is valid or not. Example: fast blinking = access, slow blinking = no access. The LED is controlled with the owiButtonEnableLED and owiButtonSetLed functions.
Please note that it is only possible to have a single iButton connected to the 1-Wire bus at a time.
Input: None.
Returns: STRING A string containing the ID of the iButton if present or an empty string if not.
Declaration: FUNCTION owiButtonGetID : STRING;
Example: INCLUDE rtcu.inc |