Home › Wiring

Wiring guides: modules to Arduino and ESP32

How to connect each module to an Arduino or an ESP32: the pins, a sketch that works, and the same circuit ready to run in your browser. Every table is read off a working project in the lab.

Arduino Nano

L298N motor driver

+12V → + of the 12 V supply · GND → GND · IN1 → D8 · IN2 → D9 ~

Potentiometer

pin 1 → GND · pin 2 → A0 · pin 3 → 5V

Arduino Uno

4×4 keypad

R1 → D9 ~ · R2 → D8 · R3 → D7 · R4 → D6 ~

7-segment display

a → D2 (INT0) (through a 220 Ω resistor) · b → D3 ~ (INT1) (through a 220 Ω resistor) · c → D4 (through a 220 Ω resistor) · d → D5 ~ (through a 220 Ω resistor)

Active buzzer

pin 1 → D8 · pin 2 → GND

HC-SR04 ultrasonic distance sensor

VCC → 5V · TRIG → D9 ~ · ECHO → D10 ~ · GND → GND

HC-SR501 pIR motion sensor

VCC → 5V · OUT → D2 (INT0) · GND → GND

I2C LCD

GND → GND · VCC → 5V · SDA → A4 (SDA) · SCL → A5 (SCL)

LED

pin 1 → D9 ~ (through a 220 Ω resistor) · pin 2 → GND

LM35 temperature sensor

+V_S → 5V · V_out → A0 · GND → GND

Photoresistor

Lead 1 → 5V · Lead 2 → A0

Potentiometer

pin 1 → GND · pin 2 → A0 · pin 3 → 5V

Push button

pin 1 → D9 ~ · pin 2 → GND

Relay module

VCC → 5V · GND → GND · IN → D7 · COM → + of the 5 V supply

RGB LED

R → D9 ~ (through a 220 Ω resistor) · Common − (longest) → GND · G → D10 ~ (through a 220 Ω resistor) · B → D11 ~ (through a 220 Ω resistor)

SG90 hobby servo

GND (brown) → GND · +5 V (red) → 5V · Signal (orange) → D9 ~

Soil moisture sensor

GND → GND · VCC → 5V · AOUT → A0

ESP32

2N2222 nPN transistor

E → GND · B → GPIO23 (through a 1 kΩ resistor)

Active buzzer

pin 1 → GPIO25 · pin 2 → GND

BME280 environment sensor

VIN → 3V3 · GND → GND · SCL → GPIO22 · SDA → GPIO21

DS18B20 temperature sensor

GND → GND · DQ → GPIO4 · VDD → 3V3

HC-SR04 ultrasonic distance sensor

VCC → + of the 5 V supply · TRIG → GPIO5 · ECHO → GPIO18 (through a 1 kΩ resistor) · GND → GND

HX711 load-cell ADC

VCC → + of the 5 V supply · GND → GND · DT → RX2 · SCK → TX2

INA219 current sensor

VIN+ → + of the 12 V supply · VIN− → − of the 12 V supply (through a 24 Ω resistor) · VCC → 3V3 · GND → GND

LED

pin 1 → GPIO26 (through a 220 Ω resistor) · pin 2 → GND

MAX6675 thermocouple module

GND → GND · VCC → 3V3 · SCK → GPIO18 · CS → GPIO5

MAX7219 8-digit display

VCC → + of the 5 V supply · GND → GND · DIN → GPIO23 · CS → GPIO5

N-channel MOSFET

G → GPIO25 (through a 100 Ω resistor) · S → GND

OLED display

GND → GND · VCC (3.3–5 V: regulator on the module) → 3V3 · SCL → GPIO22 · SDA → GPIO21

Potentiometer

pin 1 → 3V3 · pin 2 → GPIO34 · pin 3 → GND

Push button

pin 1 → GPIO4 · pin 2 → GND

WS2812 LED strip

+5V → VIN · DIN (data in) → GPIO5 (through a 330 Ω resistor) · GND → GND