error expected primary expression before ',' token

#include <LiquidCrystal_I2C.h>

#include <LiquidCrystal.h>

#include <DHT11.h>

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

#define DHT11PIN 2

#define DHTTYPE DHT11

#define ENABLE 3
#define DIRA 4
#define DIRB 5

LiquidCrystal lcd( 7, 8, 9, 10, 11, 12);

byte arms[8] = {
0b00100,
0b01010,
0b00100,
0b00100,
0b01110,
0b10101,
0b00100,
0b01010
};

void setup()
{
Serial.begin(9600);
Wire.begin();
lcd.begin(16,2);
lcd.createChar(1, arms);
pinMode(ENABLE,OUTPUT);
pinMode(DIRA,OUTPUT);
pinMode(DIRB,OUTPUT);

}

void loop()
{
int chk = DHT11.read(DHT11PIN);
int Tep = (float)DHT11.temperature;
lcd.setCursor(0, 0);
lcd.print("Hum: ");
lcd.print((float)DHT11.humidity,0);
lcd.print("%");
lcd.setCursor(0, 1); //Move the cursor to line 2
lcd.print("Tep: ");
lcd.print((float)DHT11.temperature-3,0);
lcd.write(0xdf); // Display temperature unit
lcd.print("C");

if(((float)DHT11.temperature)>26&&((float)DHT11.temperature)<28) // the problem start here it has to do with DHT11
{
lcd.setCursor(10, 1);
lcd.print(" ON ");
lcd.write(1);
analogWrite(ENABLE,170); // enable on
digitalWrite(DIRA,HIGH); //one way
digitalWrite(DIRB,LOW);
delay(10);
digitalWrite(DIRA,LOW); //reverse
digitalWrite(DIRB,HIGH);
delay(10);
lcd.setCursor(10, 0);
lcd.print("FAN");
lcd.setCursor(14, 0);
lcd.print("1");
delay(1000);
}

if(Tep>=28&&Tep<30)
{
lcd.setCursor(10, 1);
lcd.print(" ON ");
lcd.write(1);
analogWrite(ENABLE,210); // enable on
digitalWrite(DIRA,HIGH); //one way
digitalWrite(DIRB,LOW);
delay(10);
digitalWrite(DIRA,LOW); //reverse
digitalWrite(DIRB,HIGH);
delay(10);
lcd.setCursor(10, 0);
lcd.print("FAN");
lcd.setCursor(14, 0);
lcd.print("2");
delay(1000);
}

if(Tep>=30)
{
lcd.setCursor(10, 1);
lcd.print(" ON ");
lcd.write(1);
analogWrite(ENABLE,255); // enable on
digitalWrite(DIRA,HIGH); //one way
digitalWrite(DIRB,LOW);
delay(10);
digitalWrite(DIRA,LOW); //reverse
digitalWrite(DIRB,HIGH);
delay(10);
lcd.setCursor(10, 0);
lcd.print("FAN");
lcd.setCursor(14, 0);
lcd.print("3");
delay(1000);
}
if(Tep<=26)
{
lcd.setCursor(10, 1);
lcd.print("OFF ");
digitalWrite(ENABLE,LOW); // enable on
digitalWrite(DIRA,HIGH); //one way
digitalWrite(DIRB,LOW);
delay(10);
digitalWrite(DIRA,LOW); //reverse
digitalWrite(DIRB,HIGH);
delay(10);
lcd.setCursor(10, 0);
lcd.print("FAN");
lcd.setCursor(14, 0);
lcd.print(" ");
delay(1000);
}
}

I am not good in programming just starter so I do not know what is the problem near the if function

Use CTRL T to format your code.
Attach your ‘complete’ sketch between code tags, use the </> icon in the posting menu.
[code]Paste your sketch here[/code]

What was the complete error ?

the error is (expected primary expression before ',' token) near the if function and it has to do with the DHT11 in the function I have posted the whole code, also stated

if(((float)DHT11.temperature)>26&&((float)DHT11.temperature)<28)

error: expected primary-expression before '.' token

Please post the full, actual error messages copied from the IDE, maybe using the cunningly named "Copy error messages" button

Arduino: 1.8.12 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Arduino\Temperature+fan\temperature_fan2\temperature_fan2\temperature_fan2.ino: In function 'void loop()':

temperature_fan2:48:20: error: expected primary-expression before '.' token

int chk = DHT11.read(DHT11PIN);

^

temperature_fan2:49:27: error: expected primary-expression before '.' token

int Tep = (float)DHT11.temperature;

^

temperature_fan2:52:27: error: expected primary-expression before '.' token

lcd.print((float)DHT11.humidity,0);

^

temperature_fan2:56:27: error: expected primary-expression before '.' token

lcd.print((float)DHT11.temperature-3,0);

^

temperature_fan2:60:21: error: expected primary-expression before '.' token

if(((float)DHT11.temperature)>26&&((float)DHT11.temperature)<28)

^

temperature_fan2:60:52: error: expected primary-expression before '.' token

if(((float)DHT11.temperature)>26&&((float)DHT11.temperature)<28)

^

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

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

Clean these up so there are no duplicates
#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal.h>
#include <DHT11.h>

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

decide on which LiquidCrystal library and DHT/dht11 library you are using, and make sure they are in the right folder, such as
Windows/Arduino1.8.5/libraries
so when you select Sketch:Include Library: you can see them in the list.
Restart the IDE after you move any.

You don't appear to have an instance of the class.

Check the library examples

I did what you said the same error still there I will post it again.

Arduino: 1.8.12 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Arduino\Temperature+fan\temperature_fan2\temperature_fan2\temperature_fan2.ino: In function 'void loop()':

temperature_fan2:45:20: error: expected primary-expression before '.' token

int chk = DHT11.read(DHT11PIN);

^

temperature_fan2:46:27: error: expected primary-expression before '.' token

int Tep = (float)DHT11.temperature;

^

temperature_fan2:49:27: error: expected primary-expression before '.' token

lcd.print((float)DHT11.humidity,0);

^

temperature_fan2:53:27: error: expected primary-expression before '.' token

lcd.print((float)DHT11.temperature-3,0);

^

temperature_fan2:57:21: error: expected primary-expression before '.' token

if(((float)DHT11.temperature)>26&&((float)DHT11.temperature)<28)

^

temperature_fan2:57:52: error: expected primary-expression before '.' token

if(((float)DHT11.temperature)>26&&((float)DHT11.temperature)<28)

^

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

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

the whole code is below so I do not know if the problem with the class DHT11:

#include <LiquidCrystal_I2C.h>

#include <DHT11.h>

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

#define DHT11PIN 2

#define DHTTYPE DHT11

#define ENABLE 3
#define DIRA 4
#define DIRB 5

LiquidCrystal lcd( 7, 8, 9, 10, 11, 12);

byte arms[8] = {
0b00100,
0b01010,
0b00100,
0b00100,
0b01110,
0b10101,
0b00100,
0b01010
};

void setup()
{
Serial.begin(9600);
Wire.begin();
lcd.begin(16,2);
lcd.createChar(1, arms);
pinMode(ENABLE,OUTPUT);
pinMode(DIRA,OUTPUT);
pinMode(DIRB,OUTPUT);

}

void loop()
{
int chk = DHT11.read(DHT11PIN);
int Tep = (float)DHT11.temperature;
lcd.setCursor(0, 0);
lcd.print("Hum: ");
lcd.print((float)DHT11.humidity,0);
lcd.print("%");
lcd.setCursor(0, 1); //Move the cursor to line 2
lcd.print("Tep: ");
lcd.print((float)DHT11.temperature-3,0);
lcd.write(0xdf); // Display temperature unit
lcd.print("C");

if(((float)DHT11.temperature)>26&&((float)DHT11.temperature)<28)
{
lcd.setCursor(10, 1);
lcd.print(" ON ");
lcd.write(1);
analogWrite(ENABLE,170); // enable on
digitalWrite(DIRA,HIGH); //one way
digitalWrite(DIRB,LOW);
delay(10);
digitalWrite(DIRA,LOW); //reverse
digitalWrite(DIRB,HIGH);
delay(10);
lcd.setCursor(10, 0);
lcd.print("FAN");
lcd.setCursor(14, 0);
lcd.print("1");
delay(1000);
}

if(Tep>=28&&Tep<30)
{
lcd.setCursor(10, 1);
lcd.print(" ON ");
lcd.write(1);
analogWrite(ENABLE,210); // enable on
digitalWrite(DIRA,HIGH); //one way
digitalWrite(DIRB,LOW);
delay(10);
digitalWrite(DIRA,LOW); //reverse
digitalWrite(DIRB,HIGH);
delay(10);
lcd.setCursor(10, 0);
lcd.print("FAN");
lcd.setCursor(14, 0);
lcd.print("2");
delay(1000);
}

if(Tep>=30)
{
lcd.setCursor(10, 1);
lcd.print(" ON ");
lcd.write(1);
analogWrite(ENABLE,255); // enable on
digitalWrite(DIRA,HIGH); //one way
digitalWrite(DIRB,LOW);
delay(10);
digitalWrite(DIRA,LOW); //reverse
digitalWrite(DIRB,HIGH);
delay(10);
lcd.setCursor(10, 0);
lcd.print("FAN");
lcd.setCursor(14, 0);
lcd.print("3");
delay(1000);
}
if(Tep<=26)
{
lcd.setCursor(10, 1);
lcd.print("OFF ");
digitalWrite(ENABLE,LOW); // enable on
digitalWrite(DIRA,HIGH); //one way
digitalWrite(DIRB,LOW);
delay(10);
digitalWrite(DIRA,LOW); //reverse
digitalWrite(DIRB,HIGH);
delay(10);
lcd.setCursor(10, 0);
lcd.print("FAN");
lcd.setCursor(14, 0);
lcd.print(" ");
delay(1000);
}
}

Have you looked at the example code provided with the library?

Have you considered using code tags?

@shawkat123 before you do anything else, read this: Read this before posting a programming question ....

As the title says, you should have done so BEFORE posting here. Pay particular attention to Item #6 that describes how to properly post your code using CODE TAGS. After you finish reading that entire thread, come back here and post your code again, this time with code tags.

Didn't I just clean this same post up in the French forum too?

It sure looks like you don't have the DHT11 library in the correct folder.

HI, I have read the example libraries for dht11 and liquid crystal it is not the same code as the one I am using, also I put tags still the error, also this global moderator instead of using insulting words like noob which I think you are, give advice politely, I have put the code again here with the tags and still the same error:

#include "LiquidCrystal_I2C.h"

#include "DHT11.h"

#include "Wire.h"
#include "LiquidCrystal.h"
#include "dht11.h"

#define DHT11PIN 2

#define DHTTYPE DHT11

#define ENABLE 3
#define DIRA 4
#define DIRB 5

LiquidCrystal lcd( 7, 8, 9, 10, 11, 12);

byte arms[8] = {
0b00100,
0b01010,
0b00100,
0b00100,
0b01110,
0b10101,
0b00100,
0b01010
};

void setup()
{
Serial.begin(9600);
Wire.begin();
lcd.begin(16,2);
lcd.createChar(1, arms);
pinMode(ENABLE,OUTPUT);
pinMode(DIRA,OUTPUT);
pinMode(DIRB,OUTPUT);

}

void loop()
{
int chk = DHT11.read(DHT11PIN);
int Tep = (float)DHT11.temperature;
lcd.setCursor(0, 0);
lcd.print("Hum: ");
lcd.print((float)DHT11.humidity,0);
lcd.print("%");
lcd.setCursor(0, 1); //Move the cursor to line 2
lcd.print("Tep: ");
lcd.print((float)DHT11.temperature-3,0);
lcd.write(0xdf); // Display temperature unit
lcd.print("C");

if(((float)DHT11.temperature)>26&&((float)DHT11.temperature)<28)
{
lcd.setCursor(10, 1);
lcd.print(" ON ");
lcd.write(1);
analogWrite(ENABLE,170); // enable on
digitalWrite(DIRA,HIGH); //one way
digitalWrite(DIRB,LOW);
delay(10);
digitalWrite(DIRA,LOW); //reverse
digitalWrite(DIRB,HIGH);
delay(10);
lcd.setCursor(10, 0);
lcd.print("FAN");
lcd.setCursor(14, 0);
lcd.print("1");
delay(1000);
}

if(Tep>=28&&Tep<30)
{
lcd.setCursor(10, 1);
lcd.print(" ON ");
lcd.write(1);
analogWrite(ENABLE,210); // enable on
digitalWrite(DIRA,HIGH); //one way
digitalWrite(DIRB,LOW);
delay(10);
digitalWrite(DIRA,LOW); //reverse
digitalWrite(DIRB,HIGH);
delay(10);
lcd.setCursor(10, 0);
lcd.print("FAN");
lcd.setCursor(14, 0);
lcd.print("2");
delay(1000);
}

if(Tep>=30)
{
lcd.setCursor(10, 1);
lcd.print(" ON ");
lcd.write(1);
analogWrite(ENABLE,255); // enable on
digitalWrite(DIRA,HIGH); //one way
digitalWrite(DIRB,LOW);
delay(10);
digitalWrite(DIRA,LOW); //reverse
digitalWrite(DIRB,HIGH);
delay(10);
lcd.setCursor(10, 0);
lcd.print("FAN");
lcd.setCursor(14, 0);
lcd.print("3");
delay(1000);
}
if(Tep<=26)
{
lcd.setCursor(10, 1);
lcd.print("OFF ");
digitalWrite(ENABLE,LOW); // enable on
digitalWrite(DIRA,HIGH); //one way
digitalWrite(DIRB,LOW);
delay(10);
digitalWrite(DIRA,LOW); //reverse
digitalWrite(DIRB,HIGH);
delay(10);
lcd.setCursor(10, 0);
lcd.print("FAN");
lcd.setCursor(14, 0);
lcd.print(" ");
delay(1000);
}
}

the error code:

Arduino: 1.8.12 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Arduino\Temperature+fan\temperature_fan2\temperature_fan2\temperature_fan2.ino: In function 'void loop()':

temperature_fan2:45:20: error: expected primary-expression before '.' token

int chk = DHT11.read(DHT11PIN);

^

temperature_fan2:46:27: error: expected primary-expression before '.' token

int Tep = (float)DHT11.temperature;

^

temperature_fan2:49:27: error: expected primary-expression before '.' token

lcd.print((float)DHT11.humidity,0);

^

temperature_fan2:53:27: error: expected primary-expression before '.' token

lcd.print((float)DHT11.temperature-3,0);

^

temperature_fan2:57:21: error: expected primary-expression before '.' token

if(((float)DHT11.temperature)>26&&((float)DHT11.temperature)<28)

^

temperature_fan2:57:52: error: expected primary-expression before '.' token

if(((float)DHT11.temperature)>26&&((float)DHT11.temperature)<28)

^

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

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

Reply #10

I have put the code again here with the tags

You did not use code tags as far as I can see

Here is your code Auto formatted in the IDE to tidy up the layout and posted here in code tags

#include "LiquidCrystal_I2C.h"

#include "DHT11.h"

#include "Wire.h"
#include "LiquidCrystal.h"
#include "dht11.h"

#define DHT11PIN 2

#define DHTTYPE DHT11


#define ENABLE 3
#define DIRA 4
#define DIRB 5

LiquidCrystal lcd( 7, 8, 9, 10, 11, 12);

byte arms[8] =
{
  0b00100,
  0b01010,
  0b00100,
  0b00100,
  0b01110,
  0b10101,
  0b00100,
  0b01010
};

void setup()
{
  Serial.begin(9600);
  Wire.begin();
  lcd.begin(16, 2);
  lcd.createChar(1, arms);
  pinMode(ENABLE, OUTPUT);
  pinMode(DIRA, OUTPUT);
  pinMode(DIRB, OUTPUT);
}

void loop()
{
  int chk = DHT11.read(DHT11PIN);
  int Tep = (float)DHT11.temperature;
  lcd.setCursor(0, 0);
  lcd.print("Hum: ");
  lcd.print((float)DHT11.humidity, 0);
  lcd.print("%");
  lcd.setCursor(0, 1); //Move the cursor to line 2
  lcd.print("Tep: ");
  lcd.print((float)DHT11.temperature - 3, 0);
  lcd.write(0xdf);  // Display temperature unit
  lcd.print("C");
  if (((float)DHT11.temperature) > 26 && ((float)DHT11.temperature) < 28)
  {
    lcd.setCursor(10, 1);
    lcd.print(" ON ");
    lcd.write(1);
    analogWrite(ENABLE, 170); // enable on
    digitalWrite(DIRA, HIGH); //one way
    digitalWrite(DIRB, LOW);
    delay(10);
    digitalWrite(DIRA, LOW); //reverse
    digitalWrite(DIRB, HIGH);
    delay(10);
    lcd.setCursor(10, 0);
    lcd.print("FAN");
    lcd.setCursor(14, 0);
    lcd.print("1");
    delay(1000);
  }
  if (Tep >= 28 && Tep < 30)
  {
    lcd.setCursor(10, 1);
    lcd.print(" ON ");
    lcd.write(1);
    analogWrite(ENABLE, 210); // enable on
    digitalWrite(DIRA, HIGH); //one way
    digitalWrite(DIRB, LOW);
    delay(10);
    digitalWrite(DIRA, LOW); //reverse
    digitalWrite(DIRB, HIGH);
    delay(10);
    lcd.setCursor(10, 0);
    lcd.print("FAN");
    lcd.setCursor(14, 0);
    lcd.print("2");
    delay(1000);
  }
  if (Tep >= 30)
  {
    lcd.setCursor(10, 1);
    lcd.print(" ON ");
    lcd.write(1);
    analogWrite(ENABLE, 255); // enable on
    digitalWrite(DIRA, HIGH); //one way
    digitalWrite(DIRB, LOW);
    delay(10);
    digitalWrite(DIRA, LOW); //reverse
    digitalWrite(DIRB, HIGH);
    delay(10);
    lcd.setCursor(10, 0);
    lcd.print("FAN");
    lcd.setCursor(14, 0);
    lcd.print("3");
    delay(1000);
  }
  if (Tep <= 26)
  {
    lcd.setCursor(10, 1);
    lcd.print("OFF        ");
    digitalWrite(ENABLE, LOW); // enable on
    digitalWrite(DIRA, HIGH); //one way
    digitalWrite(DIRB, LOW);
    delay(10);
    digitalWrite(DIRA, LOW); //reverse
    digitalWrite(DIRB, HIGH);
    delay(10);
    lcd.setCursor(10, 0);
    lcd.print("FAN");
    lcd.setCursor(14, 0);
    lcd.print("                  ");
    delay(1000);
  }
}

Hi UKHeliBob,

thank you very much for that I did the same with my code, but still the same error is there I do not know where is the problem.

Using code tags will not solve your problem. They are simply a method of posting code to the forum in a way that males it easy to see and manage and to prevent any of it being interpreted as HTML commands and messing with the text of the code

As to the error, where in the sketch do you create the DH11 object and why are you trying to use 2 libraries for the sensor, one name DHT11.h and the other dht11.h ?

I have committed the library dht11.h with // still does not make a difference, the library in the sketch location is DHT11, even if I want to create another folder dht11, it still become capital letters DHT11, anyway it does not resolve the problem, now only include DHT.h in the code, but still the same problem.

I note that all of the errors relate to an object named DHT11

where in the sketch do you create the DH11 object

Are there any examples with the library ?