Maxim DS18 topic
- Introduction
- Sensor Datasheet
- Sensor Constructor
- Example Code
- Reference
- Detailed Descriptions
Classes for the Maxim DS18 one-wire temperature sensors.
Introduction
The Maxim temperature probes communicate using the OneWire library, which can be used on any digital pin on any of the supported boards. The same module should work with a DS18B20, DS18S20, DS1822, MAX31820, and the no-longer-sold DS1820 sensor. These sensors can be attached to a 3.0-5.5V power source or they can take "parasitic power" from the data line. When using the more typical setup with power, ground, and data lines, a 4.7k resistor must be attached as a pull-up between the data and power lines. The one-wire communication protocol is slow and interrupts are turned off during communication. Keep this in mind if using this sensor in combination with a rain gauge or other interrupt-driven sensor.
The resolution of the DS18B20, DS1822, and MAX31820 temperature sensors are user-configurable to 9, 10, 11, or 12 bits, corresponding to increments of 0.5°C, 0.25°C, 0.125°C, and 0.0625°C, respectively. The default resolution at power-up is 12-bit, unless it has previously been set to something else. The resolution of the DS18S20 is set at 9-bit
The OneWire hex address of the sensor, the Arduino pin controlling power on/off, and the Arduino pin sending and receiving data are required for the sensor constructor. The OneWire address is an array of 8 hex values, for example: {0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0}. To get the address of your sensor, plug a single sensor into your device and run the oneWireSearch example or the Single example provided within the Dallas Temperature library. The sensor address is programmed at the factory and cannot be changed.
Sensor Datasheet
Sensor Constructor
Construct a new Maxim DS18 with a known sensor address. The pin on the mcu controlling power to the DS18, if using a separate power pin. Use -1 if the DS18 is continuously powered or you are using "parasitic" power. Use this version for more than one sensor attached to the OneWire bus.
MaximDS18::
Parameters
OneWireAddress
The unique address of the sensor. Should be an array of 8 values. To get the address of your sensor, plug a single sensor into your device and run the oneWireSearch example or the Single example provided within the Dallas Temperature library. The sensor address is programmed at the factory and cannot be changed.
powerPin
dataPin
The pin on the mcu of the OneWire bus.
measurementsToAverage
The number of measurements to take and average before giving a "final" result from the sensor; optional with a default value of 1.
Example Code
The Maxim DS18 is used in the menu a la carte example.
Classes
- class MaximDS18
- The Sensor sub-class for the DS18 one-wire temperature sensors.
- class MaximDS18_Temp
- The Variable sub-class used for the temperature output from a Maxim one-wire temperature sensor.
Sensor Variable Counts
The number of variables that can be returned by the DS18
- #define DS18_NUM_VARIABLES = 1
- Sensor::
_numReturnedValues; the DS18 can report 1 value. - #define DS18_INC_CALC_VARIABLES = 0
- Sensor::
_incCalcValues; we don't calculate any additional values.
Sensor Timing
The sensor timing for a Maxim DS18
- #define DS18_WARM_UP_TIME_MS = 2
- Sensor::
_warmUpTime_ms; the DS18 warms up in 2ms (reset time is < 480 µs). - #define DS18_STABILIZATION_TIME_MS = 0
- Sensor::
_stabilizationTime_ms; the DS18 is stable as soon as it warms up (0ms stabilization). - #define DS18_MEASUREMENT_TIME_MS = 750
- Sensor::
_measurementTime_ms; the DS18 takes 750ms to complete a measurement (at 12-bit: 750ms).
Temperature
The temperature variable from an Maxim DS18
- Range is -55°C to 125°C
- Accuracy:
- ± 0.5°C from -10°C to +85°C for DS18S20 and DS18B20
- ± 2°C for DS1822 and MAX31820
- Resolution:
- 0.0625°C for DS18B20, DS1822, and MAX31820 (12-bit)
- 0.5°C for DS18S20 (9-bit)
- DS18_
TEMP_ RESOLUTION = 4
- Reported as degrees Celsius (°C)
- Default variable code is DS18Temp
Construct a new MaximDS18_
MaximDS18_
Parameters
parentSense
The parent MaximDS18 providing the result values.
uuid
A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode
A short code to help identify the variable in files; optional with a default value of "DS18Temp".
- #define DS18_TEMP_RESOLUTION = 4
- Decimals places in string representation; temperature should have 4.
- #define DS18_TEMP_VAR_NUM = 0
- Sensor variable number; temperature is stored in sensorValues[0].
- #define DS18_TEMP_VAR_NAME = "temperature"
- Variable name in ODM2 controlled vocabulary; "temperature".
- #define DS18_TEMP_UNIT_NAME = "degreeCelsius"
- Variable unit name in ODM2 controlled vocabulary; "degreeCelsius" (°C)
- #define DS18_TEMP_DEFAULT_CODE = "DS18Temp"
- Default variable short code; "DS18Temp".
Define documentation
#define DS18_NUM_VARIABLES = 1
#include <src/sensors/MaximDS18.h>
Sensor::
#define DS18_INC_CALC_VARIABLES = 0
#include <src/sensors/MaximDS18.h>
Sensor::
#define DS18_WARM_UP_TIME_MS = 2
#include <src/sensors/MaximDS18.h>
Sensor::
#define DS18_STABILIZATION_TIME_MS = 0
#include <src/sensors/MaximDS18.h>
Sensor::
#define DS18_MEASUREMENT_TIME_MS = 750
#include <src/sensors/MaximDS18.h>
Sensor::
#define DS18_TEMP_RESOLUTION = 4
#include <src/sensors/MaximDS18.h>
Decimals places in string representation; temperature should have 4.
#define DS18_TEMP_VAR_NUM = 0
#include <src/sensors/MaximDS18.h>
Sensor variable number; temperature is stored in sensorValues[0].
#define DS18_TEMP_VAR_NAME = "temperature"
#include <src/sensors/MaximDS18.h>
Variable name in ODM2 controlled vocabulary; "temperature".
#define DS18_TEMP_UNIT_NAME = "degreeCelsius"
#include <src/sensors/MaximDS18.h>
Variable unit name in ODM2 controlled vocabulary; "degreeCelsius" (°C)
#define DS18_TEMP_DEFAULT_CODE = "DS18Temp"
#include <src/sensors/MaximDS18.h>
Default variable short code; "DS18Temp".