Expected primary expression

C:\Users\Admin\OneDrive\Documents\Arduino\sketch_oct29cworks\sketch_oct29cworks.ino: In function 'void loop()':
C:\Users\Admin\OneDrive\Documents\Arduino\sketch_oct29cworks\sketch_oct29cworks.ino:14:26: error: expected primary-expression before '.' token
int readData =( DHT11.read11(outPin));
^
C:\Users\Admin\OneDrive\Documents\Arduino\sketch_oct29cworks\sketch_oct29cworks.ino:15:24: error: request for member 'temperature' in 'readData', which is of non-class type 'int'
float t = readData.temperature; // Read temperature
^~~~~~~~~~~
C:\Users\Admin\OneDrive\Documents\Arduino\sketch_oct29cworks\sketch_oct29cworks.ino:16:20: error: expected primary-expression before '.' token
float h = DHT11.humidity; // Read humidity Serial.print(h);
^
C:\Users\Admin\OneDrive\Documents\Arduino\sketch_oct29cworks\sketch_oct29cworks.ino: At global scope:
C:\Users\Admin\OneDrive\Documents\Arduino\sketch_oct29cworks\sketch_oct29cworks.ino:26:7: error: 'Serial' does not name a type
Serial.print("Greater than 20");
^~~~~~
C:\Users\Admin\OneDrive\Documents\Arduino\sketch_oct29cworks\sketch_oct29cworks.ino:27:5: error: expected declaration before '}' token
}
^

exit status 1

Compilation error: expected primary-expression before '.' token

Please do not post in "Uncategorized"; see the sticky topics in Uncategorized - Arduino Forum. Your topic has been moved.

You will have to post your code; don't forget to use code tags as described in How to get the best out of this forum.

hello Delta G. thanks for your anticipated help. I am 85 years old and having trouble with error messages in Arduino. I have spent literally tens of hours trying to figure out the message expected primary expression before '.' token. Many answers are given, but they all seem simply to correct the code for the client without telling why there is an expected primary expression and how to ensure that I don't make the same mistake again in another Sketch
#include <DHT11.h>
dht DHT11.h;
DHT11.h dht(DHTPIN, DHTTYPE);

int (DHT11PIN_8);

void setup() {
Serial.begin(9600);
}

void loop() {
Serial.println();
int data = DHT11.read(DHT11PIN);
float h = DHT11.humidity; // Read humidity Serial.print(h)
float t = DHT11.temperature; // Read temperature

Serial.print("Temperature = ");
Serial.print(t);
Serial.print("°C | ");
Serial.print((t * 9.0) / 5.0 + 32.0); // Convert celsius to fahrenheit
Serial.println("°F ");
Serial.print("Humidity = ");

Serial.println("% ");
Serial.println("");

delay(5000); // wait two seconds

Sorry, the error is in lines int data float h =DHT.humidity; and again in float t =DHT.temperature.

Hello tom_tuffin

Welcome to the world's best Arduino forum ever.

Do some basic studies and run the DHT11 tutorial that can be found on the WWW.

Have a nice day and enjoy coding in C++.

Something that you don't understand about my earlier comment

To figure it out you need an understanding of C++ language.

"Expected primary expression" is not the only error in your code. Honesty speaking, this sketch has a lot of errors and typos, so, I think , the preferable way for you is just to copy the syntax from the library examples.

thanks B707 it's good of you to help. I have corrected a few errors in the sketch and thought that this was the only thing in my way. Judging by the number of posts concerning this error, I'm not the only one having trouble with it -not that that helps a lot. If you have the patience and time I would be grateful if you could go through all the errors or at least some. I need to learn and can't see that copying syntax will help much. I have had done several successful sketches but get held up with the error mentioned above and "unqualified id' and haven't got my head around them yet. what do you think?
Best wishes Tom from Down Under.

Hi, Tom, start from posting your code properly as suggested in posts #2 and #7

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.