ESP8266-Controlled Gearmotor System with L298N Driver and Ultrasonic Sensing
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to control multiple DC gearmotors using an L298N DC motor driver, with power supplied by an 18650 Li-Ion battery. The system is managed by an ESP8266 NodeMCU microcontroller, which also interfaces with an HC-SR04 Ultrasonic Sensor for distance measurement. Relay modules are used to switch the gearmotors on and off. The circuit appears to be part of a robotic or automated system where precise control of motors and distance sensing is required.
Component List
Gearmotor DC / Motorreductor
- Description: A DC gearmotor used for providing mechanical motion.
- Pins: Pin1, Pin2
18650 Li-Ion Battery
- Description: A rechargeable lithium-ion battery used as a power source.
- Pins: Positive, Negative
L298N DC Motor Driver
- Description: A motor driver module capable of driving up to four DC motors.
- Pins: OUT1, OUT2, 12V, GND, 5V, OUT3, OUT4, 5V-ENA-JMP-I, 5V-ENA-JMP-O, +5V-J1, +5V-J2, ENA, IN1, IN2, IN3, IN4, ENB
ESP8266 NodeMCU
- Description: A microcontroller board with Wi-Fi capability.
- Pins: D0, D1, D2, D3, D4, 3V3, GND, D5, D6, D7, D8, RX, TX, A0, RSV, SD3, SD2, SD1, CMD, SD0, CLK, EN, RST, VIN
HC-SR04 Ultrasonic Sensor
- Description: An ultrasonic sensor used for measuring distances.
- Pins: VCC, TRIG, ECHO, GND
Relay 4 Channel 5V
- Description: A 4-channel relay module for controlling high power devices.
- Pins: GND, IN1, IN2, IN3, IN4, VCC, COM1, COM2, COM3, COM4, NO1, NO2, NO3, NO4, NC1, NC2, NC3, NC4
Wiring Details
Gearmotor DC / Motorreductor
- Pin1: Connected to the normally open (NO) contacts of the relay module.
- Pin2: Connected to the ground (GND) net, which includes the ground of the L298N motor driver, relay module, ESP8266 NodeMCU, and the negative terminal of the 18650 Li-Ion battery.
18650 Li-Ion Battery
- Positive: Connected to the 12V input of the L298N motor driver and the common (COM) contacts of the relay module.
- Negative: Connected to the ground (GND) net.
L298N DC Motor Driver
- OUT1, OUT2, OUT3, OUT4: Connected to the input (IN) pins of the relay module.
- 12V: Connected to the positive terminal of the 18650 Li-Ion battery.
- GND: Connected to the ground (GND) net.
- 5V: Connected to the VCC of the relay module and VIN of the ESP8266 NodeMCU.
- ENA, ENB: Connected to digital pins D1 and D6 of the ESP8266 NodeMCU, respectively.
- IN1, IN2, IN3, IN4: Connected to digital pins D2, D3, D4, and D5 of the ESP8266 NodeMCU, respectively.
ESP8266 NodeMCU
- D0, D8: Connected to the ECHO and TRIG pins of the HC-SR04 Ultrasonic Sensor, respectively.
- 3V3: Connected to the VCC of the HC-SR04 Ultrasonic Sensor.
- GND: Connected to the ground (GND) net.
- VIN: Connected to the 5V output of the L298N motor driver.
- D1, D2, D3, D4, D5, D6, D7: Connected to the ENA, IN1, IN2, IN3, IN4, ENB, and a gearmotor, respectively.
HC-SR04 Ultrasonic Sensor
- VCC: Connected to the 3V3 pin of the ESP8266 NodeMCU.
- TRIG: Connected to the D8 pin of the ESP8266 NodeMCU.
- ECHO: Connected to the D0 pin of the ESP8266 NodeMCU.
- GND: Connected to the ground (GND) net.
Relay 4 Channel 5V
- GND: Connected to the ground (GND) net.
- IN1, IN2, IN3, IN4: Connected to the OUT1, OUT2, OUT4, OUT3 of the L298N motor driver, respectively.
- VCC: Connected to the 5V output of the L298N motor driver.
- COM1, COM2, COM3, COM4: Connected to the positive terminal of the 18650 Li-Ion battery.
- NO1, NO2, NO3, NO4: Connected to the Pin1 of different gearmotors.
Documented Code
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Note: The provided code is a template and does not contain any functional code. It needs to be populated with the logic to control the motors via the L298N driver, read the ultrasonic sensor, and manage the relay states based on the application requirements.