The implementation should be generic enough that it can be adapted to other microcontrollers.
This implements Maxims One Wire / 1-Wire protocol for AVR microcontrollers from the DS18B20 datasheet and Maxims other application notes. DallasTemperature sensors ( & oneWire ) /* * The setup function. AVR C 1-Wire + DS18B20 temperature sensor.
ONE WIRE LIBRARY DRIVER
the APIs can be found in the (TivaWare Peripheral Driver Library Users. In our case this is the variable oneWireBus. Controller for TMP1826 Single Wire Temperature Sensor provides emulated host. The only parameter for the constructor is the pin of the 1-wire bus. The difference is that were using a function here: the constructor.
ONE WIRE LIBRARY DRIVERS
OneWire enabled devices should have open collector drivers (with single pull-up resistor) on the shared data line. OneWire is a Master/Slave protocol, and all communication cabling required is a single wire.
Include the libraries we need #include #include // Data wire is plugged into port 2 on the Arduino #define ONE_WIRE_BUS 2 // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) OneWire oneWire ( ONE_WIRE_BUS ) // Pass our oneWire reference to Dallas Temperature. The One Wire (1-Wire) protocol is used in the popular DS18B20 temperature sensor and other devices from Maxim (formerly Dallas). 1 OneWire one Wire(oneWireBus) On this line we define the variable oneWire of type OneWire. The OneWire library provides routines for communication via the Dallas OneWire protocol, e.g.