Search code examples
c++arduinocharinvalid-charactersuint

error: invalid conversion from 'char*' to 'uint32_t


I am trying to manually set up a RTC clock. When doen automatically, this is the working code:

clock.setDateTime((__DATE__, __TIME__));

But now I want to set it manually and this is what I am trying:

char dateTime[20];
strcat(dateTime, "2017,03,22,16,20,04");
//clock.setDateTime((__DATE__, __TIME__));
clock.setDateTime(dateTime);

I get the following error(at the last line):

error: invalid conversion from 'char*' to 'uint32_t {aka long unsigned int}' [-fpermissive]

How to solve?

EDIT: This is how setDateTime is defined:

void setDateTime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second);

Solution

  • setDateTime() accepts ints as parameters, yet you give it char array.

    The call should be:

    clock.setDataTime(2017, 3, 22, 16, 20, 4);