ModularSensors > Files > sensors / MaximDS18.h

MaximDS18.h file

Contains the MaximDS18 sensor subclass and the MaximDS18_Temp variable subclass.

These are for the Maxim DS18B20, DS18S20, MAX31820, DS1822, and DS1820 vtemperature sensors.

This depends on Dallas Temperature library, which itself is dependent on the OneWire library.


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.


#define DS18_NUM_VARIABLES = 1
Sensor::_numReturnedValues; the DS18 can report 1 value.

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).
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).


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)
  • Reported as degrees Celsius (°C)
  • Default variable code is DS18Temp

MaximDS18_Temp(MaximDS18* parentSense, const char* uuid = "", const char* varCode = DS18_TEMP_DEFAULT_CODE) explicit

Construct a new MaximDS18_Temp object.

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".