Now supports DS18B20 and DS18S20 Maxim/Dallas one-wire thermometer devices. Also supports DS18S20 in 9, 10, 11, and 12 bit resolution modes. 'Use Address' mode now checks if the correct device type is present, and informs the user which device to use. Correct temperature conversion times now used in non-parasitic mode. The device should be placed at least 6 inches (15 cm) from the mbed board in order to accurately read ambient temperature.
Fork of OneWireCRC by
Revision 1:ade3fad22621, committed 2015-07-13
- Comitter:
- lagish
- Date:
- Mon Jul 13 17:22:49 2015 +0000
- Parent:
- 0:01a6a40578c9
- Commit message:
- Draft1
Changed in this revision
DS18B20.cpp | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 01a6a40578c9 -r ade3fad22621 DS18B20.cpp --- a/DS18B20.cpp Sun Jan 03 11:57:31 2010 +0000 +++ b/DS18B20.cpp Mon Jul 13 17:22:49 2015 +0000 @@ -95,7 +95,7 @@ pc_ds18B20.traceOut("12 bit resolution ...\r\n"); break; } - float realTemp = (float)read_temp/16 ; + float realTemp = (float)read_temp/16*9/5+32 ; pc_ds18B20.traceOut("TEMP_READ/REAL TEMP: %f \r\n", realTemp);
diff -r 01a6a40578c9 -r ade3fad22621 main.cpp --- a/main.cpp Sun Jan 03 11:57:31 2010 +0000 +++ b/main.cpp Mon Jul 13 17:22:49 2015 +0000 @@ -29,6 +29,8 @@ #include "DS18B20.h" #include "OneWireDefs.h" +DigitalOut myled(LED1); + //#define THERMOMETER DS18S20 #define THERMOMETER DS18B20 @@ -38,21 +40,25 @@ THERMOMETER device(true, true, false, p25); while (!device.initialize()); // keep calling until it works - + while (true) { // changing the resolutions only affects the DS18B20. The DS18S20 is fixed. device.setResolution(nineBit); device.readTemperature(); + myled=1; wait(2); device.setResolution(tenBit); device.readTemperature(); + myled=0; wait(2); device.setResolution(elevenBit); device.readTemperature(); + myled=1; wait(2); device.setResolution(twelveBit); device.readTemperature(); + myled=0; wait(2); }