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.
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