0

I'm really new to coding for arduino. My current project is a monitor for my terrarium using an arduino UNO board, a DHT11 and a DS3231 RTC, displaying Temperature(from both DHT (in the terrarium) and the RTC (outside)) as well as time and humidity.

The code was functional, but recently the IDE said there were some updates (which I ran) and now it won't verify. All this code was basically obtained through examples for the hardware I'm using. Can someone please point me to what I need to correct?

The code as is ....

#include <DS3231.h>

#include <dht11.h>

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
DS3231  rtc(SDA, SCL); 
dht11 DHT;                        //Note:DHT on behalf of the temperature         and humidity sensor 
const int dht11_data = 6;     
int temp=0;
int hum=0;

#include "Wire.h"
#define DS3231_I2C_ADDRESS 0x68
                              // Convert normal decimal numbers to binary   coded decimal
byte decToBcd(byte val)
{
  return( (val/10*16) + (val%10) );
}
                              // Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)

{
  return( (val/16*10) + (val%16) );
}

void setup()
{
  Wire.begin();
                              // set the initial time here:
  // DS3231 seconds, minutes, hours, day, date, month, year
  // setDS3231time(30,42,21,4,26,11,14);
  rtc.begin();                    //Initialize the rtc object
  lcd.begin(16,2);                //Initialize LCD display
  lcd.print("Terrarium ");        //Splash Screen text line 1
  lcd.setCursor(0,1);             //Set Cursor Position for second line of Splash screen
  lcd.print("Monitor 1.3");       //Splash screen text line 2
  delay(3000);                    //Delay 3 seconds on Splash screen
  lcd.clear();                    //Clear LCD
}


void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte
dayOfMonth, byte month, byte year)

{
  // sets time and date data to DS3231
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0);                  // set next input to start at the seconds register
  Wire.write(decToBcd(second));   // set seconds
  Wire.write(decToBcd(minute));   // set minutes
  Wire.write(decToBcd(hour));     // set hours
  Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday)
  Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31)
  Wire.write(decToBcd(month));    // set month
  Wire.write(decToBcd(year));     // set year (0 to 99)
  Wire.endTransmission();
}

void readDS3231time(byte *second,byte *minute,byte *hour,byte     *dayOfWeek,byte *dayOfMonth,byte *month,byte *year)

{
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set DS3231 register pointer to 00h
  Wire.endTransmission();
  Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
                              // request seven bytes of data from DS3231       starting from register 00h
  *second = bcdToDec(Wire.read() & 0x7f);
  *minute = bcdToDec(Wire.read());
  *hour = bcdToDec(Wire.read() & 0x3f);
  *dayOfWeek = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month = bcdToDec(Wire.read());
  *year = bcdToDec(Wire.read());
}
void displayTime()
{
  DHT.read(dht11_data);
  temp=DHT.temperature;
  hum=DHT.humidity;

  lcd.clear();                    //clear display

  lcd.print("rH=");               //Display text rH= on LCD
  lcd.print(hum);                 //Display relative humidiy reading from    DHT11
  lcd.print("%");                 //Display Percent sign

  lcd.setCursor(9,0) ;            //set cursor position
  lcd.print("Ti=");               //display"Ti="
  lcd.print(temp);                //Displays temperature reading from     DHT11, designated is Internal Temperature
  lcd.write(0xDF);                //Display custom characters '°'
  lcd.print("C");                 //Display text "C" to designate Celsius     units

  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

                              // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,  &year);
                              // send it to the serial monitor

  lcd.setCursor(0,1);
  lcd.print(hour, DEC);           //Displays hours value on LCD
                               // convert the byte variable to a decimal number when displayed
  lcd.print(":");                 //Displays ":" between hours and minutes
  if (minute<10)
  {
    lcd.print("0");
  }
  lcd.print(minute, DEC);         //Displays Minutes value on the LCD
  lcd.setCursor(9,1);
  lcd.print ("Te:");              //Displays text "Te:" on LCD
  lcd.print(rtc.getTemp());       //Displays Temperature from DS3231 designated as "External Temperature"

}
void loop()
{
  displayTime();                  // display the real-time clock data on the Serial Monitor,
  delay(1000);                    // every second
}

and the errors it is throwing are:

> > Arduino: 1.8.3 (Windows 10), Board: "Arduino/Genuino Uno"
> 
> Terrarium_Monitor_1.3:8: error: no matching function for call to
> 'DS3231::DS3231(const uint8_t&, const uint8_t&)'
> 
>  DS3231  rtc(SDA, SCL); 
> 
>                      ^
> 
> F:\Arduino Kit Stuff\my
> sketches\Terrarium_Monitor_1.3\Terrarium_Monitor_1.3.ino:8:21: note:
> candidates are:
> 
> In file included from F:\Arduino Kit Stuff\my
> sketches\Terrarium_Monitor_1.3\Terrarium_Monitor_1.3.ino:1:0:
> 
> C:\Users\Ursinos\Documents\Arduino\libraries\DS3231/DS3231.h:64:3:
> note: DS3231::DS3231()
> 
>    DS3231();
> 
>    ^
> 
> C:\Users\Ursinos\Documents\Arduino\libraries\DS3231/DS3231.h:64:3:
> note:   candidate expects 0 arguments, 2 provided
> 
> C:\Users\Ursinos\Documents\Arduino\libraries\DS3231/DS3231.h:60:7:
> note: constexpr DS3231::DS3231(const DS3231&)
> 
>  class DS3231 {
> 
>        ^
> 
> C:\Users\Ursinos\Documents\Arduino\libraries\DS3231/DS3231.h:60:7:
> note:   candidate expects 1 argument, 2 provided
> 
> C:\Users\Ursinos\Documents\Arduino\libraries\DS3231/DS3231.h:60:7:
> note: constexpr DS3231::DS3231(DS3231&&)
> 
> C:\Users\Ursinos\Documents\Arduino\libraries\DS3231/DS3231.h:60:7:
> note:   candidate expects 1 argument, 2 provided
> 
> F:\Arduino Kit Stuff\my
> sketches\Terrarium_Monitor_1.3\Terrarium_Monitor_1.3.ino: In function
>    'void setup()':
> 
> Terrarium_Monitor_1.3:34: error: 'class DS3231' has no member named
> 'begin'
> 
>    rtc.begin();                    //Initialize the rtc object
> 
>        ^
> 
> F:\Arduino Kit Stuff\my
> sketches\Terrarium_Monitor_1.3\Terrarium_Monitor_1.3.ino: In function
> 'void displayTime()':
> 
> Terrarium_Monitor_1.3:112: error: 'class DS3231' has no member named
> 'getTemp'
> 
>    lcd.print(rtc.getTemp());       //Displays Temperature from DS3231
> designated as "External Temperature"
> 
>                  ^
> 
> Multiple libraries were found for "LiquidCrystal.h"  Used: E:\Program
> Files (x86)\Arduino\libraries\LiquidCrystal  Not used:
> C:\Users\Ursinos\Documents\Arduino\libraries\arduino_136712 exit
> status 1 no matching function for call to 'DS3231::DS3231(const
> uint8_t&, const uint8_t&)'
> 
> This report would have more information with "Show verbose output
> during compilation" option enabled in File -> Preferences.

As I said, I was working when I uploaded it to my arduino on last changes a week ago (and it's still running on the board right now), but after doing the updates to the libraries and whatnot, it's now throwing all these errors. I know the code isn't very elegant, I'm still learning. Please help

edit: After altering the line as advised in the answers, I now get the following errors.

Arduino: 1.8.3 (Windows 10), Board: "Arduino/Genuino Uno"

F:\Arduino Kit Stuff\my sketches\Terrarium_Monitor_1.3  \Terrarium_Monitor_1.3.ino: In function 'void setup()':

Terrarium_Monitor_1.3:34: error: 'class DS3231' has no member named 'begin'

   rtc.begin();                    //Initialize the rtc object

       ^

F:\Arduino Kit Stuff\my sketches\Terrarium_Monitor_1.3  \Terrarium_Monitor_1.3.ino: In function 'void displayTime()':

Terrarium_Monitor_1.3:112: error: 'class DS3231' has no member named 'getTemp'

 lcd.print(rtc.getTemp());       //Displays Temperature from DS3231 designated as "External Temperature"

             ^

Multiple libraries were found for "LiquidCrystal.h"
 Used: E:\Program Files (x86)\Arduino\libraries\LiquidCrystal
 Not used: C:\Users\Ursinos\Documents\Arduino\libraries   \arduino_136712
exit status 1
'class DS3231' has no member named 'begin'

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

Could this have anything to do with my Arduino IDE being version 1.8.3 instead of the newest version?

  • the I2C (Wire) pins SDA and SCL are constant on Uno. no need to give them into the constructor. change DS3231 rtc(SDA, SCL); to DS3231 rtc; – Juraj May 25 '18 at 8:24
  • huh, that's pretty weird since so many of the code examples I've come across have it entered like I had it. – Ursinos May 25 '18 at 9:43
  • because the libraries are cross platform and on some platforms you can choose the pins. and in new version they disabled for AVR the constructor with parameters – Juraj May 25 '18 at 11:10
0

I found this online but I can not verify it.

http://www.instructables.com/topics/no-matching-function-for-call-to-DS3231DS3231const/

The relevant part for you I think is:

I don't know where you get the syntax

DS3231 rtc (SDA, SCL);

My copy of the DS3231 library says you need only DS3231 rtc; //no arguments. BUT you need the Wire library.

So change your code and make sure you have the Wire library.

  • 1
    I have the wire library installed and included. I tried changing that segment of code and it did not help – Ursinos May 25 '18 at 9:20
  • 1
    actually, I figured out what I did wrong the first time I tried changing it. It cleared the error for that one segment, Editing original post to show new errors. – Ursinos May 25 '18 at 9:23
  • 1
    so why did you accept the answer? – Juraj May 25 '18 at 11:11
  • because it was part of the problem – Ursinos May 25 '18 at 18:23
2

Alright, so I figured it out by gasp going and reading the documentation for the DS3231 library I'm using.

It seems when the library updated, one of the keywords changed.

so, after removing the (SDA, SCL) from the one line, I had to remove the line

rtc.begin();

and change

lcd.print(rtc.getTemp()); 

to

lcd.print(rtc.getTemperature());

thanks for the help :D

  • 1
    Thanks for advising us of that. Personally I don't update the IDE very often. What is the point? I currently use 1.6.9. It works, and there is a danger if you upgrade then things stop working. It's not as if your Arduino has to connect to some new-fangled printer that was only released last week. – Nick Gammon May 25 '18 at 10:41

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.