-2

I am using a arduino and dht22 sensor for my project purpose annd gettting error as expecte before unqualified '.' token

MY CODE IS :

#include <DHT.h>


#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
#include <Wire.h>


#define DHTPIN 8     
#define DHTTYPE DHT22   

LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

int ldrpin=A0;
int ldr=0;


DHT dht(DHTPIN, DHTTYPE);


//
//
//
//
//
//
//
//


void setup() 
    {

   lcd.begin(16, 2);
   Serial.begin (9600);
   DHT .begin();
     pinMode(ldrpin,INPUT);

}

//
//
//
//
//
//
//

void loop() 
    {

  lcd.setCursor(0,0);


 //ldr 
  ldr=analogRead(ldrpin);



//LDR DISPLAY
  Serial.println("LIGHT INTENSITY");
  Serial.println(ldr);
  Serial.print(" lx\t");
  delay(2000);

   lcd.clear();
    lcd.setCursor(0, 0); 

   lcd.print("LIGHT INTENSITY");
    delay(200);
    lcd.print(ldr);
      delay(2000);


//dht22 
delay(2000);

   int chk = DHT.read(DHTPIN);
    float humidity = DHT.humidity;
    float temperature = DHT.temperature;



//dht22 display
1.  Serial.println("Humidity: "); 
2.    Serial.print(h);
3.    Serial.print(" %\t");
4.    Serial.println("Temperature: "); 
5.    Serial.print(t);
  Serial.println(" *C ");

my error message is

Arduino: 1.6.4 (Windows 8.1), Board: "Arduino Uno"

LCD.ino: In function 'void setup()':
LCD:38: error: expected unqualified-id before '.' token
LCD.ino: In function 'void loop()':
LCD:80: error: expected primary-expression before '.' token
LCD:81: error: expected primary-expression before '.' token
LCD:82: error: expected primary-expression before '.' token
LCD:87: error: expected ';' before 'Serial'
LCD:88: error: expected ';' before 'Serial'
LCD:89: error: expected ';' before 'Serial'
LCD:90: error: expected ';' before 'Serial'
LCD:91: error: expected ';' before 'Serial'
expected unqualified-id before '.' token

This report would have more information with "Show verbose output during compilation" enabled in File > Preferences.

some one help me please!!

  • 1
    Don’t shout. No need for an ALLCAPS title – RubberDuck Feb 17 '18 at 11:26
0

Line 38, 80, 81, 82: DHT is a class name, dht is an instance of that class (an object, a variable), so write:

   dht.begin();

And all those call to DHT.something? Wrong too. Reemplaza DHT with dht.

All others errors: Why are you written "1. ", "2. ", before statements? Delete those numbers:

Serial.println("Humidity: "); 
Serial.print(h);
Serial.print(" %\t");
Serial.println("Temperature: "); 
Serial.print(t);
Serial.println(" *C ");

Also, you are missing a "}" to end loop().

When you correct this errors, others will surface.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.