exit status 1 expected primary-expression before '.' token

I know that there is many posts about this or similar problems, as I have read through a few of them to see if I can solve this by myself.
All I know from other posts that there is a . in the wrong place??

The code/sketch is from How to Set Up the DHT11 Humidity Sensor on an Arduino

I had to change a cople of lines as there were other errors with <dht.h> then dht DHT;.
The said lines are now <DHT.h> and DHT dht;

#include <DHT.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

DHT dht;

#define DHT11_PIN 7

void setup() {
  lcd.begin(16, 2);
}

void loop()
{
  int chk = DHT.read11(DHT11_PIN);
  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(DHT.temperature);
  lcd.print((char)223);
  lcd.print("C");
  lcd.setCursor(0, 1);
  lcd.print("Humidity: ");
  lcd.print(DHT.humidity);
  lcd.print("%");
  delay(1000);
}

The error:

home/rob/sketchbook/CBsics_DHT_LCD/CBsics_DHT_LCD.ino: In function 'void loop()':
CBsics_DHT_LCD:16:16: error: expected primary-expression before '.' token
int chk = DHT.read11(DHT11_PIN);
^
CBsics_DHT_LCD:19:16: error: expected primary-expression before '.' token
lcd.print(DHT.temperature);
^
CBsics_DHT_LCD:24:16: error: expected primary-expression before '.' token
lcd.print(DHT.humidity);
^
Multiple libraries were found for "DHT.h"
Used: /home/rob/sketchbook/libraries/DHT
Not used: /home/rob/sketchbook/libraries/DHT_sensor_library
Multiple libraries were found for "LiquidCrystal.h"
Used: /opt/arduino-1.8.8/libraries/LiquidCrystal
Not used: /home/rob/sketchbook/libraries/Newliquidcrystal_1.3.5
Using library DHT in folder: /home/rob/sketchbook/libraries/DHT (legacy)
Using library LiquidCrystal at version 1.0.7 in folder: /opt/arduino-1.8.8/libraries/LiquidCrystal
exit status 1
expected primary-expression before '.' token

EXACTLY which DHT library are you using? Have you tried the built-in examples that come with that library?

dht.xx not DHT.xx

You named it dht in lower letters so request to DHT.temperature should be dht.temperature,dht.humidity etc.

surepic:
dht.xx not DHT.xx

You named it dht in lower letters so request to DHT.temperature should be dht.temperature,dht.humidity etc.

The reason I named it dht in lowercase was because this gave an error: dht DHT because 'dht' does name a type.

Also changing the name from DHT.Humidity to dht.Humidity etc, moves the error line up to here:

int chk = DHT.read11(DHT11_PIN);, and if I changed that to dht.read it says 'Class DHT' has no member named 'read11'

Thanks

The declaration is fine. When you try to use the dht object i.e. where your original error was, use dht instead of DHT.

gfvalvo:
EXACTLY which DHT library are you using? Have you tried the built-in examples that come with that library?

The DHT library I am using is just the one which is the one in the sketch/code: <DHT.h>

I'm not sure which built-in examples you mean. I have tried the DHT sensor library, still same error, Adafruit unified sensor, still the same error.

Thanks

avalon66:
The DHT library I am using is just the one which is the one in the sketch/code: <DHT.h>

There a several libraries that use the name "DHT.h". EXACTLY which one are you using? If you downloaded and installed in manually, provide a clickable link. If you installed it with the Arduino Library Manager, go there and check which one it is. Tell us precisely.

I'm not sure which built-in examples you mean. I have tried the DHT sensor library, still same error, Adafruit unified sensor, still the same error.

Almost every library comes with simple, built-in example that show how to use it. Have you tried those?

gfvalvo:
There a several libraries that use the name "DHT.h". EXACTLY which one are you using? If you downloaded and installed in manually, provide a clickable link. If you installed it with the Arduino Library Manager, go there and check which one it is. Tell us precisely.
Almost every library comes with simple, built-in example that show how to use it. Have you tried those?

No I have not tried those, and I cannot see I have actually seen any built- in examples.

The DHT.h file is in a folder called DHT, and I downloaded it from github:

DHT Temperature & Humidity Sensor library for Arduino.

Features:

  • Support for DHT11 and DHT22/AM2302/RHT03
  • Auto detect sensor model
  • Very low memory footprint
  • Very small code

Written by Mark Ruys, mark@paracas.nl.

As I said initially, I got the sketch from circuit basics site and there was no library file include to actually download. Because it was typed as <dht.h>, I then assumed that it should be <DHT.h>. I knew I alread a DHT library, so that is what I used.

I've found another DHT library from Rob Tillart
FILE: dht.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.14
// PURPOSE: DHT Temperature & Humidity Sensor library for Arduino
// URL: Arduino Playground - DHTLib
//

dht.read() not dht.read11

From where that 11 came from

BOTH of those libraries come with example(s).

surepic:
dht.read() not dht.read11

From where that 11 came from

The 11 came from the original sketch or code from the website I got it from:

http://www.circuitbasics.com/how-to-set-up-the-dht11-humidity-sensor-on-an-arduino/

If you read from here, it will explain why it was I am using: Display Humidity and Temperature on an LCD

dht.read still same error, no member named 'read'.

It looks like the tutorial you were following was using a different DHT library than the one you have. Look at the example sketch that comes with your library - the functions it provides are completely different. Start with that & then add in your LCD stuff.

@avalon66 In link you provided nothing about read11.

Assuming u are using dht library from

https://playground.arduino.cc/Main/DHTLib

Error is in the line naming the object.
So change DHT dht to dht DHT.

And leave DHT.read without any numbers attached to the word read. There is no function read11 in that library.

Or better look the examples in library as others advised.

wildbill:
Look at the example sketch that comes with your library - the functions it provides are completely different.

As suggested way back in Reply #1. Here we are at #13.

gfvalvo:
BOTH of those libraries come with example(s).

From the first sreenshot L1.JPG it is the arduinoDHT, which I have just tried, but it didn't change anything.

For the second screenshot L2.JPG I am struggling to find a download for DHTlib, and NOT DHTLib.

Thanks

And from reply #2 we see that it was my fault :-))

surepic:
@avalon66 In link you provided nothing about read11.

Assuming u are using dht library from

Arduino Playground - DHTLib

Error is in the line naming the object.
So change DHT dht to dht DHT.

And leave DHT.read without any numbers attached to the word read. There is no function read11 in that library.

Or better look the examples in library as others advised.

The coding starts from just under this: Display Humidity and Temperature on an LCD
and is the 1st block of code which you can scroll up and down a little.

void loop()
{
int chk = DHT.read11(DHT11_PIN);
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(DHT.temperature);

surepic:
@avalon66 In link you provided nothing about read11.

I replied to you at post #16 about read11

Here is the code from the tutorial you looked at:

#include <dht.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

dht DHT;

#define DHT11_PIN 7

void setup(){
  lcd.begin(16, 2);
}

void loop()
{
  int chk = DHT.read11(DHT11_PIN);
  lcd.setCursor(0,0); 
  lcd.print("Temp: ");
  lcd.print(DHT.temperature);
  lcd.print((char)223);
  lcd.print("C");
  lcd.setCursor(0,1);
  lcd.print("Humidity: ");
  lcd.print(DHT.humidity);
  lcd.print("%");
  delay(1000);
}

Check it out and see what differences you can see between this one and yours

surepic already gave you the solution

Error is in the line naming the object.
So change DHT dht to dht DHT.

@surepic in the DHTLib library from How to Set Up the DHT11 Humidity Sensor on an Arduino there actually exists a "read11" function

class dht
{
public:
    // return values:
    // DHTLIB_OK
    // DHTLIB_ERROR_CHECKSUM
    // DHTLIB_ERROR_TIMEOUT
    int read11(uint8_t pin);
    int read(uint8_t pin);

    inline int read21(uint8_t pin) { return read(pin); };
    inline int read22(uint8_t pin) { return read(pin); };
    inline int read33(uint8_t pin) { return read(pin); };
    inline int read44(uint8_t pin) { return read(pin); };

    double humidity;
    double temperature;

private:
    uint8_t bits[5];  // buffer to receive data
    int _readSensor(uint8_t pin, uint8_t wakeupDelay);
};

dht.cpp (4.6 KB)

dht.h (1.46 KB)

The differences between the tutorial sketch and the I have is these library files:

#include <Wire.h>
//#include <hd44780.h> // main hd44780 header
//#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header

After commenting them out, it made no difference, and I can't see any other differences yet.

I added those because my plan was to use a I2C backboard on an LCD screen I have spare.

Naming DHT dht to dht DHT produces an error:
exit status 1
'dht' does not name a type

Regarding to 2 dht files you have uploaded, I already have the same versions of, and that is what I am using