invalid conversion from 'char*' to 'uint64_t {aka long long unsigned int}'

Hi all!

Im facing this error during the compiling of the program.

I understand that i need to convert char to int so i can use it on a variable. I can't do it now.

This is the code:

char deepSleep_time[] = "Insert a 3 digits number.";


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

You cannot test it this way but the code is the simplest i can upload so you can concentrate on it.

Any clues?

From Esp.h, the prototype for that function is:

void deepSleep(uint64_t time_us, RFMode mode = RF_DEFAULT);

So, it takes two arguments:

  • A sleep time in microseconds
  • An RFMode

Also from Esp.h, the choices of RFMode are:

enum RFMode {
    RF_DEFAULT = 0, // RF_CAL or not after deep-sleep wake up, depends on init data byte 108.
    RF_CAL = 1,      // RF_CAL after deep-sleep wake up, there will be large current.
    RF_NO_CAL = 2,   // no RF_CAL after deep-sleep wake up, there will only be small current.
    RF_DISABLED = 4 // disable RF after deep-sleep wake up, just like modem sleep, there will be the smallest current.

I'm curious how this is a uint64_t char deepSleep_time[] = "Insert a 3 digits number.";

ESP32 deepsleep() only needs the sleep time, the other parameter is an option.

BTW this is a unit64_t 1, or 1000, or 100000, or 1000000000, or 1000000, or 135406978888887, but an array of characters in NOT a unit64_t.


 esp_sleep_enable_timer_wakeup( (1000000 * (60 * 3)) - 4000000 ); //3 minute sleep time  - 4 seconds
    //esp_sleep_enable_timer_wakeup( 1000000 * (60 * 5) ); //5 minute sleep time  
    //esp_sleep_enable_timer_wakeup( 1000000 * (60) ); // 1 minute slep time for troubleshooting, drains battery.

Ok! Good answers out there.

If im not misunderstood i only need to use:

Char deepSleep_time = “100000” ?????

Like i said before, the problem comes when i want to convert the deepSleep_time variable into numbers.

Im using a custom Wifimanager library as a front end to show some fields in which the user can input some data. That way works me ok with a another fields but none with this deep sleep number field. The final idea is to obtain a 3 digit number and convert it to minutes.

You might want start with a search on how to covert char to int.

Char deepSleep_time = "100000" ?????

No. The deepSleep function wants a number (juint64_t), not a string (null terminated character array).

void deepSleep(uint64_t time_us,


uint64_t deepSleep_time = 100000;

To convert a string (null terminated character array) to a number you can use the strtol() function.

But we have only 2 lines of code from you so we don't really know where the string comes from.

Ok i manage to post a part of the code due to characters limit, so you can check it out and have and idea of whats going on.

First of, i declare some variables with char type outside the void setup() that are going to be seen on the front end.
Second, i do some copy to the FS memory because all those fields inputs are saved on the FS.
Third, using the wifimanager library i declare the aumont of characters of every variable declared on the first point.
Fourth, i've hardcoded the aumont of time that i want to use on the deepSleep function, there i need to use the variable declared on the first point.

//char mqtt_server[40] = "ingrese server mqtt";
//char mqtt_port[6] = "ingrese puerto mqtt";
char blynk_token[33] = "Ingrese Token de Blynk";
char plant_name[33] = "Ingrese nombre de la planta";
char deepSleep_time[] = "Insert a 3 digit number for Deep Sleep.";

void setup()

strcpy(blynk_token, json["blynk_token"]);
strcpy(plant_name, json["plant_name"]);
strcpy(deepSleep_time, json["deepSleep_time"]);

WiFiManagerParameter custom_blynk_token("blynk", "blynk token", blynk_token, 33);
WiFiManagerParameter custom_plant_name("plant name", "plant name", plant_name, 33);
WiFiManagerParameter custom_deepSleep_time("deepSleep time", "deepSleep time", deepSleep_time, 64);


ESP.deepSleep(60e6); // 60 segs

I need to use the variable deepSleep_time here:

ESP.deepSleep(deepSleep_time); // 60 segs

But it doesnt work as spected.

I should convert the deepSleep_time before using it on the final ESP.deepSleep(....)

The plant_name and blynk token variables works ok!

Thanks a lot!!

So far this is what I got:

So in some place, with some unseen code, someone types something "like I am a pretzel" and you want to convert that typing into a uint64_t, so you can put the ESP to sleep.

Well each character is a 'byte' and each byte can be added together, or multiplied, or some other formula you wish, to make it into a uint64_t. not sure if i understood correctly but somehow i need to convert the variable input into bytes or something?.

The weird thing is that for example the MQTT port field receives a number, and then i can use it later on the code without any problems.

Sorry but im stuck here.


The words "a peanut" is not 1000000, a number. If you want the words to reflect a number then you have to change those words to a number.

If someone enters the characters 'I am a mushroom' and deepsleep() requires an integer, then, of course, the characters need to be converted to integers; see post #5.

Me, I'd have someone enter numbers, then, I'd test the entered value to see if its a number, and then change those number characters to integers; see post #5. or do an internet search on 'character array to int c++'.

If you pee into the wind and you don't like getting wet, change directions.

"If you pee into the wind and you don't like getting wet, change directions." -- cool phrase.

ok, so, i need then too input a 3 digit number into that variable, maybe i should leave the variable empty and try that. can i inform people to input "a 3 digit number" into that field?.

Even if i convert words into numbers it will not work either because i need only 3 digit number especifically the numbers that the user wants.


Google "Arduino user input" to see some ways to have a user input data.

Thank you.

Whatever user prompt you currently have, change it to reflect the desired input. Training. Written instructions. Could be ways to have the user enter the proper information.

3 digit number is 0 through 999. If you do the math you can get a number of seconds for sleep time between 1 and 999 seconds.

For the ESP32 be ware that long sleep times, such as days, weeks,, months, years, decades, and so on are not recommended because there is a translation from unit64_t to a smaller datatype in the RTC module. For very long sleep times you can use RTC fast ram to store a count.

Let's say a sleep time of 4 hours is wanted. setup() can run, check the contents of the RTC variable, if the variable is less than X then go back to sleep.

Whiles using the Main ESP32 processor to keep track of time passed is one way to do long sleep times another way would be to use the ULP processor. When it comes to long time periods it is best to use the ULP processor to count the time, increment the RTC variable, and or wake the main cpu. The ULP processor is easily programmable, in the Arduino IDE, using the GNU legacy method, and macro assembler.

The ULP processor or Ultra Low Power Processor, has limitations, under the Arduino IDE, of having 2K of 32 bit ram for the RTC Fast and Slow ram and not 8K as per the ESP32 API API Reference - ESP32 - — ESP-IDF Programming Guide latest documentation

ok, thanks for that long answer!.

I was wondering how can i convert a number into scientific notation because Deep Sleep waits for that.

I mean, this 10 into this 1e+7 so i can use that as a valid variable.


An internet search will answer your question.

deepsleep() uses a unit64_t, not a floating point number; u = unsigned, int = integer, 64 = 64 bit integer.

Great, i've searched but i only found the examples with float numbers.

Could you provide some examples?


Great, i've searched but i only found the examples with float numbers.

Could you provide some examples?



This forum is for helping people and share information with others about failures and success. So maybe you can't answer my question but maybe anyone?.


It's just arithmetic.

Yes i know is aritmethic but how can i do it?. Im really lost there.

I need just a tip of where to start.

Thanks a lot!.