ERROR In function 'void loop()':

Hi i am having the following errors when trying to compile my script.

Arduino: 1.6.5 (Windows 8.1), Board: “Arduino/Genuino Uno”

Weather_Station_Snow_Maker.ino: In function ‘void dht22()’:
Weather_Station_Snow_Maker:58: error: expected primary-expression before ‘.’ token
Weather_Station_Snow_Maker:63: error: expected primary-expression before ‘.’ token
Weather_Station_Snow_Maker:68: error: expected primary-expression before ‘.’ token
Weather_Station_Snow_Maker.ino: In function ‘void loop()’:
Weather_Station_Snow_Maker:88: error: expected primary-expression before ‘.’ token
Weather_Station_Snow_Maker:89: error: expected primary-expression before ‘.’ token
expected primary-expression before ‘.’ token

PLEASE HELP

const int critical = -3; //critcal plant freezing temp in degree C
const int ledblue = 10;
const int ledgreen = 12;
float wetbulb = 0;

#include <DHT.h>
#include <LiquidCrystal.h>
#define LUMIN 11          // the number of the PWM output pin
#define BUTTON 10         // the number of the pushbutton pin
#define DHT22_PIN 2 // what digital pin we're connected to
int  val = 0;           // variable for reading the pushbutton status
int counter = 0;


byte temp[8] =             //icon for thermometer
{
  B00100,
  B01011,
  B01010,
  B01111,
  B01110,
  B11111,
  B11111,
  B01110
};

byte drop[8] =             //icon for water droplet
{
  B00100,
  B00100,
  B01110,
  B01110,
  B11111,
  B11111,
  B11111,
  B01110,
};
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

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

#define DS3232_I2C_ADDRESS 0x68
#define DHT22_PIN 3


// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return ( (val / 16 * 10) + (val % 16) );
}

void dht22()
{
  // READ DATA
  int chk = DHT.read22(DHT22_PIN);
  // DISPLAY DATA
  lcd.setCursor(0, 1);         // Position the LCD cursor (col 0, row 1)
  lcd.write(1);            // Print the new character labeled 1
  lcd.print(" ");
  lcd.print(DHT.temperature, 1);       // Print a message to the lcd.
  lcd.print((char)223);
  lcd.print("C");
  lcd.write(2);            // Print the new character labeled 2
  lcd.print(" ");
  lcd.print(DHT.humidity, 1);
  lcd.print("%");
}


void setup() {
  Serial.begin(9600);
  Serial.println("DHT22 test!");
  pinMode(ledgreen, OUTPUT);
  pinMode (ledblue, OUTPUT);
  lcd.createChar(1, temp);       // create a new character labeled 1
  lcd.createChar(2, drop);      // create a new character labeled 2
  lcd.begin(16, 2);         // set up the LCD's number of columns and rows

}

void loop() {

  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = DHT.readHumidity();
  float t = DHT.readTemperature();

  wetbulb = (t * atan(.151977 * pow(h + 8.313659, 0.5))) + atan(t + h) - atan(h - 1.676331) + (.391838 * pow(h, 2 / 3)) * atan(.023101 * h) - 4.686035;
  if (wetbulb <= critical) {
    digitalWrite (ledgreen, HIGH);
  }  //wetbulb below critical trips led
  if (wetbulb >= critical) {
    digitalWrite (ledblue, HIGH);
  }
  if (wetbulb <= critical) {
    digitalWrite (ledblue, LOW);
  }
  if (wetbulb >= critical + 3) {
    digitalWrite (ledblue, LOW);
  }\
  if (wetbulb >= critical) {
    digitalWrite (ledgreen, LOW);
  }


  // check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t) || isnan(h)) {
    Serial.println("Failed to read from DHT");
  } else {
    Serial.print("Humidity: ");
    Serial.print(h);
    Serial.print(" %\t");
    Serial.print("Temperature: ");
    Serial.print(" ");
    Serial.print(t);
    Serial.println(" *C");
    Serial.print(" ");

    Serial.print("Wetbulb");
    Serial.print(" ");
    Serial.print(wetbulb);
    Serial.print("*C");
    Serial.print(" ");
    Serial.print("Freeze");
    Serial.print(" ");
    Serial.print(critical);
    Serial.print("*C");
    Serial.print(" ");

    lcd.setCursor (0, 0);
    lcd.print("Wetbulb");
    lcd.print(" ");
    lcd.print(wetbulb);
    lcd.print((char)223); // Prints degrees symbol
    lcd.print("C");

    dht22();

    delay (2000);


  }
}

Weather_Station_Snow_Maker.ino (3.37 KB)

}
  if (wetbulb >= critical + 3) {
    digitalWrite (ledblue, LOW);
  }\

That backwards slash is likely to cause problems.

DuaneDegn: }   if (wetbulb >= critical + 3) {     digitalWrite (ledblue, LOW);   }\

That backwards slash is likely to cause problems.

i just removed that backwards slash still the same errors as before but thats for pointing that out to me. it makes it look a lot more cleaner.

.151977

Can't do that. You gotta have the zero in front of it.

0.151977

From this line:

wetbulb = (t * atan(.151977 * pow(h + 8.313659, 0.5))) + atan(t + h) - atan(h - 1.676331) + (.391838 * pow(h, 2 / 3)) * atan(.023101 * h) - 4.686035;

You haven't instantiated DHT. It is complaining about your use of DHT.read22 etc.

Pete

byte drop[8] =             //icon for water droplet
{
  B00100,
  B00100,
  B01110,
  B01110,
  B11111,
  B11111,
  B11111,
  B01110,
};

I’m betting the last comma isn’t supposed to be there.

el_supremo: You haven't instantiated DHT. It is complaining about your use of DHT.read22 etc.

Pete

thanks pete that might be it but how do i do that

#define DHT22_PIN 3
DHT dht(DHT22_PIN, DHT22);

Pete P.S. .151977 is valid. You don't have to have a leading zero.

thanks pete tried that it still did not change any of the errors. all the same errors still exist

Did you see reply #3? Those need to be fixed.

Delta_G: Did you see reply #3? Those need to be fixed.

no they dont need to be fixed there is nothing wrong with them. they were working before i stated writing in the the new temp and humidity code

Ooops. the dht needs to be upper case:

DHT DHT(DHT22_PIN, DHT22);

and two other problems. When you get temperature and humidity from the DHT22 you need to use readTemperature() and readHumidity(). And I don't know what you intended with DHT.read22 but there's no such function in DHT22. Change the dht22 function to this:

void dht22()
{
  // DISPLAY DATA
  lcd.setCursor(0, 1);         // Position the LCD cursor (col 0, row 1)
  lcd.write(1);            // Print the new character labeled 1
  lcd.print(" ");
  lcd.print(DHT.readTemperature(), 1);       // Print a message to the lcd.
  lcd.print((char)223);
  lcd.print("C");
  lcd.write(2);            // Print the new character labeled 2
  lcd.print(" ");
  lcd.print(DHT.readHumidity(), 1);
  lcd.print("%");
}

Pete