Dependencies And Libraries

Embedded firmware often depends on libraries for sensors, displays, communication protocols, and device drivers. Embedr manages these as project dependencies through PlatformIO.

The key idea

A dependency should be declared by the project. It should not be a mystery package installed somewhere on your machine.

Embedr stores dependency intent in the project and regenerates or updates PlatformIO configuration as needed. PlatformIO may cache packages globally, but the declared list belongs to the repo.

Open Project Dependencies

Click the book icon in the toolbar to open Project Dependencies.

The modal has three tabs:

Tab Use it for
Search Registry Find libraries in the PlatformIO registry.
Project Dependencies View and remove dependencies already declared by the project.
Custom Sources Add dependencies from Git or direct archive URLs.

Search registry

Search for the library by a human name:

  • Adafruit NeoPixel,
  • FastLED,
  • DHT sensor library,
  • ArduinoJson.

Click Add to Project. Embedr calls the CLI, updates the dependency config, and lets PlatformIO install it.

Custom sources

Use custom sources when a library is:

  • not published to the PlatformIO registry,
  • a fork,
  • a specific Git branch,
  • a zip archive from a vendor.

Examples:

https://github.com/adafruit/Adafruit_NeoPixel.git
https://github.com/vendor/library.git#v1.2.0
https://example.com/library.zip

Prefer versioned tags for class, workshop, or production projects. A branch can change without warning.

Where dependencies appear

In PlatformIO terms, dependencies become lib_deps.

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

Embedr also tracks build settings in embedr.yaml for manifest-aware workflows.

Local lib/

Use lib/ for project-specific code that behaves like a library but is not a published package. This is useful for:

  • a sensor abstraction written for one robot,
  • shared headers between source files,
  • code students will modify in a lab.

If the code is reused across many projects, publish it or add it as a Git dependency instead.

Missing library errors

Common compile error:

fatal error: DHT.h: No such file or directory

That means the compiler could not find a header. It can happen because:

  • the library is not installed or declared,
  • the wrong library was installed,
  • the include name is different,
  • the selected framework does not support that library.

Search the registry for the exact component or header name, then read the library's examples.

Version compatibility

Not every Arduino library works on every platform. A library may work on AVR but not ESP-IDF, or on Arduino framework but not Zephyr.

When choosing libraries:

  • check the framework,
  • check examples for your board family,
  • pin versions for reproducible teaching material,
  • compile immediately after adding a library.

Agent workflow

Good request:

Add a maintained DHT11 library for this PlatformIO project, update src/main.cpp with a minimal read loop, compile, and explain any library-specific wiring assumptions.

This asks the agent to do the whole dependency loop: choose, declare, edit, compile, and explain.