Dependencies and Libraries

Add, pin, list and remove PlatformIO libraries through the agent, the embedr CLI or by editing platformio.ini.

Firmware libraries for sensors, displays and protocols are PlatformIO packages that the project declares in its own files. Embedr has no separate library manager window; you add libraries by asking the agent, with the embedr lib commands in the Terminal, or by editing platformio.ini yourself.

Where the list lives

Project Declared in
Projects created by current versions of Embedr (manifest_version: 1 in embedr.yaml, with a platformio.ini) lib_deps in platformio.ini, in the active environment's section
Older projects without manifest_version: 1 lib_deps under build: in embedr.yaml; Embedr regenerates platformio.ini from it

A typical platformio.ini:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
    adafruit/Adafruit NeoPixel@^1.12.0
    bblanchon/ArduinoJson@^7.0.4

PlatformIO downloads declared libraries into .pio/libdeps/ inside the project on the next build. .pio/ is build output: do not edit it and do not commit it.

Ask the agent

The agent can search the PlatformIO registry and install libraries. In the chat these steps show as Search libraries and Install library.

Add a maintained library for the DHT22 sensor, pin it to a version, update src/main.cpp with a minimal read loop on GPIO 4, compile, and tell me which library you chose and why.

That request covers the whole loop: choose, declare, edit, build and explain. Installing a library changes project files, so it is blocked in Plan Mode.

Use the CLI

The Terminal tab has the embedr command on its path. Run these from the project folder, or pass --path.

# Search the PlatformIO registry
embedr lib search "neopixel"
embedr lib search dht --limit 5

# Install and declare a library
embedr lib install "Adafruit NeoPixel"
embedr lib install "DHT sensor library" --version 1.4.4

# What the project declares and what is installed
embedr lib list

# Remove a library from the project
embedr lib uninstall "Adafruit NeoPixel"

# Update every library to its latest allowed version
embedr lib update

embedr lib install installs the package and adds it to the project's declared list, and reports where it saved it (platformio.ini or embedr.yaml). If the library is already declared it says so and changes nothing. All the flags are in the CLI reference.

Git and URL sources

A library that is not in the registry, a fork, or a specific tag can be declared by URL in lib_deps:

lib_deps =
    https://github.com/adafruit/Adafruit_NeoPixel.git#1.12.0
    https://github.com/your-org/sensor-driver.git#v2.1.0
    https://example.com/vendor-library.zip

The part after # is a tag, branch or commit. Prefer tags or commits: a branch can change under you. You can give the agent a repository URL and a tag and ask it to add the dependency.

Project code in lib/

Put code that belongs to this project but behaves like a library, such as a driver you wrote for this robot, in lib/<Name>/:

lib/
└── MotorDriver/
    ├── MotorDriver.h
    └── MotorDriver.cpp

PlatformIO builds it with the project and #include "MotorDriver.h" works from src/. If the code is shared across projects, publish it or reference it by Git URL instead.

Missing library errors

src/main.cpp:3:10: fatal error: DHT.h: No such file or directory

The compiler could not find a header. Usually one of these:

  • the library is not declared in lib_deps,
  • a different library with a similar name was installed,
  • the header name differs from the library name (check the library's examples),
  • the library does not support the selected framework or chip.

Select the error in the Output tab, click Add to Chat, and ask the agent to fix it, or click Fix with Agent. See Build, upload and serial.

Choosing libraries

Not every Arduino library works on every board. A library written for AVR may not build for ESP32 or RP2040, and Arduino libraries do not build under ESP-IDF.

  • Check that the library lists your framework and platform.
  • Build right after adding a library, before writing code against it.
  • Pin versions (@1.4.4 or @^1.4.4) for projects other people will build, such as class material or a product.
  • Commit platformio.ini (and embedr.yaml) so collaborators get the same list.

For physical parts (sensors, connectors, ICs) rather than firmware libraries, see Component library.