Error message .....non-class type 'char'

#include <IRLibSendBase.h>    //We need the base code
#include <IRLib_HashRaw.h>    //Only use raw sender
#include <dht.h>

#define dht_apin A0 // Analog Pin sensor is connected to
 
char dht, DHT;

 int sensor = 2;

void setup(){
pinMode(sensor, INPUT);
Serial.begin(9600);}


IRsendRaw mySender;

void loop() {
  {
  Serial.begin(9600);
  delay(2000); 
  while (!Serial); //delay for Leonardo
  Serial.println("DHT11 Humidity & temperature Sensor\n\n");
  }
  
  {
  DHT.read11(dht_apin);
  int temp = DHT.temperature;
  Serial.print("temperature = ");
  Serial.print(temp); 
  Serial.println(" C");
  int sensorval = digitalRead(sensor);
  Serial.println(sensorval);
  
  if (sensorval == HIGH)&& if (temp > 26 ) {
    mySender.send(rawDataOn,RAW_DATA_LEN,36);//Pass the buffer,length, optionally frequency
    Serial.println(F("AC Switched On"));
  }
  else if (sensorval == HIGH)&& if (temp < 29 ) {
    mySender.send(rawDataOff,RAW_DATA_LEN,36);//Pass the buffer,length, optionally frequency
    Serial.println(F("AC Switched Off"));
  }
  else if(sensorval == LOW){
   mySender.send(rawDataOff,RAW_DATA_LEN,36);//Pass the buffer,length, optionally frequency
    Serial.println(F("AC Switched Off"));    
  }
  }
/* Cut and paste the output from "rawRecv.ino" below here. It will 
 * consist of a #define RAW_DATA_LEN statement and an array definition
 * beginning with "uint16_t rawData[RAW_DATA_LEN]= {…" and concludes
 * with "…,1000};"
 */
#define RAW_DATA_LEN 350
uint16_t rawDataOff[RAW_DATA_LEN]={
  2950, 366, 142, 1190, 446, 1110, 446, 1110, 
  446, 370, 450, 370, 494, 322, 494, 1062, 
  450, 370, 446, 378, 494, 1062, 446, 1110, 
  446, 370, 450, 1106, 450, 370, 446, 370, 
  494, 1062, 446, 1118, 446, 374, 446, 1110, 
  446, 1110, 446, 370, 446, 370, 450, 1106, 
  450, 370, 446, 378, 446, 1110, 446, 374, 
  446, 370, 446, 370, 446, 374, 446, 370, 
  446, 370, 446, 378, 446, 374, 446, 370, 
  446, 370, 446, 370, 450, 370, 446, 370, 
  446, 374, 446, 374, 450, 370, 446, 374, 
  442, 374, 446, 370, 446, 374, 442, 1110, 
  450, 370, 446, 378, 446, 1110, 446, 1110, 
  446, 370, 450, 370, 446, 370, 446, 374, 
  442, 374, 446, 378, 446, 370, 446, 1110, 
  450, 1106, 450, 370, 446, 370, 446, 370, 
  450, 370, 446, 378, 446, 370, 446, 370, 
  450, 370, 446, 370, 446, 374, 446, 370, 
  446, 1110, 446, 378, 446, 374, 446, 370, 
  446, 370, 446, 370, 450, 370, 446, 370, 
  446, 370, 450, 374, 450, 370, 446, 370, 
  446, 374, 446, 370, 446, 370, 446, 374, 
  446, 370, 446, 378, 446, 374, 442, 374, 
  446, 370, 446, 370, 446, 370, 450, 370, 
  446, 370, 446, 382, 442, 374, 446, 370, 
  446, 370, 446, 374, 446, 370, 446, 370, 
  446, 374, 446, 1114, 450, 370, 446, 1110, 
  446, 1110, 446, 1110, 450, 1106, 450, 1110, 
  446, 1110, 446, 1110, 422, 1000};  



#define RAW_DATA_LEN 350
uint16_t rawDataOn[RAW_DATA_LEN]={
 2950, 1694, 450, 1110, 446, 1110, 446, 370, 
 450, 370, 446, 370, 446, 1110, 446, 370, 
 450, 378, 446, 1110, 446, 1110, 446, 370, 
 450, 1106, 450, 370, 446, 370, 446, 1110, 
 450, 1114, 446, 370, 450, 1110, 446, 1110, 
 446, 370, 450, 370, 446, 1110, 446, 370, 
 446, 378, 446, 1110, 450, 370, 446, 370, 
 446, 370, 450, 370, 446, 370, 446, 374, 
 446, 378, 446, 370, 446, 370, 446, 374, 
 446, 370, 446, 370, 450, 370, 446, 370, 
 446, 378, 446, 370, 450, 370, 446, 1110, 
 446, 370, 450, 370, 446, 1110, 446, 370, 
 446, 378, 450, 1106, 450, 1106, 450, 370, 
 446, 370, 446, 374, 446, 370, 446, 370, 
 450, 374, 450, 370, 446, 1110, 446, 1110, 
 446, 370, 450, 370, 446, 370, 446, 374, 
 446, 378, 446, 370, 446, 370, 450, 370, 
 446, 370, 446, 370, 450, 370, 446, 1110, 
 446, 378, 446, 370, 450, 370, 446, 370, 
 446, 370, 450, 370, 446, 370, 446, 370, 
 450, 374, 450, 370, 446, 370, 450, 370, 
 446, 370, 446, 370, 450, 370, 446, 370, 
 446, 378, 446, 370, 450, 370, 446, 370, 
 446, 374, 446, 370, 446, 370, 446, 374, 
 446, 378, 446, 370, 446, 370, 450, 370, 
 446, 370, 446, 370, 450, 370, 446, 370, 
 446, 1118, 446, 370, 450, 1110, 446, 370, 
 446, 370, 446, 374, 446, 370, 446, 370, 
 450, 370, 418, 1000};

Arduino: 1.8.13 (Windows 10), Board: “Arduino Uno”

Error Message:

C:\Users\Eric\Desktop\ERIC OFFCIAL\AC Automation PROJECT\Programs\PIR_test\PIR_test.ino: In function ‘void loop()’:

PIR_test:36:7: error: request for member ‘read11’ in ‘DHT’, which is of non-class type ‘char’

DHT.read11(dht_apin);

^~~~~~

PIR_test:37:18: error: request for member ‘temperature’ in ‘DHT’, which is of non-class type ‘char’

int temp = DHT.temperature;

^~~~~~~~~~~

PIR_test:44:28: error: expected identifier before ‘if’

if (sensorval == HIGH)&& if (temp > 26 ) {

^~

PIR_test:48:33: error: expected identifier before ‘if’

else if (sensorval == HIGH)&& if (temp < 29 ) {

^~

PIR_test:53:18: error: ‘rawDataOff’ was not declared in this scope

mySender.send(rawDataOff,RAW_DATA_LEN,36);//Pass the buffer,length, optionally frequency

^~~~~~~~~~

PIR_test:53:29: error: ‘RAW_DATA_LEN’ was not declared in this scope

mySender.send(rawDataOff,RAW_DATA_LEN,36);//Pass the buffer,length, optionally frequency

^~~~~~~~~~~~

PIR_test:126:22: error: expected ‘}’ at end of input

450, 370, 418, 1000};

^

exit status 1

request for member ‘read11’ in ‘DHT’, which is of non-class type ‘char’

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

If someone could let me know how to rectify the error. It would be highly appreciated. Thanks!

char dht, DHT;

Couldn’t be much clearer

How do i correct it?

Might want to take a peek at the dht library example code.

void loop() {
  {
  Serial.begin(9600);
  delay(2000); 
  while (!Serial); //delay for Leonardo
  Serial.println("DHT11 Humidity & temperature Sensor\n\n");
  }
  
  {
  DHT.read11(dht_apin);
  int temp = DHT.temperature;
  Serial.prin

etc etc. This is a mess... Err.. This is formatted incorrectly.

-jim lee

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