Hi Guys,
I'm trying to interface with the SHT-11 digital temperature and humidity sensor. I will note that I have never tried to use SPI before, so I am probably making some gross error!
The data sheet is here: http://www.sensirion.com/en/pdf/product_information/Data_Sheet_humidity_sensor_SHT1x_SHT7x_E.pdf
It uses a 2 wire SPI interface. After I start the transmission (pulsing SCK wile DATA is high) and send the command byte (00000011), the SHT-11 should pull DATA low to acknowledge the transmission.
As you can see, I have a while structure to test if DATA is low, but all I see in the serial monitor is "Still busy" (never seeing 'ready to read data') indicating that DATA is high and not being pulled low. What am I doing wrong?
Could this be a bad IC, or is it me? I would appreciate some help for a newbie!
Tom.
int sckPin = 8;
int dataPin = 9;
int busy = 1;
void shtStart() {
pinMode(dataPin, OUTPUT);
dataPin = HIGH;
sckPin = HIGH;
dataPin = LOW;
sckPin = LOW;
sckPin = HIGH;
dataPin = HIGH;
sckPin = LOW;
dataPin = LOW;
}
void pulseSck() {
sckPin = HIGH;
sckPin = LOW;
}
void setup() {
Serial.begin(9600);
pinMode(sckPin, OUTPUT);
}
void loop() {
// Prepare IC to receive command byte
shtStart();
// Transmit address (always 000)
pulseSck();
pulseSck();
pulseSck();
// Transmit temperature command (00011)
pulseSck();
pulseSck();
pulseSck();
dataPin = HIGH;
pulseSck();
pulseSck();
// Data pin is now an input
pinMode(dataPin, INPUT);
// Wait for the IC to pull dataPin LOW
// indicating that temperature has been
// measured
busy = digitalRead(dataPin);
while(busy == 1) {
busy = digitalRead(dataPin);
Serial.println("Still busy");
delay(100);
}
Serial.println("Ready to read data");
delay(10000);
}