Trouble with Arduino code

Hello,
I am having an error with this code, can anyone help me?

int LEDTEMP = 42;      // High temp at which the LED turns on
int ALARMTEMP = 42;   // Overheating temp
int LED = 53;        // Pin for LED "on"
int TEMPOK = 52;        // LED for when temp is under LEDTEMP
int ALARMLED = 51;      // Alarm LED
int ALARMPIN = 50;      // Audible alarm for overheating
int DHTPIN = 8;       // (defined below)
int HeaterPIN = 24;        // Relay for heater
int HumidityPIN = 40;     // Humidity PIN
int Humidity = 48;    // Humidity level

#include <Wire.h>
#include "ClosedCube_HDC1080.h"
#include <Stepper.h>
#include <LiquidCrystal.h>
ClosedCube_HDC1080 hdc1080;
// For Temp

// Readings used for average
const int numReadings = 10;

// For Turner
const int stepsPerRevolution = 32;

// initialize the stepper library on pins 14 through 17:
Stepper myStepper(stepsPerRevolution, 14, 15, 16, 17);


// Set variables to zero
float avetemp = 0;               
float temp = 0;
float checkdelay = 0;

// For Humidity

// Set variables to zero
float aveHumid = 0;               
float Humid = 0;

void setup() {

  // For Turner

  myStepper.setSpeed(1000);



  pinMode(24, OUTPUT);// connected to S terminal of Relay
  Serial.begin(9600);
  Serial.println("Temp Monitor Started");

hdc1080.begin(0x40);
 
  pinMode(HeaterPIN,OUTPUT);
  pinMode(ALARMPIN,OUTPUT);
  pinMode(ALARMLED,OUTPUT);
  pinMode(LED,OUTPUT);
  pinMode(TEMPOK,OUTPUT);
  pinMode(HumidityPIN,OUTPUT);

  digitalWrite(HeaterPIN, LOW);
  digitalWrite(LED, LOW);
  digitalWrite(ALARMLED, LOW);
  digitalWrite(TEMPOK, HIGH);
    for(int x = 0; x < 5; x++){   // Test Alarm
        noTone(ALARMPIN);
        delay(100);                 
       }
   Serial.print("LED Test Started (5 Seconds) ");
    for(int x = 0; x < 5; x++){
     Serial.print(".");
     delay(1000);
    }
    Serial.println("Done");
  digitalWrite(HeaterPIN, HIGH);
  digitalWrite(LED, HIGH);
  digitalWrite(ALARMLED, HIGH);
  digitalWrite(TEMPOK, LOW);
  noTone(ALARMPIN);


//For Humidity
digitalWrite(HumidityPIN, HIGH);
digitalWrite(HumidityPIN, LOW);

  Serial.print("Realtime Temp: \t");
}
void loop() {
// For Turner

myStepper.step(stepsPerRevolution);
delay(86400);// full day change to: 86400

 
// Wait a few seconds between measurements.
  delay(100);
  temp = 0;

    Serial.print("Realtime Temp: \t");

  for (int x = 0; x < numReadings; x++){
    float c = hdc1080.readTemperature(false);   //This line is where the error is!
    Serial.print(c);
    Serial.print("\t");
    temp = c + temp;
    delay(1000); // delay in between reads for stability 
  }   
  Serial.println();
 
  avetemp = temp / numReadings;                    // calculate the average
  Serial.print("Average Temp is ");
  Serial.println(avetemp);                         // send it to the computer as ASCII digits

     // Check if any reads failed and exit early (to try again).
  if (isnan(temp)) {
    Serial.println("Failed to read from HDC1080 sensor!");
    return;
  }

  // Set off alarm if overheating 
    if (avetemp>ALARMTEMP) {
      digitalWrite(ALARMLED, HIGH);
      Serial.print("Temperature is over ");
      Serial.print(ALARMTEMP);
      Serial.println(", Alarm is ON");
       for(int x = 0; x < 3; x++){                  // Sound the alarm for 5 seconds
        noTone(ALARMPIN);                  // Fan should already be running from last loop, if not, it will start right after alarm sounds
        delay(500);
        noTone(ALARMPIN);
        delay(500);
        }
     noTone(ALARMPIN);
     checkdelay = 5000;                            // Switch the normal 5 min delay to 30 seconds before going through the loop again
   } else {
    digitalWrite(ALARMLED, LOW);
    Serial.print("Temperature is under ");
    Serial.print(ALARMTEMP);
    Serial.println(", Alarm is OFF");
    checkdelay = 5000;                            // Unless temp is over 120*F the fan runs for 5 minutes before temp is checked again
  }

// Turn ON Heater if cabinet is COLD
  if (avetemp>LEDTEMP) {
    digitalWrite(HeaterPIN, HIGH);
    digitalWrite(LED, HIGH);
    digitalWrite(TEMPOK, LOW);
    Serial.print("Temperature is over ");
    Serial.print(LEDTEMP);
    Serial.print(", Heater is OFF (for ");
    Serial.print(checkdelay / 1000 / 60);
    Serial.println(" minutes)");
    delay(checkdelay);    // turn on minimum of 5 min (unless alarm is going off, then it loops after 30 seconds)
  } else {
    digitalWrite(HeaterPIN, LOW);
    digitalWrite(LED, LOW);
    digitalWrite(TEMPOK, HIGH);
    Serial.print("Temperature is under ");
    Serial.print(LEDTEMP);
    Serial.println(", Heater is ON");                   // When fan is off, Temp is read every 30 seconds
  }
   
  Serial.println();
  Serial.println();



//Humidity



  if (aveHumid>Humidity) {
    digitalWrite(HumidityPIN, HIGH);
    digitalWrite(Humidity, HIGH);
  } else {
    digitalWrite(HumidityPIN, LOW);
    digitalWrite(Humidity, LOW);

  }




// LCD module connections (RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

char temperature[] = "Temp = 00.0 C";
char humidity[]    = "RH   = 00.0 %";

  // set up the LCD's number of columns and rows
  lcd.begin(16, 2);

delay(1);           // wait 1s between readings
  // Read humidity
  byte RH = hdc1080.readHumidity();
  //Read temperature in degree Celsius
  byte Temp = hdc1080.readTemperature();
 
  // Check if any reads failed and exit early (to try again)
  if (isnan(RH) || isnan(Temp)) {
    lcd.clear();
    lcd.setCursor(5, 0);
    lcd.print("Error");
    return;
  }

  temperature[7]     = Temp / 10 + 48;
  temperature[8]     = Temp % 10 + 48;
  temperature[11]    = 223;
  humidity[7]        = RH / 10 + 48;
  humidity[8]        = RH % 10 + 48;
  lcd.setCursor(0, 0);
  lcd.print("Temp = ");
  lcd.setCursor(8, 0);
  lcd.print(Temp);
  lcd.setCursor(10, 0);
  lcd.print("C");
 
  lcd.setCursor(0, 1);
  lcd.print("Hum  = ");
  lcd.setCursor(8, 1);
  lcd.print(RH);
  lcd.setCursor(10, 1);
  lcd.print("%");

}

Thanks

Might be an idea to tell the forum what the error with the code is ?

The error code is:

Arduino: 1.9.0-beta (Mac OS X), Board: "Arduino Uno"

...sketch_may10b/sketch_may10b.ino: In function 'void loop()':
sketch_may10b:102:44: error: no matching function for call to 'ClosedCube_HDC1080::readTemperature(bool)'
     float c = hdc1080.readTemperature(false);
                                            ^
In file included from .../sketch_may10b/sketch_may10b.ino:13:0:
...Arduino/libraries/ClosedCube_HDC1080/src/ClosedCube_HDC1080.h:92:9: note: candidate: double ClosedCube_HDC1080::readTemperature()
  double readTemperature();
         ^~~~~~~~~~~~~~~
.../Arduino/libraries/ClosedCube_HDC1080/src/ClosedCube_HDC1080.h:92:9: note:   candidate expects 0 arguments, 1 provided
exit status 1
no matching function for call to 'ClosedCube_HDC1080::readTemperature(bool)'

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

Thanks

Remove the word false inside the brackets

Hello,
the declared pin numbers don´t match to a.m. Arduino board.

Hello,
I am using an Arduino Mega, not an Arduino UNO.
Thanks for the help.

Hello,
When I remove the word “false” from in there the code compiles fine.
But, then for some reason when the 5 second countdown starts it puts “???” question marks instead of “…” fullstops.
Might you know why this is?
Thanks

Hello,
Sorry, I have just seen that I have put this in the wrong category.
Thanks

What do you have the speed of the serial monitor set to?

I have it set to: 9600

Can you help me?

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("Hello World!");
}
void loop() {
  // put your main code here, to run repeatedly:
}

Get the serial monitor code above working first before dealing with your code.

@Hike, your topic has been moved to a more appropriate section of the forum.

Thanks,
I do not actually need the serial monitor, as long as the lcd displays the temperature and humidity.
Thanks again.

Hi,
Did you write this code?
What is it supposed to do?

Can you please tell us your electronics, programming, arduino, hardware experience?

If you wrote this code, did you write it in stages and make sure each stage works before writing code for the next stage?

Tom.... :grinning: :+1: :coffee: :australia:

Hello,
I did write this code, I wrote it in a few hours, not in stages.
It is for an incubator. I have the stepper turning the eggs, the heater warming the box, the pin 40 is for a heating element to go in the water to make the humidity, and the sensor reading the temp and humidity to control the humidity and temperature.
I am planning on using the HDC2080 sensor instead.
Thanks for the help!

Hi,

Where did you get this library from?
For us to try your code we need to know where to get your version.

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

Hello,
Thank you so much for helping me.
I got the library from the Manage Librarys on the Arduino IDE.
Please note: I am sorry for the mess up, but I have just found that the HDC2080 is far better, so I will be using the HDC2080 sensor. Sorry again.
And thank you very much.
I may need help with the code for the HDC2080 sensor, if I do, I will ask you and post the code and any error messages.
Thanks,
Hike

New code works!
Except, I do not have the sensor yet, so cannot fully test.
Can any of you just read the below code and tell me if you see any problems?
I got all the librarys from the Manage Librarys section on the Arduino IDE Program (Beta on Mac).
Thanks

int LEDTEMP = 42;      // High temp at which the LED turns on
int ALARMTEMP = 42;   // Overheating temp
int LED = 53;        // Pin for LED "on"
int TEMPOK = 52;        // LED for when temp is under LEDTEMP
int ALARMLED = 51;      // Alarm LED
int ALARMPIN = 50;      // Audible alarm for overheating
int HeaterPIN = 0;        // Relay for heater
int HumidityPIN = 1;     // Humidity PIN
int Humidity = 48;    // Humidity level

#include <Servo.h>
#include <Wire.h>
#include <HDC2080.h>
#include <LiquidCrystal.h>
// For Turner
Servo myservo;
int pos = 0;


#define ADDR 0x40
HDC2080 sensor(ADDR);

// For Temp

// Readings used for average
const int numReadings = 10;


// Set variables to zero
float avetemp = 0;               
float temp = 0;
float checkdelay = 0;

// For Humidity

// Set variables to zero
float aveHumid = 0;               
float Humid = 0;

float temperature = 0, humidity = 0;

void setup() {
// For turner
myservo.attach(13);

// For Heater
  pinMode(24, OUTPUT);// connected to S terminal of Relay
  Serial.begin(9600);
  Serial.println("Temp Monitor Started");

  sensor.begin();
  sensor.reset();
  // Configure Measurements
  sensor.setMeasurementMode(TEMP_AND_HUMID);  // Set measurements to temperature and humidity
  sensor.setRate(ONE_HZ);                     // Set measurement frequency to 1 Hz
  sensor.setTempRes(FOURTEEN_BIT);
  sensor.setHumidRes(FOURTEEN_BIT);
  //begin measuring
  sensor.triggerMeasurement();
 
  pinMode(HeaterPIN,OUTPUT);
  pinMode(ALARMPIN,OUTPUT);
  pinMode(ALARMLED,OUTPUT);
  pinMode(LED,OUTPUT);
  pinMode(TEMPOK,OUTPUT);
  pinMode(HumidityPIN,OUTPUT);

  digitalWrite(HeaterPIN, LOW);
  digitalWrite(LED, LOW);
  digitalWrite(ALARMLED, LOW);
  digitalWrite(TEMPOK, HIGH);
    for(int x = 0; x < 5; x++){   // Test Alarm
        noTone(ALARMPIN);
        delay(100);                 
       }
   Serial.print("LED Test Started (5 Seconds) ");
    for(int x = 0; x < 5; x++){
     Serial.print(".");
     delay(1000);
    }
    Serial.println("Done");
  digitalWrite(HeaterPIN, HIGH);
  digitalWrite(LED, HIGH);
  digitalWrite(ALARMLED, HIGH);
  digitalWrite(TEMPOK, LOW);
  noTone(ALARMPIN);


//For Humidity
digitalWrite(HumidityPIN, HIGH);
digitalWrite(HumidityPIN, LOW);

  Serial.print("Realtime Temp: \t");
}
void loop() {
// For Turner
for (pos = 0; pos <= 80; pos += 1) { // goes from 0 degrees to 80 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(5000);                       // waits 5000ms for the servo to reach the position
    delay(12133333);
  }
  for (pos = 80; pos >= 0; pos -= 1) { // goes from 80 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(5000);                       // waits 5000ms for the servo to reach the position
    delay(12133333);


 
// Wait a few seconds between measurements.
  delay(100);
  temp = 0;

    Serial.print("Realtime Temp: \t");

  for (int x = 0; x < numReadings; x++){
    Serial.print("Temperature(C): "); Serial.print(sensor.readTemp());
    Serial.print("\t");
    delay(1000); // delay in between reads for stability 
  }   
  Serial.println();
 
  avetemp = temp / numReadings;                    // calculate the average
  Serial.print("Average Temp is ");
  Serial.println(avetemp);                         // send it to the computer as ASCII digits

     // Check if any reads failed and exit early (to try again).
  if (isnan(temp)) {
    Serial.println("Failed to read from HDC2080 sensor!");//ln
    return;
  }

  // Set off alarm if overheating 
    if (avetemp>ALARMTEMP) {
      digitalWrite(ALARMLED, HIGH);
      Serial.print("Temperature is over ");
      Serial.print(ALARMTEMP);
      Serial.println(", Alarm is ON");
       for(int x = 0; x < 3; x++){                  // Sound the alarm for 5 seconds
        noTone(ALARMPIN);                  // Fan should already be running from last loop, if not, it will start right after alarm sounds
        delay(500);
        noTone(ALARMPIN);
        delay(500);
        }
     noTone(ALARMPIN);
     checkdelay = 5000;                            // Switch the normal 5 min delay to 30 seconds before going through the loop again
   } else {
    digitalWrite(ALARMLED, LOW);
    Serial.print("Temperature is under ");
    Serial.print(ALARMTEMP);
    Serial.println(", Alarm is OFF");
    checkdelay = 5000;                            // Unless temp is over 120*F the fan runs for 5 minutes before temp is checked again
  }

// Turn ON Heater if cabinet is COLD
  if (avetemp>LEDTEMP) {
    digitalWrite(HeaterPIN, HIGH);
    digitalWrite(LED, HIGH);
    digitalWrite(TEMPOK, LOW);
    Serial.print("Temperature is over ");
    Serial.print(LEDTEMP);
    Serial.print(", Heater is OFF (for ");
    Serial.print(checkdelay / 1000 / 60);
    Serial.println(" minutes)");
    delay(checkdelay);    // turn on minimum of 5 min (unless alarm is going off, then it loops after 30 seconds)
  } else {
    digitalWrite(HeaterPIN, LOW);
    digitalWrite(LED, LOW);
    digitalWrite(TEMPOK, HIGH);
    Serial.print("Temperature is under ");
    Serial.print(LEDTEMP);
    Serial.println(", Heater is ON");                   // When fan is off, Temp is read every 30 seconds
  }
   
  Serial.println();
  Serial.println();



//Humidity



  if (aveHumid>Humidity) {
    digitalWrite(HumidityPIN, HIGH);
    digitalWrite(Humidity, HIGH);
  } else {
    digitalWrite(HumidityPIN, LOW);
    digitalWrite(Humidity, LOW);

  }




// LCD module connections (RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

char temperature[] = "Temp = 00.0 C";
char humidity[]    = "RH   = 00.0 %";

  // set up the LCD's number of columns and rows
  lcd.begin(16, 2);

delay(1);           // wait 1s between readings
  // Read humidity
  byte RH =("\t\tHumidity (%): "); byte (sensor.readHumidity());
  //Read temperature in degree Celsius
  byte Temp =("Temperature(C): "); byte (sensor.readTemp());
 
  // Check if any reads failed and exit early (to try again)
  if (isnan(RH) || isnan(Temp)) {
    lcd.clear();
    lcd.setCursor(5, 0);
    lcd.print("Error");
    return;
  }

  temperature[7]     = Temp / 10 + 48;
  temperature[8]     = Temp % 10 + 48;
  temperature[11]    = 223;
  humidity[7]        = RH / 10 + 48;
  humidity[8]        = RH % 10 + 48;
  lcd.setCursor(0, 0);
  lcd.print("Temp = ");
  lcd.setCursor(8, 0);
  lcd.print(Temp);
  lcd.setCursor(10, 0);
  lcd.print("C");
 
  lcd.setCursor(0, 1);
  lcd.print("Hum  = ");
  lcd.setCursor(8, 1);
  lcd.print(RH);
  lcd.setCursor(10, 1);
  lcd.print("%");

}
}

@sterretje, Thanks so much