Battery-Powered Arduino Mega and ESP32-Based Robotic Controller
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This document provides a detailed overview of a circuit designed to interface various electronic components, including microcontrollers, sensors, motor drivers, and power management modules. The primary microcontroller in the circuit is an Arduino Mega 2560, which is responsible for controlling the peripherals and managing the input/output operations. An ESP32 microcontroller is also included, likely for wireless communication or dual-operation purposes. The circuit features motor control with feedback from integrated encoders, distance measurement using an ultrasonic sensor, and line detection with a reflectance sensor array. Power management is handled by a combination of lithium battery charging, protection boards, and voltage regulators to ensure stable operation.
Component List
Microcontrollers
- Arduino Mega 2560: A microcontroller board based on the ATmega2560, with a wide range of input/output pins.
- ESP32 (30 pin): A microcontroller with Wi-Fi and Bluetooth capabilities, featuring a variety of GPIOs.
Sensors
- HC-SR04 Ultrasonic Sensor: A sensor for measuring distances using ultrasonic waves.
- QTRX-HD-07RC Reflectance Sensor Array: A sensor array used for line detection or following.
Motors and Drivers
- Gear Motor with integrated Encoder: A motor that provides rotational movement with feedback from an integrated encoder.
- Motor Driver 1A Dual TB6612FNG: A motor driver capable of driving two motors with up to 1A per channel.
Power Management
- 18650 Li-ion Battery: A rechargeable lithium-ion battery commonly used in portable electronics.
- Lithium Battery Charging Board Type-C: A charging board for lithium batteries with a USB Type-C input.
- 2S lithium battery protection board module: A protection module for 2-series lithium battery configurations.
- Buck Converter, Adjustable Regulator: A voltage regulator that steps down voltage to a desired level.
- Step Up Boost Power Converter, Adjustable Voltage Regulator: A voltage regulator that steps up voltage to a desired level.
Switches and Indicators
- rocker switch: A simple on/off switch to control the power flow in the circuit.
Passive Components
- Resistor: A passive two-terminal electrical component that implements electrical resistance as a circuit element.
Wiring Details
Arduino Mega 2560
- VIN: Connected to the VIN of ESP32 and OUT- of Buck Converter.
- GND: Common ground with ESP32, Resistor, and Buck Converter.
- D17 PWM/RX2: Connected to TX2 of ESP32.
- D5 PWM: Connected to PWMB of Motor Driver.
- D25: Connected to BIN2 of Motor Driver.
- D24: Connected to BIN1 of Motor Driver.
- 5V: Connected to STBY of Motor Driver, VCC of QTRX-HD-07RC Reflectance Sensor Array, and VCC of HC-SR04 Ultrasonic Sensor.
- D22: Connected to AIN1 of Motor Driver.
- D23: Connected to AIN2 of Motor Driver.
- D4 PWM: Connected to PWMA of Motor Driver.
- D2 PWM: Connected to Encoder A of Gear Motor with integrated Encoder.
- D3 PWM: Connected to Encoder B of Gear Motor with integrated Encoder.
- D19/RX1: Connected to Encoder A of another Gear Motor with integrated Encoder.
- D18/TX1: Connected to Encoder B of another Gear Motor with integrated Encoder.
- D42, D36, D41, D37, D40, D38, D39: Connected to pins 7, 1, 6, 2, 5, 3, 4 of QTRX-HD-07RC Reflectance Sensor Array respectively.
ESP32 (30 pin)
- Vin: Connected to VIN of Arduino Mega 2560 and OUT- of Buck Converter.
- GND: Common ground with Arduino Mega 2560, Resistor, and Buck Converter.
- D15: Connected to Resistor.
- RX2: Connected to Resistor.
- TX2: Connected to D17 PWM/RX2 of Arduino Mega 2560.
- D18: Connected to TRIG of HC-SR04 Ultrasonic Sensor.
- D19: Connected to Resistor.
Gear Motor with integrated Encoder
- MOTOR -: Connected to B01 of Motor Driver.
- MOTOR+: Connected to B02 of Motor Driver.
- Encoder -: Common ground with Motor Driver, Arduino Mega 2560, QTRX-HD-07RC Reflectance Sensor Array, and HC-SR04 Ultrasonic Sensor.
- Encoder A: Connected to D2 PWM of Arduino Mega 2560.
- Encoder B: Connected to D3 PWM of Arduino Mega 2560.
Motor Driver 1A Dual TB6612FNG
- GND: Common ground with Arduino Mega 2560, Gear Motor with integrated Encoder, QTRX-HD-07RC Reflectance Sensor Array, HC-SR04 Ultrasonic Sensor, Buck Converter, and Step Up Boost Power Converter.
- B01: Connected to MOTOR - of Gear Motor with integrated Encoder.
- B02: Connected to MOTOR+ of Gear Motor with integrated Encoder.
- A02: Connected to MOTOR - of another Gear Motor with integrated Encoder.
- A01: Connected to MOTOR+ of another Gear Motor with integrated Encoder.
- VCC: Connected to 5V of Arduino Mega 2560.
- VM: Connected to IN+ of Buck Converter and VOUT+ of Step Up Boost Power Converter.
- PWMA: Connected to D4 PWM of Arduino Mega 2560.
- AIN2: Connected to D23 of Arduino Mega 2560.
- AIN1: Connected to D22 of Arduino Mega 2560.
- STBY: Connected to 5V of Arduino Mega 2560.
- BIN1: Connected to D24 of Arduino Mega 2560.
- BIN2: Connected to D25 of Arduino Mega 2560.
- PWMB: Connected to D5 PWM of Arduino Mega 2560.
HC-SR04 Ultrasonic Sensor
- VCC: Connected to 5V of Arduino Mega 2560.
- TRIG: Connected to D18 of ESP32.
- ECHO: Connected to Resistor.
- GND: Common ground with Motor Driver, Arduino Mega 2560, Gear Motor with integrated Encoder, and QTRX-HD-07RC Reflectance Sensor Array.
QTRX-HD-07RC Reflectance Sensor Array
- GND: Common ground with Motor Driver, Arduino Mega 2560, Gear Motor with integrated Encoder, and HC-SR04 Ultrasonic Sensor.
- VCC: Connected to 5V of Arduino Mega 2560.
- 7, 1, 6, 2, 5, 3, 4: Connected to D42, D36, D41, D37, D40, D38, D39 of Arduino Mega 2560 respectively.
Power Management Components
- Buck Converter, Adjustable Regulator: IN- connected to GND of Motor Driver, IN+ connected to VM of Motor Driver.
- Step Up Boost Power Converter, Adjustable Voltage Regulator: VOUT- connected to GND of Motor Driver, VOUT+ connected to VM of Motor Driver, VIN- connected to Resistor, VIN+ connected to Resistor.
- Lithium Battery Charging Board Type-C: GND connected to Resistor, BAT connected to P+ of 2S lithium battery protection board module.
- 2S lithium battery protection board module: P- connected to Resistor, B- connected to - of 18650 Li-ion Battery, BM connected to - of another 18650 Li-ion Battery and + of a different 18650 Li-ion Battery, B+ connected to + of another 18650 Li-ion Battery.
Resistor
- Multiple resistors are used in the circuit, connected to various components such as ESP32, HC-SR04 Ultrasonic Sensor, and power management modules.
Documented Code
Arduino Mega 2560 Code (sketch.ino)
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Note: The provided code for the Arduino Mega 2560 is a template with empty setup and loop functions. The actual functionality needs to be implemented based on the requirements of the circuit.
ESP32 Code
No code was provided for the ESP32 microcontroller. It is assumed that the ESP32 will be programmed separately with its specific functionality, such as handling wireless communication or additional processing tasks.