Blog
ESP32 Libraries: Install, Use, Fix
Installing a library is the easy half — the hard half is the version mismatch that breaks the next compile. Where libraries live, how to pick one that works, and what to do when the example won’t build.
How to Install ESP32 Library in Arduino?
Library Manager (Sketch → Include Library → Manage Libraries), search, install — most ESP32 libraries are there. The manual route: download the ZIP, Sketch → Include Library → Add .ZIP Library. One catch: the Library Manager lists everything for every board, so filter by ESP32 tags or check the repo says arduino-esp32. The Arduino IDE FAQ covers the folder layout.
How to Use Animated GIF Library ESP32?
AnimatedGIF by Larry Bank is the go-to — pair it with TFT_eSPI and it plays GIFs on common SPI screens. GIFs decode to raw frames, so RAM matters: a 320×240 frame is roughly 150 KB, which is why animation struggles on 2 MB chips and sings on PSRAM boards. On my 240×320 ILI9341 it ran about 15 FPS, smooth enough for a looping animation. The example projects page has a working setup.
Is Harware Serial Library in ESP32?
Yes — HardwareSerial is built into the core, no install needed. Serial, Serial1, and Serial2 exist on the classic ESP32; on C3 and S3 the availability of Serial1 and Serial2 depends on the chip’s UART count. ‘Harware serial’ is a search typo; same built-in library either way.
Why Does My Library Compile on One Board but Not Another?
Board-specific config — pins in #define, PSRAM presence, flash size. Many ESP32 libraries assume a WROOM-32 with 4 MB flash and hard-code pins that S3 boards route differently. Read the library’s README for the board table; if it lists boards, yours must be on it.
Library Installed but Not Found?
Restart the IDE, then check the sketchbook folder: File → Preferences shows it, and user libraries live in <sketchbook>/libraries. Two common fails: the ZIP extracted into a nested folder (Arduino wants the .h one level deep), or the IDE cached a corrupt copy — delete and reinstall. The knowledge base has the screenshot walkthrough.
Core Update Broke My Library — Now What?
The arduino-esp32 2.x to 3.x jump renamed APIs; libraries pinned to old names fail with confusing errors. Fixes, in order: update the library, read its changelog, or pin the core in Boards Manager to the version the library names.
Built-In vs Third-Party Libraries — What’s the Difference?
Built-in means the core ships it — WiFi.h, HardwareSerial, SPI, Wire. Third-party means an external repo — sensors, displays, services. Built-ins update with the core; third-party libraries update on their own schedule, which is exactly why pinning matters.
Two Libraries Define the Same Function — Conflict?
Yes, and the linker picks one silently or errors. C++ doesn’t stop you; the result is a coin flip of which gets called. Find the duplicate from the error message, then uninstall one library or use its namespace if it has one. I hit this with two DHT libraries once; the fix was deleting the one I never used.
How Do I Know Which Library a Sketch Needs?
Read the #include lines, then search the Library Manager for each name — Adafruit BMP280, U8g2, whatever. The README or example header usually names the author’s preferred fork, which matters for renamed libraries. The library with issues that actually get closed is the one that works.
Can I Write My Own ESP32 Library?
Yes — a folder with .h, .cpp, and library.properties inside <sketchbook>/libraries is a library. Export the API you use, keep hardware specifics in header config, and an ESP32 library is just an Arduino library that #ifdefs ESP32 headers.
Real Libraries, Resolving for Real
The simulator installs and links the same libraries the desktop IDE does — which makes it a fast way to test the “is it my code or the library?” question:
- DHT22 example — built on Adafruit’s DHT sensor library and Adafruit Unified Sensor, the exact pair this FAQ recommends. If it compiles and runs here, your include path and constructor usage are sound.
- SSD1306 OLED — the Adafruit GFX/SSD1306 stack, same story.
No toy re-implementations: when a library misbehaves, what you learn here transfers to hardware one-to-one.