This library demonstrates how to use the sensors on the QW Shield.

Dependents:   QW-TEMP_GPS-NMEA QW-Motiondetection QW-Closet-detection

Embed: (wiki syntax)

« Back to documentation index

LinearTempSensor Class Reference

LinearTempSensor Class Reference

Linear Temperature Sensor class. More...

#include <LinearTempSensor.h>

Public Types

enum  SensorType { MCP9700, MCP9701, LM35 }
 

Sensor Type Definitions.

More...

Public Member Functions

 LinearTempSensor (PinName ain, int N=10, SensorType type=MCP9700)
 Create a Temperature Sensor instanse.
float Sense ()
 Sample (read) sensor data and store to buffer.
float GetAverageTemp ()
 Calculate average temperature from sample buffer.
float GetLatestTemp ()
 Calculate temperature from the latest sample.

Detailed Description

Linear Temperature Sensor class.

Sample and store sensor acuired value in N (default=10) times and calculate avarage temperature from sampled data Supports Microchip MCP9700/9701, National Semiconductor LM35

Author:
Todotani

Definition at line 18 of file LinearTempSensor.h.


Member Enumeration Documentation

enum SensorType

Sensor Type Definitions.

Enumerator:
MCP9700 

Microchip MCP9700 (Default)

MCP9701 

Microchip MCP9701.

LM35 

National Semiconductor LM35.

Definition at line 21 of file LinearTempSensor.h.


Constructor & Destructor Documentation

LinearTempSensor ( PinName  ain,
int  N = 10,
SensorType  type = MCP9700 
)

Create a Temperature Sensor instanse.

Parameters:
ainPinName of analog input
NNumber of samples to calculate average temperature (default = 10)
typeSensor type (default = MCP9700)

Definition at line 9 of file LinearTempSensor.cpp.


Member Function Documentation

float GetAverageTemp (  )

Calculate average temperature from sample buffer.

Parameters:
None
Returns:
Average temperature from N times of sumple (Centigrade)

Definition at line 65 of file LinearTempSensor.cpp.

float GetLatestTemp (  )

Calculate temperature from the latest sample.

Parameters:
None
Returns:
Temperature from the latest sampled data (Centigrade)

Definition at line 90 of file LinearTempSensor.cpp.

float Sense (  )

Sample (read) sensor data and store to buffer.

Parameters:
None
Returns:
Sensor-acuired value (mV)

Definition at line 46 of file LinearTempSensor.cpp.