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
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
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.