From edce21c3714c51f265bc2aa9d4ed8acc68d7d756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyrille=20M=C3=A9dard=20de=20Chardon?= Date: Wed, 5 Mar 2014 22:01:49 +0100 Subject: [PATCH] Cleaned up code, comments for SHT10 module to sync with blog post --- ModuleHumTempSensor/ModuleHumTempSensor.ino | 12 +++++++++--- ModuleHumTempSensor/README.markdown | 2 +- ModuleHumTempSensor/SHT1x.cpp | 5 +++-- ModuleHumTempSensor/SHT1x.h | 2 ++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ModuleHumTempSensor/ModuleHumTempSensor.ino b/ModuleHumTempSensor/ModuleHumTempSensor.ino index 8080552..a47db47 100644 --- a/ModuleHumTempSensor/ModuleHumTempSensor.ino +++ b/ModuleHumTempSensor/ModuleHumTempSensor.ino @@ -1,3 +1,8 @@ +/** + * Humidity - Temperature sensor module + * Cyrille Medard de Chardon, Christophe Trefois + */ + #include "SHT1x.h" #define dataPin 7 #define sckPin 8 //serial clock @@ -7,11 +12,10 @@ // Steady accuracy between 10-80 // example at 10/90 +/- 6%, 0/100 +/- 7.5% -// Temp accuracy +/- .5 degrees celcius -// Temp error increases more as we get farther from 25 celc. +// Temp accuracy +/- .5 degrees celsius +// Temp error increases more as we get farther from 25 cels. // example: @ 0/50 degrees, +/- 1.2 degrees - SHT1x th_sensor(dataPin, sckPin); void setup() @@ -27,6 +31,8 @@ void loop() // Read values from the sensor humid = th_sensor.readHumidity(); + // Since the humidity reading requires the temperature we simply + // retrieve the reading capture from the readHumidity() call. See the lib. temp_c = th_sensor.retrieveTemperatureC(); // Print data diff --git a/ModuleHumTempSensor/README.markdown b/ModuleHumTempSensor/README.markdown index f4f8774..e75ac03 100644 --- a/ModuleHumTempSensor/README.markdown +++ b/ModuleHumTempSensor/README.markdown @@ -39,7 +39,7 @@ Example: ### retrieveTemperatureC() ### -Returns a float of the temperature in celcius that was measured during the humidity measurement. This prevents needing two calls to the temperature sensor. Call the humidyt function readHumidity() then retrieveTemperatureC(). +Returns a float of the temperature in celcius that was measured during the humidity measurement. This prevents needing two calls to the temperature sensor. Call the humidty function readHumidity() then retrieveTemperatureC(). ### readHumidity() ### diff --git a/ModuleHumTempSensor/SHT1x.cpp b/ModuleHumTempSensor/SHT1x.cpp index 32cf034..dd67314 100644 --- a/ModuleHumTempSensor/SHT1x.cpp +++ b/ModuleHumTempSensor/SHT1x.cpp @@ -1,7 +1,7 @@ /** * SHT1x Library * - * Modified by Cyrille Medard de Chardon for 3V3 Arduino Fio + * Modified by Cyrille Medard de Chardon, Christophe Terfois for 3V3 Arduino Fio * * Copyright 2009 Jonathan Oxer / * Based on previous work by: @@ -76,6 +76,7 @@ float SHT1x::readHumidity() // const float C1 = -4.0; // for 12 Bit // const float C2 = 0.0405; // for 12 Bit // const float C3 = -0.0000028; // for 12 Bit + // Fio coefficients for SHT1x with 3.3V const float C1 = -2.0468; // for 12 bit const float C2 = 0.0367; // for 12 bit const float C3 = -0.0000015955;// for 12 bit, see Table 6 in SHT1x V5 datasheet @@ -210,7 +211,7 @@ int SHT1x::getData16SHT(int _dataPin, int _clockPin) pinMode(_dataPin, INPUT); pinMode(_clockPin, OUTPUT); val = shiftIn(_dataPin, _clockPin, 8); - // ~25 degrees celcius == 25 + // ~25 degrees celsius == 25 val <<= 8; //shift 8 bits left // ~25 degrees celsius == 6400 diff --git a/ModuleHumTempSensor/SHT1x.h b/ModuleHumTempSensor/SHT1x.h index fbaf397..cdba7b1 100644 --- a/ModuleHumTempSensor/SHT1x.h +++ b/ModuleHumTempSensor/SHT1x.h @@ -1,6 +1,8 @@ /** * SHT1x Library * + * Modified by Cyrille Medard de Chardon, Christophe Terfois for 3V3 Arduino Fio + * * Copyright 2009 Jonathan Oxer / * Based on previous work by: * Maurice Ribble: