Getting error no matching function for call to 'NtpTime::NtpTime(const char*&, int, int)'

I don’t remember what did I change recently, but now I have started getting an error:

relay_led_light.ino:17:49: no matching function for call to 'NtpTime::NtpTime(const char*&, int, int)'

I have included the ntpTime library following the usual step.

#include <NtpTime.h>

#define RELAY1  1       
int inputPin = D0;              // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status

NtpTime* ntpTime;
unsigned long fadeStartTime = 0;
unsigned long fadeDuration = 60000; // 60 seconds

void setup()
{
    pinMode(RELAY1, OUTPUT);
    pinMode(inputPin, INPUT);     // declare sensor as input
    const char* ntpServer = "pool.ntp.org";
    ntpTime = new NtpTime(ntpServer, 3600, 60000);

    // ntpTime = new NtpTime("pool.ntp.org", 3600, 60000);
    ntpTime->begin();
}

void readTheSensor() {
    val = digitalRead(inputPin);
}

void loop()
{
    ntpTime->update();
    readTheSensor();
    if (val == HIGH) {
        // motion detected
        if (pirState == LOW) {
            // motion is just detected
            pirState = HIGH;
            setLEDStrip(pirState);
            fadeStartTime = millis();
        }
    }
    else {
        // no motion detected
        if (pirState == HIGH) {
            // motion is just ended
            if (millis() - fadeStartTime > fadeDuration) {
                pirState = LOW;
                setLEDStrip(pirState);
            } else {
                int brightness = map(millis() - fadeStartTime, 0, fadeDuration, 255, 0);
                analogWrite(RELAY1, brightness);
            }
        }
    }
}

void setLEDStrip(int state) {
    if (state == LOW) {
        digitalWrite(RELAY1, LOW);
    }
    else {
        analogWrite(RELAY1, 255);
    }
}

That’s because there are only these three constructors


none of which fits your call.

However, what is the reason for using that library?
What does the built-in Time object not provide?

Also what is the rationale for instantiating the NtpTime object in setup() and not on initialization? You instantiate it only once anyhow.

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