How do I get rid of this compile error?

I don't understand why Serial.print(dVal) compiles but serialHC05.write(dVal) won't compile.

They're both HardwareSerial objects aren't they? (Serial and Serial2)

sketch\Debug.cpp: In member function 'void CDebug::dump(char, double)':

Debug.cpp:159: error: call of overloaded 'write(const double&)' is ambiguous

serialHC05.write(dVal);

^

sketch\Debug.cpp:159:26: note: candidates are:

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:232:0,

from sketch\Debug.cpp:1:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:129:20: note: virtual size_t HardwareSerial::write(uint8_t)

virtual size_t write(uint8_t);

^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:130:19: note: size_t HardwareSerial::write(long unsigned int)

inline size_t write(unsigned long n) { return write((uint8_t)n); }

^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:131:19: note: size_t HardwareSerial::write(long int)

inline size_t write(long n) { return write((uint8_t)n); }

^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:132:19: note: size_t HardwareSerial::write(unsigned int)

inline size_t write(unsigned int n) { return write((uint8_t)n); }

^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:133:19: note: size_t HardwareSerial::write(int)

inline size_t write(int n) { return write((uint8_t)n); }

^

#define serialHC05 Serial2

void CDebug::log(const double dVal, const bool bNewLine)
{
  #ifdef DEBUG
    Serial.print(dVal);
    if (bNewLine)
      Serial.println();
  #elif defined DIAGNOSTIC
    serialHC05.write(dVal);
    if (bNewLine)
      serialHC05.write("\r\n");
  #else
    m_file.write(dVal);
    if (bNewLine)
      m_file.writeLine(F(""));
  #endif
}

The problem has nothing to do with Serial vs Serial2. The problem is trying to pass a double to write(). You can't do that, use print() instead. If you try to do:

Serial.write(dVal)

you'll encounter the same error.

It's much easier for us to help you if you provide a simplified, self-contained example. You have a lot of unnecessary extra complication in your code snippet. Much better to give us something like this:

void setup() {
  double dVal = 1.42;
  Serial.print(dVal);
  Serial2.write(dVal);
}
void loop() {}

Please also use code tags for compiler output/error/warning messages, etc. The reason is to make sure they will be correctly rendered by the forum.

OK thanks for that. A different question then.

Does anyone use Realterm?

I am trying to get the above code to write debug info my HC05 rather than the Serial monitor.

I have done this on a previous occasion some time ago but I can't seem to get it to work this time.

I have a bluetooth dongle on my PC, I have successfully paired with the HC05 in windows bluetooth devices, have have added the correct com port settings in Realterm and opened the port, but I am not getting any text coming through in the Realterm window.

Don't know what I am doing wrong in Realterm. Any suggestions re Realterm?