WEEK 09 — Input Devices

Testing HC-SR04 with XIAO ESP32-C3 using Multimeter

Group Assignment – Input Devices Analysis

Testing HC-SR04 with XIAO ESP32-C3 using Multimeter

Group Assignment – Measuring Power Consumption of an Output Device

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.

System Description

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.

Materials and Equipment

The following materials and instruments were used to assemble the system and perform the power consumption measurements of the DC motor.

Measurement Instruments
Instrument Function
Multimeter Used to measure voltage (parallel) and current (series)
DC Power Supply Provides stable voltage for the motor and driver module
Main Components
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
Additional Materials
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
System Overview

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.

Workflow

  1. Design and assemble the circuit on a protoboard
  2. Connect the motor to the L298N driver (OUT1 and OUT2)
  3. Upload the control code to the XIAO ESP32-C3
  4. Verify bidirectional motor operation
  5. Measure voltage across the motor terminals (parallel measurement)
  6. Measure current flowing through the motor (series measurement)
  7. Calculate electrical power using measured values

Code Description – Bidirectional DC Motor Control

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.

Code Implementation
// 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);
}
          
Program Logic
Key Concept

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 Measurement

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 Measurement

Current was measured in series with the motor using a multimeter.

Rotation Direction Current (mA)
Clockwise 12.10 mA
Counterclockwise -12.10 mA

PCB Output Device Test with L9110S Driver

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.

PCB with XIAO ESP32-C6, L9110S driver, motor and LED
Integrated PCB with XIAO ESP32-C6, L9110S H-bridge driver, motor output, and LED.

Oscilloscope Measurement

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.

Oscilloscope probes measuring the motor output
Oscilloscope probe connection using GND and one motor output terminal.
Oscilloscope waveform when turning the motor on and off
Waveform observed when the motor output turns on and off.

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.

Multimeter Voltage Measurement

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.

Fluke 117 multimeter measuring 7.99V across the motor terminals
Voltage measurement across the motor terminals using the Fluke 117 multimeter.

Additional Results

Power Calculation

Electrical power is calculated using the fundamental formula:

P = V × I

Where:

Calculation

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.