Arduino Library – Dallas Temperature Control Library
Installatie van Arduino IDE libraries: Arduino info
This library supports the following devices :
- DS18S20 – Please note there appears to be an issue with this series.
You will need a pull-up resistor of about 5 KOhm between the 1-Wire data line and your 5V power. If you are using the DS18B20, ground pins 1 and 3. The centre pin is the data line ‘1-wire’.
We have included a “REQUIRESNEW” and “REQUIRESALARMS” definition. If you want to slim down the code feel free to use either of these by including
at the top of DallasTemperature.h
[1.0] First version
[1.5.0 Test] Includes negative temperature support
[2.0.0] Updated by Tim Newsome to include support for multiple ICs on the same OneWire
[2.0.1] A slightly leaner version of 2.0.0
[2.5.0] James Whiddon has re-factored the core code to provide accurate timings, increased sensor resolution, detect parasite power (etc).
[3.0.0] Another addition by James Whiddon. He has re-factored much of the original code and included a new example sketch.
[3.0.0b] Includes a fix for the S series of devices by Nic Johns
[3.1.0] Heavily re-factored version of 3.0.0b. Includes 4 new sketches and several additional functions to make sketches simple for new user who 'just want to get going'
[3.2.0] Separated OneWire and DallasTemperature libraries so you only need to install one if you've already got OneWire installed (avoids those annoying conflicts). This includes full support for alarms and a supporting example. We have also included a couple of definitions should you want to remove the alarm functionality to save some memory
bool hasAlarm(void); This allows you to know if ANY device is reporting an alarm without having to scan each device on the bus.
void setAlarmHandler(AlarmHandler *); You can define a function that will be executed when an alarm condition exists on a device. The function takes a device address as an argument. The handler is executed when processAlarms() is called.
void processAlarms(void); Used in loop(). Performs an alarmSearch() and calls the appropriate AlarmHandler for any devices with alarms.
AlarmHandler.pde example included.
private float calculateTemperature(uint8_t*, uint8_t*); This was done so the hasAlarm(uint8_t*) function didn't have to read the scratchpad twice or include duplicate code for measuring the temperature. Change is invisible to the end user.
Fixed incorrect address array sizes in hasAlarm and processAlarms
setResolution now only reads the scratchpad once
setHighAlarmTemp and setLowAlarmTemp now read the scratchpad to ensure the scratchpad contains the data for the device address you're setting
Changed DEVICE_DISCONNECTED value to -127 so it can be passed as a result in functions returning a char value
getLowAlarmTemp and getHighAlarmTemp now return DEVICE_DISCONNECTED if the device is disconnected
Added typedef uint8_t DeviceAddress (hopefully to help prevent mistakes like were in hasAlarm and processAlarms)
Added typedef uint8_t ScratchPad
Updated demo sketches to use DeviceAddress typedef
Guil Barros submitted two additional functions, GetTemperatureByIndex & GetTemperatureByAddress to make life a little easier
Device count is reset when you call the begin() method. This allows you to detect new ICs without resetting your MCU. Many thanks to two contributors for emailing me this fix! Great Work Peter Maag & Paolo Bosetti.
Rob Tillaart was kind enough to introduce a new revision to the library, asynchronous calls. When you request a temperature you can choose to manage the delay in your own code and continue processing other data. This code is still considered beta so if you spot any issues let me know.
[3.7.1] Daniel Seither has cleaned up some of the example files for better legibility, thanks Daniel.
- Merge pull request #35 from milesburton/RobTillaart-master
- Rob tillaart master
- Merge pull request #38 from RobTillaart/master
- example to generate address array from connected devices