I am working on an esp8266 project which is version controlled via git.
Initially I used the Ticker library that comes with the arduinoespressif8266 framework without declaring it in lib_deps. I now know that is a mistake but it worked back then. Later I switched to Ticker by Stefan Staub and declared it in lib_deps.
The Problem now is that when checking out an older git commit it fails to compile because is is using the newer Ticker library while the code was written to use the old library.
I believe this is caused by the “.pio\libdeps\esp12e\Ticker” folder which is by default not tracked by git. It would probably also not happen if by chance both libraries didn’t have the same name (Ticker.h)
I know that I can temporarily fix this by adding
lib_deps =
Ticker @ ^1.0
but this gets deleted as soon as I go back to the main branch.
My question: Is there an elegant way to fix this?
I hope this is a good post, any feedback welcome 
This is correct and still not a mistake now if the framework-internal library version is to be used.
Using a standard platformio.ini
with
[env:esp8266]
platform = espressif8266
board = nodemcuv2
framework = arduino
and a src\main.cpp
filled with the content from the example shows
Scanning dependencies...
Dependency Graph
|-- <Ticker> 1.0 (C:\Users\Max\.platformio\packages\framework-arduinoespressif8266\libraries\Ticker)
Building in release mode
...
RAM: [=== ] 32.8% (used 26840 bytes from 81920 bytes)
Flash: [== ] 24.7% (used 257736 bytes from 1044464 bytes)
==================== [SUCCESS] Took 1.84 seconds ====================
if instead wanting to use the external library you’ve linked, you should use the full declaration per library page though –
[env:esp8266]
platform = espressif8266
board = nodemcuv2
framework = arduino
lib_deps =
sstaub/Ticker @ ^4.1.0
Using the dedicated example code then as src\main.cpp
gives
Dependency Graph
|-- <Ticker> 4.1.0 (C:\Users\Max\Documents\PlatformIO\Projects\esp8266_airfilter\.pio\libdeps\esp8266\Ticker)
Building in release mode
..
RAM: [=== ] 33.2% (used 27196 bytes from 81920 bytes)
Flash: [=== ] 25.2% (used 263420 bytes from 1044464 bytes)
Creating BIN file ".pio\build\esp8266\firmware.bin" using "C:\Users\Max\.platformio\packages\framework-arduinoespressif8266\bootloaders\eboot\eboot.elf" and ".pio\build\esp8266\firmware.elf"
==================== [SUCCESS] Took 6.98 seconds ====================
If you’ve onced used one library and then want to switch to another, after doing the platformio.ini
modifications, you should also to a project clean and remove the .pio
folder of the project to remove the old library. Otherwise it will still be found by the library dependency finder.
1 Like
That was the tip I needed, Thanks! Not only did you fix my problem, but I also learned something.