0

i wanted to convert a double to a string i tested several examples online i allawys get the same error.

the code :

void setup()
{
  Serial.begin(9600);

}
void loop()
{
  double val =3.2222;
  String stringOne =  String(val, 3);
  Serial.print(stringOne);
}

the errors :

sketch_jun02c.ino: In function ‘void loop()’:
sketch_jun02c.ino:10:36: error: call of overloaded ‘String(double&, int)’ is ambiguous
sketch_jun02c.ino:10:36: note: candidates are:
In file included from /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:192:0,
                 from sketch_jun02c.ino:2:
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:70:11: note: String::String(long unsigned int, unsigned char)
  explicit String(unsigned long, unsigned char base=10);
           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:69:11: note: String::String(long int, unsigned char)
  explicit String(long, unsigned char base=10);
           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:68:11: note: String::String(unsigned int, unsigned char)
  explicit String(unsigned int, unsigned char base=10);
           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:67:11: note: String::String(int, unsigned char)
  explicit String(int, unsigned char base=10);
           ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:66:11: note: String::String(unsigned char, unsigned char)
  explicit String(unsigned char, unsigned char base=10);
           ^
8
  • 1
    Which IDE version are you using? The fact it's showing /usr/share/arduino tells me you installed it with apt-get (or similar), so you're probably on something ridiculously ancient.
    – Majenko
    Jun 2 '17 at 16:14
  • Yes i used apt-get, the version i am using is: ARDUINO 1.0.5 - 2013.05.15, is there a way to update it without deleting the old version ?
    – Ryan
    Jun 2 '17 at 16:36
  • Download the new version from the website, extract it, and run it.
    – Majenko
    Jun 2 '17 at 17:17
  • Yea I have done that already thanks Majenko ;)
    – Ryan
    Jun 2 '17 at 17:54
  • The current Arduino SDK version is 1.8.2. So 1.0.5 is really old. Package managers do not necessarily stay up to date. Especially with packages that don't make up the core of the OS. In C++ the types of the arguments are just as important as the name of the function you are calling. No (perfect) match means no function will be called. So it does not look like there is a matching "Strings()" function. That is, a "Strings()" function where the type of the argument is a double.
    – st2000
    Jun 3 '17 at 4:30
0

I had installed arduino using apt-get and I didnt notice that I had an old version. I upgraded my arduino and it worked fine.

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.