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); } }
Changes
Revision | Date | Who | Commit message |
---|---|---|---|
3:7bd102cb73e0 | 2012-12-18 | ivank | - moved .h files to '_headers' folders; - added MIT License to all files |
2:07da4deb7135 | 2012-12-18 | ivank | - splited library to seprated files; - fixed bug with GET_TEMPERATURE & IRQ(interrupts) under RTOS |
1:74dcd0c7d5d4 | 2012-12-17 | ivank | - fixed bug with 1-Wire (added disablinginterripts) |
0:b9cd1d4dcc1f | 2012-11-12 | ivank | initial release |