[SOLVED] Can't use servo library with ESP8266 in PlatformIO, but it works in Arduino IDE

When I include the regular Servo library by Michael Margolis in PlatformIO I get the following error message when I compile for Wemos D1: .pio\libdeps\d1\Servo\src/Servo.h:77:2: error: #error “This library only supports boards with an AVR, SAM, SAMD, NRF52 or STM32F4 processor.”

Okay, fair enough. Except the code compiles and runs perfectly on the ESP8266 when I use the Arduino IDE to upload code.
So the Servo library does work with the Wemos D1 Mini.

Do you have any idea on how to fix this? I have already spent hours pulling my hair.

I did read this similar issue, but I have no global libraries to remove.
I have also followed the suggestion in this topic to run the “Clean” project task and remove the .pio folder. The problem and error message still persists.

That library does not support the ESP8266.

The Arduino-ESP8266 core already comes with its built-in servo library: Arduino/libraries/Servo at master · esp8266/Arduino · GitHub.

Remove the old Servo library from the lib_deps expression of the platformio.ini, remove the .pio folder and retry building.

Alternatively, try specifying

lib_deps = 

directly for the built-in library.


Thanks mate! That worked!

It was also interesting to take a look at the libraries included in the Arduino-ESP8266 core. I didn’t know they could be used without lib_deps expressions.