arduino_lib_dp1wds18xxxtermo
Table of Contents
Documentation Arduino base program code
Dp1WDS18xxxTermo library
Description
Dp1WDS18xxxTermo Arduino library provide function for gething temperature data form 1-Wire Maxim IC DS18x20 and DS1822 sensors.
No parasit power units on bus are supported!!! .
Some parts of code are used from http://milesburton.com/Dallas_Temperature_Control_Library
Source code is provided as is, without any warranty.
Distributetd under CC BY v 3.0
Functions
// Model IDs
// #define DS1820MODEL 0x10 –55°C to +125°C in 0.5°C increments
#define DS18S20MODEL 0x10 // -55°C to +125°C ±0.5°C Accuracy from -10°C to +85°C 9-Bit Resolution
#define DS18B20MODEL 0x28 // -55°C to +125°C ±0.5°C Accuracy from -10°C to +85°C, resolution is User Selectable from 9 to 12 Bits
#define DS1822MODEL 0x22 // -55°C to +125°C ±2.0°C accuracy from -10°C to +85°C, resolution is user-selectable from 9 to 12 bits
// Device resolution
#define TEMP_9_BIT 0x1F // 9 bit
#define TEMP_10_BIT 0x3F // 10 bit
#define TEMP_11_BIT 0x5F // 11 bit
#define TEMP_12_BIT 0x7F // 12 bit
// type deffinition to accomaodate 1-Wire address
typedef byte DeviceAddress[8];
// type deffinition to accomodate data from one 1-Wire termo sensor
typedef struct {
// device address
DeviceAddress dAddr;
// actual temperature in C
float dTemperature;
// minimal/low alarm temperature
float dMinAlarm;
// maximal/high alarm temperature
float dMaxAlarm;
// sensor resolution - raw byte
byte dTempReso;
} SensorInfo;
// initiate class of termo sensors
// _oneWire pointer to Dp1WBasic class
Dp1WDS18xxxTermo(Dp1WBasic*);
// read data from all temperature sensors on 1-Wire bus and return
// number of found sensors
// seIn - array with data
// maxNo - maximal number of sensors in seIn
// serachType - NORMAL_SEARCH | ALARM_SEARCH
// NORMAL_SEARCH (default) - read all sensors
// ALARM_SEARCH - read only sensor with alarm
byte readTemperature(SensorInfo seIn[], byte maxNo, byte searchType = NORMAL_SEARCH);
// set 1-Wire termosensor data, and returns true if device was founded or false
// in other case
// deviceAddres - address of 1-Wire termo sensor
// loTemp - minimal/low alarm temperature (default 70 C) in C
// hiTemp - maximal/high alarm temperature (default 75 C) in C
// resTemp - TEMP_9_BIT (0.5 C)
// TEMP_10_BIT (0.25 C)
// TEMP_11_BIT (0.125 C)
// TEMP_12_BIT (0.0625 C) default
boolean setSensorData(DeviceAddress deviceAddress, int loTemp = 70, int hiTemp = 75, byte resTemp = TEMP_12_BIT);
// returns true if address is valid or false in other case
// deviceAddress - address of 1-Wire termo sensor
boolean validAddress(uint8_t* deviceAddress);
Contact
Author: Dubravko Penezic
Email: dpenezic@gmail.com
Version
Actual
History
V 1.0.0 , 10.02.2012
arduino_lib_dp1wds18xxxtermo.txt · Last modified: by 127.0.0.1
