Data type conversion problem I have a Wemos D1 board with a OLED display using the u8g2 library.

I am printing my MAC-adress on the serial port &amp; would like to print the same information on the OLED:


#include &lt;ESP8266WiFi.h&gt;
#include &lt;U8g2lib.h&gt;
byte mac[6];
setup(){
  Serial.println(WiFi.macAddress());
  WiFi.macAddress(mac);
  u8g2.drawStr(1,10,WiFi.macAddress());
  u8g2.sendBuffer();
}


This does not work. It prints the MAC-address on the serial port but not on the OLED.

I get: no known conversion for argument 3 from 'String' to 'const char*

How can I print the MAC-information on my oled using the u8g2-library?
As said by @Mikael Patel
You need to append .c_str() to u8g2.drawStr(1,10,WiFi.macAddress()); creating the line: u8g2.drawStr(1,10,WiFi.macAddress().c_str());

The problem is that WiFi.macAddress() returns a String not the needed const char* by the drawStr function. c_str converts the String object into a const char*.

Please look at the documentation of the u8g2 library for the drawStr function.

link

And here the documentation for String

link