Error message

hi,
I am trying to send temperatures to the serial monitor from a DHT11 sensor. when I try to compile the code I get the error message 'expected primary-expression before ‘.’ token" on the line that I have bolded below in the code.

#include <DHT.h>
#include <DHT_U.h>
int tempPin = 7;
void setup() {
  // put your setup code here, to run once
Serial.flush();
pinMode(tempPin, OUTPUT);
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
Serial.print("temperature");
[b]Serial.println(DHT.Temperature);[/b]
delay(5000);
}

I have tried reinstalling the library and that did not work. Thanks

I think you have to create a DHT-type object and use it to reference the object's methods (like below). Look at any examples that came with the DHT library (File->Examples-DHT->...).

DHT dht;

dht.Tempearture
void setup() {
  // put your setup code here, to run once
Serial.flush();
pinMode(tempPin, OUTPUT);
Serial.begin(9600);
}

Serial.flush() as the first line of the program. And we have a new winner for most useless line of code for the day!

OP, why would you put that there? Before you even call Serial.begin? Do you know what flush does? You should try to avoid using lines of code if you don't know what they do.

I understand what your saying about useless lines of code, but why am I getting the error message.

Hi, As suggested, look in the Examples part of the IDE, it will have the code you need.

Tom.. :)

Norgart200:
I understand what your saying about useless lines of code, but why am I getting the error message.

Because just like that Serial.flush() line that you put there without knowing what it does, you also tried to write code around the DHT without learning first how that code should be written. Study first, code second. Any other order leads to frustration.

Like was mentioned in reply #1, you have to create a DHT object and then you can call methods on those objects.