• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Error installing MQTT on ESP32

Q&A Forum › Category: ESP32 › Error installing MQTT on ESP32
0 Vote Up Vote Down
bristol406 asked 3 years ago

I get the following Arduino compilation error when compiling the example sketch for ESP32 from Smart Home Raspberry Pi ebook.
Can anyone see what the problem might be ?
C:\Users\Mike\Documents\Arduino\MQTT\MQTT.ino: In function ‘void onMqttMessage(char*, char*, AsyncMqttClientMessageProperties, size_t, size_t, size_t)’:
MQTT:116:20: error: ‘LED_BUILTIN’ was not declared in this scope
digitalWrite(LED_BUILTIN, HIGH);
^
MQTT:119:20: error: ‘LED_BUILTIN’ was not declared in this scope
digitalWrite(LED_BUILTIN, LOW);
^
C:\Users\Mike\Documents\Arduino\MQTT\MQTT.ino: In function ‘void setup()’:
MQTT:149:12: error: ‘LED_BUILTIN’ was not declared in this scope
pinMode (LED_BUILTIN, OUTPUT);
^
Multiple libraries were found for “WiFi.h”
Used: C:\Users\Mike\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.6\libraries\WiFi
Not used: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\libraries\WiFi
exit status 1
‘LED_BUILTIN’ was not declared in this scope
 
This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.

1 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi.
 
What ESP32 board model are you using? Which board did you select in Tools > Boards?
Some of those boards might not have a built-in led defined.
Replace “LED_BUILTIN” with the GPIO number of the built-in LED. On most boards is 2, but yours might be different depending on the board.
For example, instead of:

digitalWrite(LED_BUILTIN, HIGH);

You’ll have

digitalWrite(2, HIGH);

 
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.