0

I have a Wemos D1 board with a OLED display using the u8g2 library.

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

#include <ESP8266WiFi.h>
#include <U8g2lib.h>
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?

VE7JRO
2,51519 gold badges27 silver badges29 bronze badges
asked May 12, 2019 at 17:24
1

1 Answer 1

1

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

answered May 15, 2019 at 14:45

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.