OneWire Library lets you access 1-wire devices made by Maxim/Dallas, such as temperature sensors
Dependents: OneWireTest mbed_blinky Affich_Lum_Moist Projetv0 ... more
#include "mbed.h" #include "OneWire.h" OneWire owBus(p21); int main() { char _id[16]; DeviceAddresses* devAddresses = owBus.getFoundDevAddresses(); uint8_t foundNum = owBus.getFoundDevNum(); printf("OneWire: found %d devices\r\n", foundNum); while(1) { OneWireDeviceTemperature::startConversationForAll(&owBus, OWTEMP_11_BIT); for (uint8_t i = 0; i < foundNum; i++) { OneWireDevice* owDevice = OneWireDeviceFactory::init(&owBus, (*devAddresses)[i]); if (owDevice->getFamily() != ONEWIRE_DS18B20_FAMILY) // currently only DS18B20 supports continue; owDevice->generateId(_id); printf("OneWire: device #%s = %.4f*C\r\n", _id, (float) owDevice->sendGetCommand(GET_TEMPERATURE)); delete owDevice; } wait(5); } }
History
- moved .h files to '_headers' folders; - added MIT License to all files
2012-12-18, by ivank [Tue, 18 Dec 2012 12:12:21 +0000] rev 3
- moved .h files to '_headers' folders; - added MIT License to all files
- splited library to seprated files; - fixed bug with GET_TEMPERATURE & IRQ(interrupts) under RTOS
2012-12-18, by ivank [Tue, 18 Dec 2012 11:40:28 +0000] rev 2
- splited library to seprated files; - fixed bug with GET_TEMPERATURE & IRQ(interrupts) under RTOS
- fixed bug with 1-Wire (added disablinginterripts)
2012-12-17, by ivank [Mon, 17 Dec 2012 13:34:57 +0000] rev 1
- fixed bug with 1-Wire (added disablinginterripts)
initial release
2012-11-12, by ivank [Mon, 12 Nov 2012 19:44:46 +0000] rev 0
initial release