Error: expected promary-expression before ".'

Hi all. I am not very familiar with Arduino. Doing this for the uni project. Please help :")
Im doing a humidity + temp sensor with Bluetooth monitoring.

Here is my error:
In function 'void loop()':

sketch_apr21a:27:21: error: expected primary-expression before '.' token

int readData = DHT.read11(dataPin);

                 ^

sketch_apr21a:29:12: error: expected primary-expression before '.' token

hum = DHT.humidity;

        ^

sketch_apr21a:30:13: error: expected primary-expression before '.' token

temp = DHT.temperature;

         ^

exit status 1

expected primary-expression before '.' token

My code:

#include <SoftwareSerial.h>
SoftwareSerial bt(8, 9); // RX, TX
#include "DHT.h"
#define dataPin 3

// Pin for the DHT sensor
#define DHTPIN 3
#define DHTTYPE DHT11

DHT dht (DHTPIN, DHTTYPE);

int temp;
int hum;

void setup() {

Serial.begin(9600);
bt.begin(9600);
Serial.println("Ready");

}

void loop(){
int readData = DHT.read11(dataPin);

hum = DHT.humidity;
temp = DHT.temperature;

bt.print(temp);
bt.print(";");
bt.print(hum);
bt.println(";");

delay(10000);
}

Which DTH library do you use? I suspect that your mixing code from different libraries.

Also note that C/C++ is case sensitive.

thank you so much for replying!!
I am using DHT Sensor Library.

You have any suggestions?

Your instance is called dht not DHT -
DHT dht (DHTPIN, DHTTYPE);
means - using the DHT library create something I can use and call it dht.

okay, thank you! Its solved now. I am using another library instead

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