Sorry, here is my Arduino code:
#define commPin 7 // Connect the Communications pin on the module to pin 7 on the Arduino
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// set up the LCD's number of columns and rows:
// Print a message to the LCD.
lcd.print("Temp & Humidity");
uint8_t data; // We will use this to store and array of the data
uint8_t bitCount = 7; // As data is sent with the most significant bit first we start at the end
uint8_t byteCount = 0; // Keep count of the Bytes
unsigned long t = 0; // Used to time the data pulse
char str; // We will use this to construct a string to send to the Serial port with the readings
for (int i=0; i< 4; i++) data[i] = 0; // Empty the data array
// First we need to tell the module we want it to take a reading, This is done by pulling the
// communications pin low for 18mS, then high for 40uS.
// When the module is ready to send its data it will pull the communications pin low then high
while(digitalRead(commPin) == LOW)
while(digitalRead(commPin) == HIGH)
// The module will now start sending 40 bits of data, the first Byte is the Humidity, the second is just null,
// the third is the Temperature, the fourth is null and the 5th is a check sum
// For simplicity we will just look at the first 3 Bytes.
for (int i=0; i<24; i++)
while(digitalRead(commPin) == LOW) // Wait for the High pulse to start
t = micros(); // Use variable t to store the time when the high pulse starts.
while(digitalRead(commPin) == HIGH) // Wait for the High pulse to end
// if we now do micros() -t we know how long the High pulse lasted, around 28uS represents a '0' and
// around 70uS represents a '1'. To allow some error in timing we can simply say that if the High Pulse
// is longer than 49uS then it is a '1' and if it is shorter then it is a '0'
if ((micros() - t) > 49) data[byteCount] |= (1 << bitCount);
if (bitCount == 0) // If the bitCount has reached 0 then we are on to the net Byte
bitCount = 7; // Reset the bitCount to the MSB
byteCount++; // On to the next Byte
else bitCount--; // bitCount not yet 0 so subtract 1
int humidity = data/3.75;
int temperature = data;
sprintf(str, "%d \t %d", humidity, temperature); // Construct a string out of all three readings
Serial.println(str); // Print it to the serial link
delay(2000); // This is not a quick sensor so give it time to rest :)
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
// print the number of seconds since reset:
So when I execute the fscanf function, each array variable will be logged every 2 seconds then?
I have attached my graph too if it helps: