Testing HC-SR04 with XIAO ESP32-C3 using Multimeter
Testing HC-SR04 with XIAO ESP32-C3 using Multimeter
The objective of this assignment is to measure the electrical power consumption of an output device. In this case, a 5V DC motor controlled by a XIAO ESP32-C3 through an L298N driver is analyzed. The motor rotates alternately in both directions every 4 seconds.
The system consists of a DC motor connected to an H-bridge driver (L298N), allowing bidirectional rotation. A microcontroller (XIAO ESP32-C3) controls the motor direction using timed signals.
The following materials and instruments were used to assemble the system and perform the power consumption measurements of the DC motor.
| Instrument | Function |
|---|---|
| Multimeter | Used to measure voltage (parallel) and current (series) |
| DC Power Supply | Provides stable voltage for the motor and driver module |
| Component | Description |
|---|---|
| XIAO ESP32-C3 | Microcontroller used to control motor direction |
| L298N Motor Driver | H-bridge module used to control motor direction and power |
| DC Motor (5V) | Output device used for rotation and power measurement |
| Material | Purpose |
|---|---|
| Protoboard | Used to assemble the circuit without soldering |
| Jumper Wires | Electrical connections between components |
| USB Cable | Used to program and power the XIAO ESP32-C3 |
| Resistors (optional) | Used if needed for signal conditioning or protection |
The system integrates a microcontroller (XIAO ESP32-C3) with an H-bridge driver (L298N) to control the direction of a 5V DC motor. Measurement instruments such as a multimeter and a power supply are used to analyze electrical parameters, including voltage, current, and power consumption.
This program controls a DC motor using an H-bridge driver (L298N) to alternate its rotation direction at fixed time intervals. The motor rotates in one direction for 3 seconds, then reverses its direction for another 3 seconds, creating a continuous oscillating motion.
// DC Motor Bidirectional Control with Time Intervals
const int IN1 = 6; // D4
const int IN2 = 7; // D5
void setup() {
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
}
void loop() {
// Rotate in one direction
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
delay(3000);
// Rotate in opposite direction
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
delay(3000);
}
By alternating digital signals and using time delays, the system achieves bidirectional motion without sensors. This technique is useful in applications requiring repetitive or oscillating movement.
Voltage was measured in parallel across the motor terminals while operating in both directions.
| Rotation Direction | Voltage (V) |
|---|---|
| Clockwise | 3.56 V |
| Counterclockwise | -3.56 V |
The negative voltage indicates a reversal in polarity due to the H-bridge configuration.
Current was measured in series with the motor using a multimeter.
| Rotation Direction | Current (mA) |
|---|---|
| Clockwise | 12.10 mA |
| Counterclockwise | -12.10 mA |
Another output device test was performed using an integrated PCB that includes a XIAO ESP32-C6, an L9110S motor driver, a DC motor output, and an LED. The L9110S works as an H-bridge driver, allowing the microcontroller to control the motor by switching the output polarity applied to the motor terminals.
In this circuit, the motor and LED are used as output devices. The motor response was analyzed using both an oscilloscope and a Fluke 117 multimeter to observe the electrical behavior when the motor turns on and off.
The oscilloscope was used to observe the voltage waveform generated when the motor was turned on and off. The measurement was taken using GND and one of the motor output terminals, allowing the voltage behavior of the motor output to be visualized over time.
This measurement is useful because the motor does not behave as a purely static load. When it starts, stops, or changes state, the output signal can show variations and peaks caused by the switching of the driver and the electrical behavior of the motor.
In the video, the oscilloscope shows how the waveform changes as the motor is activated. The generated signal allows us to identify the voltage variation at the output of the driver during the operation of the motor.
The motor voltage was also measured using a Fluke 117 multimeter. For this measurement, the multimeter probes were placed at both terminals of the motor to read the voltage directly across the output device while it was turned on.
When the motor was activated, the measured voltage was approximately 7.99 V. This value represents the voltage applied to the motor terminals during operation.
Electrical power is calculated using the fundamental formula:
P = V × I
Where:
Converting current to amperes:
12.10 mA = 0.0121 A
Power:
P = 3.56 × 0.0121 = 0.043076 W
Therefore, the motor consumes approximately:
0.043 W (43 mW) in both directions.