Skip to content

Commit

Permalink
Cleaned up code, comments for SHT10 module to sync with blog post
Browse files Browse the repository at this point in the history
  • Loading branch information
serialc committed Mar 5, 2014
1 parent 903a14c commit edce21c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
12 changes: 9 additions & 3 deletions 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
Expand All @@ -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()
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ModuleHumTempSensor/README.markdown
Expand Up @@ -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() ###

Expand Down
5 changes: 3 additions & 2 deletions 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 <jon@oxer.com.au> / <www.practicalarduino.com>
* Based on previous work by:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions 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 <jon@oxer.com.au> / <www.practicalarduino.com>
* Based on previous work by:
* Maurice Ribble: <www.glacialwanderer.com/hobbyrobotics/?p=5>
Expand Down

0 comments on commit edce21c

Please sign in to comment.