- KEYWORDS: One Wire,1-Wire,Built-In
OneWire Class in the Reference.
Espruino's 1-Wire API is designed to be similar to Arduino's OneWire library. Simply instantiate it with the pin to use, search for devices, and start communicating:
var ow = new OneWire(pin);
device = ow.search()[0]; // search returns an array of device IDs
if (device===undefined) print("No OneWire devices found");
ow.reset();
ow.select(device);
ow.write(42);
var result = ow.read()
Note: OneWire devices need a 4.7kOhm pullup resistor on the data line in order to work correctly.
For examples of use, look in the source code for libraries that use OneWire...
- APPEND_KEYWORD: OneWire