DS18B20 temperature sensor module.
- Source:
- See:
Methods
(inner) addConverter(name, converterFunc)
Adds a temperature scale converter function. Conversion functions should accept one parameter and return a value representing the converted temperature. The input to the function is the raw temperature from the DS18B20 sensor, an integer value that is 1000 * X, where X is the temperature in Celcius with four decimals.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Name of the converter, this is used to identify the output of parseTemp |
converterFunc |
function | Function implementing the conversion |
- Source:
Throws:
-
-
'Name must be provided' Thrown if no name is provided
- Type
- Error
-
-
-
'Converter function was not a function' Thrown if converterFunc is not a function
- Type
- Error
-
(inner) init(sensors, newSettings, callback)
Initializes the temp sensor. The module can use one or more available DS18B20 sensors. Depending on the type of parameter one, different behaviors are achieved. Passing a string is equivalent to passing a {string} {array} with one element. Passing {undefined} is equivalent to passing a {string} {array} with all installed sensors.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
sensors |
array | Sensors to use, can be either a string, an array of strings or undefined. If settings.defaultPath is set to true, the values are the ID of the sensor, otherwise the full path to the sensor output. |
|||||||||
newSettings |
object | object representing changes to settings Properties
|
|||||||||
callback |
function | Function to be called when init is finished |
- Source:
(inner) parseTemp(input) → {array}
Parses the raw data from the sensors.
Parameters:
Name | Type | Description |
---|---|---|
input |
array | An array containing the data to parse |
- Source:
Returns:
An array with parsed data
- Type
- array
(inner) readAndParse(callback)
Adds a temperature scale converter function. Conversion functions should accept one parameter and return a value representing the converted temperature. The input to the function is the raw temperature from the DS18B20 sensor, an integer value that is 1000 * X, where X is the temperature in Celcius with four decimals.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | Function that is called when readAndParse finishes |
- Source:
Throws:
-
'Callback function required' Thrown if no callback function is provided
- Type
- Error
(inner) readTemp(callback)
Reads the raw data from the sensors.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | Function to call when all sensor data has bean read or failed |
- Source:
Throws:
-
'Callback function required' Thrown if no callback function is provided
- Type
- Error