SHT11 Sensor: Incorrect Readings, Calibration?
fmc
Posts: 5
I am using the SHT11 Sensor with Wiring/Arduino and getting temperature readings of -40 C, -40 F and -4.5% humidity in a room that is not colder freezing cold.
I am curious if anyone recognizes this as a clear-cut problem on my end.
Very grateful for any ideas.
Thanks
FM
I am curious if anyone recognizes this as a clear-cut problem on my end.
Very grateful for any ideas.
Thanks
FM
Comments
And these are the connections on the board:
Pin 1 SHT11 ---> pin 10 on Arduino / "dataPin"
Pin 3 SHT11 --->Pin 11 on Arduino / "clockPin"
Pin 4 SHT11 --> Ground on Arduino
Pin 8 SHT11 ---> 5v Arduino (also tried 3.3V)
Thank you. Tell me I am an idiot, tell me anything...
---
/**
* ReadSHT1xValues
*
* Read temperature and humidity values from an SHT1x-series (SHT10,
* SHT11, SHT15) sensor.
*
* Copyright 2009 Jonathan Oxer <jon@oxer.com.au>
* www.practicalarduino.com
*/
#include <SHT1x.h>
// Specify data and clock connections and instantiate SHT1x object
#define dataPin 10
#define clockPin 11
SHT1x sht1x(dataPin, clockPin);
void setup()
{
Serial.begin(38400); // Open serial connection to report values to host
Serial.println("Starting up");
}
void loop()
{
float temp_c;
float temp_f;
float humidity;
float humidityOffset = 40;
float tempOffset = 112;
// Read values from the sensor
temp
_c = sht1x.readTemperatureC() + tempOffset;
temp_f = sht1x.readTemperatureF() + tempOffset;
humidity = sht1x.readHumidity() + humidityOffset;
// Print the values to the serial port
Serial.print("Temperature: ");
Serial.print(temp_c, DEC);
Serial.print("C / ");
Serial.print(temp_f, DEC);
Serial.print("F. Humidity: ");
Serial.print(humidity);
Serial.println("%");
delay(2000);
}
1) do you need "sht1x" repeated in your line to initiate the object?
2) why is the "temp_c" reading line split into two lines? Is your code that way?
Almost all of my errors with Sensirion devices are crazy readings like yours and it is because I swapped thedata and clock lines. Are you using Parallax's SHT11 module?
Do mean that i should remove something in here?
SHT1x sht1x(dataPin, clockPin);
Yes....I have SHST11 the Sensirion -- I have tried swapping the clock and data lines too. Should I be moving onto a different part of the breadboard maybe or trying different digital pins on my Uno? I seem to get consistent readings even when wildly changing the way things are routed to Uno.
I also just discovered I have this problem with the [TMP36] temp sensor. If two sensors are wildly off and I am following instruction manuals to the T maybe I need to try another Uno?
The device driver is in the sht1x.read.... functions, but if you have copied those verbatim from the article, they are unlikely to be the problem.
The data sheet says the "The 4.7 kΩ pull-down resistor on the clock is optional but may be required if your application experiences sensor lock-up. "
I'm an idiot -- do these wacky negative readings = sensor lock up?
It also has 330 Ω 4.7 kΩ on the data line and says "The module includes a data-line pull-up"
Thank you for all your help and ideas...I'm still confused by this moody sensor.
The negative readings and the wackiness could in fact be accounted for by the lack of the pulldown on the clock line. The deal is that the clock line has to be low when the power is applied to the chip, and since it is an input and microprocessor pins start as inputs, there is a certain amount of chance as to how it comes up. It may be affected by how you wave your hand and other vaguaries. Only a small proportion of SHT11s seem to have the problem, but true to Murphy, the first one you try is bound to be one of the unlucky ones. The pulldown does not have to be 4.7k. It can be quite a high value, 100k or 1M, and will suffice to hold the pin low until µP pin is driven as a low output.
As others have noted the behavior is more likely to be related to the circuit. ALL sensors can be wacky and moody. The more sensitive it is, the more you have to be mindful how it's hooked up.
On the above, you have it correct here. This line is just a shortcut constructor, and says to create an object called sht1x from the SHT1x class. To make your code more readable, you could change the object name from sht1x to something more descriptive. In Microsoftese it would be something like MySensor; camcelcased it would be mySensor. (Not that MySensor is descriptive, but it's just to give you the idea.)
-- Gordon
Your wires may go to the right pins, but I would still check pin numbers first and quality of the wiring second.
Your code is OK..........
I set up a "Due" with my SHT11 and your code gives this output.
Starting up
Temperature: 136.2200012207C / 187.6319885253F. Humidity: 63.88%
Temperature: 136.2699890136C / 187.7219848632F. Humidity: 63.97%
Temperature: 136.2299957275C / 187.5599975585F. Humidity: 63.73%
The integrated code example in the IDE 18 (my old faithfull ide which never fails) (gives this which is correct):-
Starting up
Temperature: 23.7399978637C / 74.7859954833F. Humidity: 24.39%
Temperature: 23.7299995422C / 74.7679977416F. Humidity: 24.39%
Temperature: 23.7199974060C / 74.7859954833F. Humidity: 24.39%
Your code is working...... taking into account your offset values!!......
.... i guess either your sensor is zapped or wires are too long or maybe the data/clk pins are reversed......
... or the SHT library is suspect.....
Hope this helps..... Gareth