I have this script where I have connected an ESP-01 to an SSD1306 OLED screen. However, the script I'm using needs adaption for ESP-01 as this module requires the I2C pins to be defined.

So basically I need to add a line that says Wire.begin(2, 0); so make the screen work with the ESP-01.

Whoever, I would love to have a check that is wrapped in a #ifdef so the code will work out of the box with multiple ESP modules without changing the source code.

Is there some way I can check if the module in use is an ESP-01?

  • you can check with ifdef which board is selected in Tools menu
    – Juraj
    Feb 24, 2021 at 10:45
  • @Juraj As programming the ESP01 requires me to use the Generic 8266 Module option, I guess it's not possible then?
    – rebellion
    Feb 24, 2021 at 11:40
  • try the ARDUINO_BOARD macro, which is different for wemos and nodemcu and esp01, not sure about others...
    – dandavis
    Feb 24, 2021 at 18:06


Your Answer

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

Browse other questions tagged or ask your own question.