Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
DS18S20 Class Reference

This class implements access to the DS18x20 range of temperature sensors. More...

#include <ds18s20.h>

Public Member Functions

 DS18S20 (uint8_t workPin=DS1820_WORK_PIN)
 Instantiate a DS18S20 object. More...
 
void Init (uint8_t)
 Initiate communication on 1-wire bus. More...
 
void StartMeasure ()
 Start measurement of all connected sensors. More...
 
void RegisterEndCallback (DS18S20CompletedDelegate)
 Register the callback function that is run when measurement is complete. More...
 
void UnRegisterCallback ()
 Unregister the callback function to avoid activity after measurement is complete. More...
 
float GetCelsius (uint8_t)
 Get the value of the last measurment from a sensor. More...
 
float GetFahrenheit (uint8_t)
 Get the value of the last measurment from a sensor. More...
 
bool IsValidTemperature (uint8_t)
 Check if the last measurement for a sensor is valid. More...
 
bool MeasureStatus ()
 Check if measurement is in progress. More...
 
uint64_t GetSensorID (uint8_t)
 Get the ID (1-wire address) of a sensor. More...
 
uint8_t GetSensorsCount ()
 Get the quantity of sensors detected during last measurement. More...
 

Detailed Description

This class implements access to the DS18x20 range of temperature sensors.

Constructor & Destructor Documentation

DS18S20::DS18S20 ( uint8_t  workPin = DS1820_WORK_PIN)

Instantiate a DS18S20 object.

Member Function Documentation

float DS18S20::GetCelsius ( uint8_t  )

Get the value of the last measurment from a sensor.

Parameters
Indexof sensor to retrieve value from
Returns
Temperature value in degrees Celsius or zero for invalid sensor index
Note
Call IsValidTemperature() to check value is valid before calling this function
float DS18S20::GetFahrenheit ( uint8_t  )

Get the value of the last measurment from a sensor.

Parameters
Indexof sensor to retrieve value from
Returns
Temperature value in degrees Fahrenheit or zero for invalid sensor index
Note
Call IsValidTemperature() to check value is valid before calling this function
uint64_t DS18S20::GetSensorID ( uint8_t  )

Get the ID (1-wire address) of a sensor.

Parameters
Indexof sensor
Returns
ID of sensor
uint8_t DS18S20::GetSensorsCount ( )

Get the quantity of sensors detected during last measurement.

Returns
Quantity of detected sensors
Note
Maximum quantity of sensors is defined in library header file by MAX_SENSORS
void DS18S20::Init ( uint8_t  )

Initiate communication on 1-wire bus.

Parameters
GPIOpin acting as 1-wire bus
bool DS18S20::IsValidTemperature ( uint8_t  )

Check if the last measurement for a sensor is valid.

Parameters
Indexof sensor to check
Returns
True if last measured temperature is valid, false for invalid value or invalid sensor index
Note
Call this function before reading value to ensure the value is valid
Todo:
Initial code review suggests this is set once but never rechecked so may not be accurate
bool DS18S20::MeasureStatus ( )

Check if measurement is in progress.

Returns
True if measurement is in progress
void DS18S20::RegisterEndCallback ( DS18S20CompletedDelegate  )

Register the callback function that is run when measurement is complete.

Parameters
Nameof the callback function
Note
Callback function must be a DS18S20CommpleteDelegate type
void DS18S20::StartMeasure ( )

Start measurement of all connected sensors.

Note
Scans for all connected sensors, measures value from each then calls the registered callback function
void DS18S20::UnRegisterCallback ( )

Unregister the callback function to avoid activity after measurement is complete.