Designing Custom Footprints in KiCad
How to build a custom footprint in KiCad's Footprint Editor for a part that isn't in the standard library, illustrated with a real footprint for the DHT22 sensor module on an ESP32 circuit.
This guide walks through building a custom footprint in KiCad's Footprint Editor when the standard library doesn't have a part with the right dimensions — using the real footprint for the DHT22 module (2.54mm pin pitch, single row of 3 pins) on an ESP32 DevKit V4 + DHT22 circuit.
Detailed guide
How to create a custom footprint in KiCad's Footprint Editor for a part that isn't in the standard library, illustrated with a real footprint for the DHT22 sensor module on an ESP32 circuit.
1. Introduction
KiCad's built-in footprint library (and the community libraries) covers most common parts, but it doesn't always have a footprint that exactly matches the physical part in your hand — especially cheap sensor modules, unbranded parts, or homemade boards. Using an "approximately right" footprint in that case can leave pads misaligned with the part's actual pins, causing crooked solder joints or a part that just won't fit. The correct fix is to draw a custom footprint yourself in KiCad's Footprint Editor, matching the physical dimensions you measured.
This guide uses the DHT22 (AM2302) sensor module in the ESP32 DevKit V4 + DHT22 example circuit as a hands-on exercise: measure — draw — verify a custom 3-pin footprint that matches a real DHT22 module.
2. Components Needed
Component | Qty | Notes |
|---|---|---|
ESP32 DevKit V4 | 1 | The main control board |
DHT22 (AM2302) | 1 | The part used for this custom-footprint drawing exercise |
Calipers or a mechanical datasheet | 1 | For measuring/verifying the module's real dimensions before drawing the footprint |
3. Wiring Diagram (the real circuit used as an example)
DHT22 | ESP32 DevKit V4 |
|---|---|
VCC | 3V3 |
GND | GND |
DATA | GPIO4 |
4. Why the DHT22 Needs a Custom Footprint
The real-world mechanical dimensions of a typical DHT22 breakout module (measured/cross-checked against internal catalog data): roughly 12mm wide, 28mm long, with 3 pins in a single row at the standard 2.54mm pitch — but the pin row itself sits about 25.4mm along the module's long axis, which doesn't match the default "3-pin THT header" footprints in the standard library (those usually have 3 pins packed close together with no such large offset). This is exactly the situation that forces you to draw your own footprint: use a generic header footprint by mistake, and the PCB pad spacing simply won't line up with the module's real pins.
5. Drawing a Custom Footprint in the Footprint Editor
Step 1 — Create a personal footprint library
Open KiCad's Footprint Editor and go to File → New Library to create your own .pretty library (e.g. MyModules.pretty) — keep your personal library separate from the system ones so it's easier to manage and won't get overwritten by future KiCad updates. Then use New Footprint to create the new footprint, giving it a clear name like DHT22_Sensor_3Pin_2.54mm.
Step 2 — Place pads at the measured dimensions
Use the Pad tool to place three pads for VCC, DATA, and GND. On a real DHT22 module: the pad spacing along the horizontal axis is 2.54mm (0.1"), and pads should be round/oval through-hole types with a hole diameter matching the part's pins (typically 0.8–1.0mm for the DHT22's flat pins). Place pad 1 (usually VCC) as the origin (0,0), then use the pad's Properties dialog to enter exact coordinates for pads 2 and 3 instead of dragging them by eye — this keeps the measurements accurate.
Step 3 — Draw the Silkscreen and Courtyard layers
Switch to the F.Silkscreen layer and draw an outline showing the module's physical footprint (a roughly 12×28mm rectangle, based on your measurements), so anyone soldering the assembled PCB can see exactly where the module sits and how it's oriented (pin 1 is usually marked with a dot or a chamfered corner). Then draw the Courtyard layer (F.CrtYd) — the boundary used for overlap checking when placing multiple components close together in the PCB Editor, following the standard IPC recommendation.
Step 4 — Set properties and save
Set the default reference designator prefix (e.g. "U" or "S" for a sensor), attach a 3D model if you have one (optional, but handy for previewing the board in 3D), then save the footprint into the .pretty library you created in step 1.
Step 5 — Assign the custom footprint to the schematic symbol
Back in the Schematic Editor, use the Assign Footprints tool, browse to your new personal library, and pick the DHT22_Sensor_3Pin_2.54mm footprint for the DHT22 symbol in the circuit. Run DRC after updating the PCB from the schematic to confirm the new footprint has no geometry errors or clearance violations.
6. ESP32 + DHT22 Sample Code (the real circuit used to verify the footprint)
#include <DHT.h>
#define DHTPIN 4
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
const unsigned long TELEMETRY_INTERVAL_MS = 2000;
unsigned long lastTelemetryAt = 0;
void setup() {
Serial.begin(115200);
delay(200);
Serial.println();
Serial.println(F("=== ESP32 + DHT22 - Vi du minh hoa cho bai viet KiCad/PCB ==="));
Serial.println(F("Boot OK. Khoi tao cam bien DHT22..."));
dht.begin();
Serial.println(F("San sang doc du lieu."));
}
void loop() {
unsigned long now = millis();
if (now - lastTelemetryAt >= TELEMETRY_INTERVAL_MS) {
lastTelemetryAt = now;
float humidity = dht.readHumidity();
float temperatureC = dht.readTemperature();
Serial.print(F("{\"temperature_c\":"));
if (isnan(temperatureC)) {
Serial.print(F("null"));
} else {
Serial.print(temperatureC, 1);
}
Serial.print(F(",\"humidity_pct\":"));
if (isnan(humidity)) {
Serial.print(F("null"));
} else {
Serial.print(humidity, 1);
}
Serial.print(F(",\"uptime_ms\":"));
Serial.print(now);
Serial.println(F("}"));
if (isnan(humidity) || isnan(temperatureC)) {
Serial.println(F("[WARN] Doc cam bien DHT22 that bai - kiem tra day noi hoac dien tro keo len DATA."));
}
}
}
7. Common Issues
Issue | Cause | Fix |
|---|---|---|
Pads don't line up with the part's actual pins during assembly | Wrong measurements, or pad coordinates entered incorrectly | Re-measure with calipers, and enter pad coordinates via the Properties dialog instead of dragging them by eye |
KiCad reports "Duplicate footprint name" | A footprint with that name already exists in the same .pretty library | Rename the new footprint, or check the library before creating it |
The footprint doesn't show up in the Assign Footprints list | The personal library hasn't been added to the project's Footprint Library Table | Go to Preferences → Manage Footprint Libraries and add the path to your .pretty library |
DRC reports a courtyard overlap error even with only one component | The courtyard was drawn in the wrong place, or overlaps its own pads/silkscreen | Redraw the courtyard to properly enclose the component without cutting through any pads |
8. Summary
When the standard footprint library doesn't match the real part you have, don't force yourself to use an approximate footprint — measure it precisely and draw it yourself in the Footprint Editor, following five steps: create a personal library, place pads at the right coordinates, draw the silkscreen and courtyard, set properties and save, then reassign it to the schematic symbol. An accurate custom footprint gets your PCB assembled correctly the first time, without having to redesign the board over misaligned pins.