Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed mbedConnectorInterface mbedEndpointNetwork TrashSensors
Fork of TempAndDistTest by
Diff: GroveTemp.cpp
- Revision:
- 11:ac0ff76a6deb
- Parent:
- 10:338191178cbf
--- a/GroveTemp.cpp Mon May 18 00:44:59 2015 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-#include "mbed.h"
-#include <math.h>
-#include "GroveTemp.h"
-//
-AnalogIn thermistor(A0); /* Temperature sensor connected to Analog Grove connector */
-
-GroveTempSensor::GroveTempSensor() {
- resetMinMax();
-}
-
-float GroveTempSensor::getTemp() {
- unsigned int analogRead;
-// units,
-// tens;
-
- analogRead = thermistor.read_u16(); /* Read analog value */
-
- /* Calculate the resistance of the thermistor from analog votage read. */
- resistance = (float) 10000.0 * ((65536.0 / analogRead) - 1.0);
-
- /* Convert the resistance to temperature using Steinhart's Hart equation */
- temperature = (1/((log(resistance/10000.0)/TEMP_BETA) + (1.0/298.15)))-273.15;
-
-// units = (int) temperature % 10;
-// tens = (int) temperature / 10;
- if (temperature > maxTemp)
- maxTemp = temperature;
- if (temperature < minTemp)
- minTemp = temperature;
-
- return temperature;
-}
-
-void GroveTempSensor::resetMinMax() {
- maxTemp = -999.9;
- minTemp = 999.9;
- minMaxDefined = false;
-}
-
-float GroveTempSensor::getMin() {
- if (!minMaxDefined)
- getTemp();
- return minTemp;
-}
-
-float GroveTempSensor::getMax() {
- if (!minMaxDefined)
- getTemp();
- return maxTemp;
-}
\ No newline at end of file
