WEEK 10 – Output Devices
Individual Assignment
Stepper Motor Control Board using XIAO ESP32-C3 and A4988 Driver
This assignment focuses on the design, fabrication, programming, and testing of an output device. For this week, I designed and fabricated a custom PCB to control a 12 V stepper motor using a Seeed Studio XIAO ESP32-C3 and an A4988 motor driver.
The idea of the system is to use a humidity sensor as an input signal. When the sensor detects a specific humidity condition, the XIAO ESP32-C3 activates the stepper motor. The motor is used to move or lift a water container toward a plant pot for a determined amount of time. This time can be adjusted in the code, allowing control over how long the watering mechanism operates.
The board was designed following the same PCB production workflow used in previous assignments: schematic design, PCB layout, fabrication with a 90 watt fiber laser machine, drilling, soldering, continuity testing, programming, and functional validation.
Final output device board for controlling a 12 V stepper motor.
1. Assignment Objective
Main Objective
The main objective of this assignment was to design and fabricate a custom PCB capable of controlling an output device. In this case, the output device is a 12 V stepper motor controlled by an A4988 driver and commanded by a XIAO ESP32-C3.
| Objective | Description |
|---|---|
| Design a custom PCB | Create a board to connect the XIAO ESP32-C3, A4988 driver, sensor input, and motor output. |
| Control an output device | Use a 12 V stepper motor as the main actuator of the system. |
| Use a motor driver | Use the A4988 driver to safely control the stepper motor from the microcontroller. |
| Use an external power source | Power the motor with an external 12 V supply while keeping common ground with the control circuit. |
| Integrate a humidity sensor | Use the sensor signal as a condition to activate the motor. |
| Fabricate the PCB | Use a 90 watt fiber laser machine to engrave the copper board. |
| Program and validate | Use Arduino IDE to program the motor movement and test the complete system. |
2. Project Concept
The project is based on an automated watering concept. A humidity sensor reads the moisture condition. When the sensor detects a value below or above a defined threshold, the XIAO ESP32-C3 sends control signals to the A4988 driver. The driver then activates the 12 V stepper motor. The motor moves the mechanism for a defined time, allowing a water container to be lifted or moved toward a plant pot.
| System Element | Function |
|---|---|
| Humidity sensor | Provides the input signal related to soil or environmental moisture. |
| XIAO ESP32-C3 | Reads the sensor value and decides when the motor should move. |
| A4988 driver | Receives STEP and DIR signals and controls the current sent to the stepper motor. |
| 12 V stepper motor | Acts as the output device that moves the watering mechanism. |
| 12 V external power supply | Provides enough power for the motor operation. |
| Custom PCB | Integrates the control and connection system into a fabricated board. |
3. Materials and Components
The components were selected to build a functional output system. The XIAO ESP32-C3 controls the logic of the system, while the A4988 driver manages the motor power stage. The external 12 V source is necessary because the motor requires more voltage and current than the microcontroller can provide directly.
| Material / Component | Quantity | Purpose |
|---|---|---|
| Seeed Studio XIAO ESP32-C3 | 1 | Main microcontroller used to read the sensor and control the motor driver. |
| A4988 stepper motor driver | 1 | Driver used to control the 12 V stepper motor. |
| 12 V stepper motor | 1 | Output actuator used to move or lift the water container. |
| Humidity sensor | 1 | Input sensor used to activate the motor depending on moisture condition. |
| 12 V external power supply | 1 | Power source for the stepper motor. |
| Copper clad board | 1 | Base material for PCB fabrication. |
| Header pins | As needed | Used to mount the XIAO ESP32-C3 and A4988 driver. |
| Screw terminal blocks | As needed | Used for motor and external power connections. |
| Capacitor | 1 | Recommended between VMOT and GND to stabilize the motor power supply. |
| USB-C cable | 1 | Used to program and power the XIAO ESP32-C3 logic side. |
| Multimeter | 1 | Used to check continuity and verify safe power connections. |
4. Software Used
KiCad
KiCad was used to design the schematic and PCB layout of the custom board. The design included the XIAO ESP32-C3, the A4988 driver connections, the humidity sensor input, the motor connector, and the external 12 V power input.
Arduino IDE
Arduino IDE was used to program the XIAO ESP32-C3. The code reads the humidity sensor and activates the motor for a defined time when the sensor reaches the programmed threshold.
Laser Software
The laser software was used to prepare and send the PCB fabrication file to the 90 watt fiber laser machine.
5. Why a Driver is Needed
The XIAO ESP32-C3 cannot directly power a 12 V stepper motor because its GPIO pins only provide low-current logic signals. For this reason, the A4988 driver is required. The driver receives low-voltage control signals from the microcontroller and uses the external 12 V power supply to energize the motor coils.
| Connection Type | Voltage / Signal | Description |
|---|---|---|
| Logic control | 3.3 V from XIAO ESP32-C3 | STEP, DIR, ENABLE, and other control signals. |
| Motor power | 12 V external source | Power used by the A4988 to drive the motor coils. |
| Common ground | GND shared | The ESP32-C3 ground and 12 V power supply ground must be connected together. |
Important: The motor must not be powered directly from the ESP32-C3. The motor requires an external 12 V supply and must be controlled through the A4988 driver.
6. A4988 Driver Connections
| A4988 Pin | Connection | Purpose |
|---|---|---|
| VMOT | 12 V external power supply positive | Motor power input. |
| GND Motor | 12 V power supply ground | Motor power ground. |
| VDD | 3.3 V from XIAO ESP32-C3 | Logic power for the driver. |
| GND Logic | GND from XIAO ESP32-C3 | Logic ground. |
| STEP | GPIO from XIAO ESP32-C3 | Receives pulses to move the motor step by step. |
| DIR | GPIO from XIAO ESP32-C3 | Controls the direction of motor rotation. |
| ENABLE | GPIO or GND depending on design | Enables or disables the driver output. |
| 1A, 1B, 2A, 2B | Stepper motor coils | Output connections to the motor windings. |
Connection diagram between XIAO ESP32-C3, A4988 driver, and stepper motor.
7. System Logic
The logic of the system is based on a condition. The humidity sensor provides an analog value. If the value crosses the programmed threshold, the XIAO ESP32-C3 activates the motor. The motor rotates for a defined time, which can be adjusted in the code. After the movement time ends, the motor stops.
| Condition | System Response |
|---|---|
| Humidity value does not reach threshold | The motor remains stopped. |
| Humidity value reaches threshold | The motor is activated through the A4988 driver. |
| Motor running time finishes | The motor stops automatically. |
| Threshold or time needs adjustment | The values are modified in the Arduino code. |
8. PCB Design in KiCad
The PCB design started with the schematic in KiCad. The schematic included the XIAO ESP32-C3, the A4988 driver, the humidity sensor connector, the motor connector, and the external 12 V power input connector.
Special attention was required because the board includes both low-voltage logic signals and higher-power motor connections. For this reason, the 12 V power traces and motor output traces were designed with more care and wider routes than normal signal traces.
Schematic Design Steps
- Create a new KiCad project for Week 10.
- Add the XIAO ESP32-C3 symbol.
- Add the A4988 driver module footprint or pin header representation.
- Add a connector for the humidity sensor.
- Add a connector for the 12 V external power supply.
- Add a connector for the stepper motor coils.
- Connect STEP and DIR pins from the XIAO ESP32-C3 to the A4988 driver.
- Connect VDD of the A4988 to 3.3 V.
- Connect VMOT of the A4988 to the 12 V external power input.
- Connect all grounds together.
- Add a capacitor between VMOT and GND for motor supply stabilization.
- Run Electrical Rules Check and correct warnings.
Schematic design of the output device board in KiCad.
9. PCB Layout Design
After validating the schematic, I moved to the PCB layout. The XIAO ESP32-C3 was placed in a position where the USB-C port remained accessible. The A4988 driver was placed with enough space for ventilation and easy connection to the motor and power terminals.
The motor connector and 12 V power connector were placed near the edge of the board. This makes the wiring safer and more organized. The signal traces were separated from the motor power traces to reduce possible electrical noise.
PCB Layout Steps
- Assign footprints for the XIAO ESP32-C3, A4988 driver, connectors, and capacitor.
- Open the PCB editor in KiCad.
- Import all schematic components.
- Place the XIAO ESP32-C3 with USB access.
- Place the A4988 driver in a central and accessible position.
- Place the 12 V input connector near the board edge.
- Place the motor connector near the driver output pins.
- Route STEP, DIR, ENABLE, sensor signal, 3.3 V, and GND.
- Route 12 V and motor traces with wider tracks.
- Check clearance between power and signal traces.
- Run Design Rules Check.
- Export fabrication files.
10. Design Rules and Safety Considerations
| Design Consideration | Application in This Board |
|---|---|
| Separate logic and motor power | 3.3 V logic traces were kept different from 12 V motor power traces. |
| Common ground | The ESP32-C3 ground and external 12 V supply ground were connected together. |
| Wider power traces | Motor power traces were made wider to support higher current. |
| Accessible USB port | The XIAO ESP32-C3 was oriented to allow easy programming. |
| Driver ventilation | Space was left around the A4988 because the driver can heat during operation. |
| External power protection | The polarity of the 12 V input was checked carefully before powering the board. |
Before powering the motor, I verified the polarity of the 12 V supply and confirmed that there was no short circuit between VMOT and GND.
11. Fabrication Equipment: 90 W Fiber Laser Machine
The PCB was fabricated using a 90 watt fiber laser machine. This machine uses a focused laser beam to remove copper from the board and isolate the conductive traces.
Because the board controls a motor, the quality of the traces is very important. Any copper bridge or incomplete isolation can affect the motor driver, the ESP32-C3, or the external power supply.
| Equipment Feature | Description |
|---|---|
| Machine type | Fiber laser engraving machine. |
| Power | 90 watts. |
| Application | PCB engraving and copper isolation. |
| Material | Single-sided copper clad board. |
| Critical parameters | Focus, power, speed, frequency, and number of passes. |
| Safety | Use proper protection, supervise the process, and avoid reflective exposure. |
90 watt fiber laser machine used for PCB fabrication.
12. PCB Fabrication Process
Fabrication Steps
- Export the PCB traces from KiCad.
- Prepare the file for the laser software.
- Clean the copper board surface.
- Place and fix the copper board on the laser bed.
- Import the trace file into the laser software.
- Check the scale, position, and orientation.
- Adjust the focus of the fiber laser.
- Configure laser parameters.
- Run the engraving process.
- Inspect trace isolation and copper removal.
- Repeat the pass if necessary.
- Clean the PCB after engraving.
13. Inspection After Laser Engraving
| Inspection Point | Expected Condition |
|---|---|
| Motor power traces | Complete and properly isolated from other traces. |
| Logic traces | STEP, DIR, ENABLE, and sensor lines must be continuous. |
| 12 V and GND | No short circuit between power and ground. |
| A4988 pads | Pads must be clean and large enough for soldering headers. |
| Board surface | The substrate must not be excessively burned. |
PCB after engraving with the fiber laser machine.
14. Drilling Process
After engraving, I drilled the holes required for the XIAO ESP32-C3 headers, the A4988 driver headers, the sensor connector, the motor connector, and the 12 V power input connector.
Drilling Steps
- Identify all holes required in the PCB.
- Select the correct drill bit for headers and terminals.
- Align the drill with the center of each pad.
- Drill vertically with controlled pressure.
- Clean dust and copper residue.
- Inspect all holes before soldering.
15. Soldering Process
Once the PCB was drilled and cleaned, I soldered the components. I started with the headers and connectors, then mounted the A4988 driver and XIAO ESP32-C3. The screw terminals were soldered for the 12 V input and motor output because these connections must be mechanically strong.
Soldering Steps
- Prepare the soldering iron and solder wire.
- Solder the XIAO ESP32-C3 headers.
- Solder the A4988 driver headers.
- Solder the humidity sensor connector.
- Solder the 12 V input terminal.
- Solder the stepper motor output terminal.
- Solder the capacitor between VMOT and GND.
- Inspect each solder joint.
- Check for solder bridges.
- Clean the board before testing.
| Soldering Check | Description |
|---|---|
| A4988 orientation | The driver must be placed in the correct orientation before powering the board. |
| Power connector polarity | 12 V and GND must be clearly identified. |
| Motor connector | The motor coil wires must be connected to the correct A4988 outputs. |
| Header alignment | The XIAO ESP32-C3 and A4988 headers must be straight and stable. |
| No solder bridges | Adjacent pads must not be accidentally connected. |
Output device board after soldering all components.
16. Continuity and Safety Test
Before connecting the external 12 V source, I tested the PCB with a multimeter. This step was essential because the motor power circuit uses a higher voltage than the logic circuit.
| Test | Expected Result |
|---|---|
| 3.3 V to GND | No short circuit. |
| 12 V VMOT to GND | No short circuit. |
| STEP pin continuity | Connected from XIAO ESP32-C3 to A4988 STEP. |
| DIR pin continuity | Connected from XIAO ESP32-C3 to A4988 DIR. |
| Sensor signal line | Connected from humidity sensor to selected analog input. |
| Motor outputs | Connected from A4988 to motor terminal. |
Continuity and safety test before powering the motor.
17. Arduino IDE Setup
Programming Setup
- Connect the XIAO ESP32-C3 to the computer using a USB-C cable.
- Open Arduino IDE.
- Select the correct ESP32 board package.
- Select the XIAO ESP32-C3 board.
- Select the correct serial port.
- Open a new sketch.
- Write or paste the motor control code.
- Compile the program.
- Upload the code to the board.
- Open the Serial Monitor to observe the sensor values.
Arduino IDE setup for programming the XIAO ESP32-C3.
18. Programming the Stepper Motor System
The code reads the humidity sensor value and compares it with a threshold. If the condition is met,
the motor is activated for a specific amount of time. This time is adjustable by changing the
variable motorRunTime.
const int humidityPin = A0;
const int stepPin = 4;
const int dirPin = 5;
const int enablePin = 6;
int humidityValue = 0;
int humidityThreshold = 500;
unsigned long motorRunTime = 5000;
int stepDelay = 800;
void setup() {
Serial.begin(115200);
delay(1000);
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, HIGH);
digitalWrite(dirPin, HIGH);
Serial.println("Week 10 - Output Devices");
Serial.println("Humidity controlled stepper motor system");
}
void loop() {
humidityValue = analogRead(humidityPin);
Serial.print("Humidity sensor value: ");
Serial.println(humidityValue);
if (humidityValue > humidityThreshold) {
Serial.println("Condition detected. Activating motor...");
runMotorForTime(motorRunTime);
Serial.println("Motor stopped.");
delay(2000);
} else {
digitalWrite(enablePin, HIGH);
}
delay(500);
}
void runMotorForTime(unsigned long duration) {
unsigned long startTime = millis();
digitalWrite(enablePin, LOW);
digitalWrite(dirPin, HIGH);
while (millis() - startTime < duration) {
digitalWrite(stepPin, HIGH);
delayMicroseconds(stepDelay);
digitalWrite(stepPin, LOW);
delayMicroseconds(stepDelay);
}
digitalWrite(enablePin, HIGH);
}
Note: The pins A0, stepPin, dirPin, and enablePin
must be adjusted according to the final PCB design. The humidity threshold and motor running time
must also be calibrated during testing.
19. Adjustable Parameters
| Parameter | Function | How to Adjust |
|---|---|---|
humidityThreshold |
Defines the sensor value required to activate the motor. | Increase or decrease after observing real sensor values. |
motorRunTime |
Defines how long the motor remains active. | Change the value in milliseconds. Example: 5000 = 5 seconds. |
stepDelay |
Controls the speed of the stepper motor. | Lower values increase speed; higher values reduce speed. |
dirPin |
Controls the direction of rotation. | Change HIGH to LOW to reverse the motor direction. |
20. Testing the Output Device
After programming the board, I tested the complete system. First, I powered only the logic side through the USB cable and checked the sensor values in the Serial Monitor. Then, I connected the external 12 V power supply to the motor driver and tested the motor response.
Testing Steps
- Connect the XIAO ESP32-C3 to the computer.
- Open the Serial Monitor at 115200 baud.
- Read the humidity sensor value.
- Adjust the threshold according to the observed values.
- Connect the external 12 V power supply to the board.
- Verify that the A4988 driver is correctly inserted.
- Trigger the humidity condition.
- Observe if the motor starts moving.
- Measure if the motor stops after the programmed time.
- Adjust motor time and speed if necessary.
| Test Condition | Expected Result |
|---|---|
| Sensor value below threshold | The stepper motor remains stopped. |
| Sensor value above threshold | The XIAO ESP32-C3 activates the A4988 driver. |
| Motor activated | The stepper motor rotates and moves the mechanism. |
| Motor running time completed | The motor stops automatically. |
21. Application in the Watering Mechanism
The final application of this output device is related to a watering mechanism for a plant pot. The humidity sensor detects the condition that activates the system. Once the condition is detected, the motor moves for a defined period of time. This movement can be used to lift or position a water container toward the plant pot.
Since the motor running time is adjustable, the amount of movement can be modified depending on the mechanical structure, the distance to move, or the amount of water required.
Concept of the motor-based watering mechanism for a plant pot.
22. Problems and Solutions
| Problem | Possible Cause | Solution |
|---|---|---|
| The motor does not move. | No 12 V power, wrong motor wiring, disabled driver, or wrong pins. | Check power supply, motor coils, STEP/DIR pins, and ENABLE state. |
| The motor vibrates but does not rotate. | Stepper motor coils connected incorrectly. | Identify coil pairs with a multimeter and reconnect them correctly. |
| The A4988 driver heats up. | Current limit not adjusted or insufficient ventilation. | Adjust current limit and allow space for cooling. |
| The ESP32-C3 resets when the motor starts. | Electrical noise or power instability. | Use common ground, add capacitor, and separate motor power from logic power. |
| The sensor does not activate the motor. | Threshold value is not calibrated. | Read real sensor values and adjust the threshold in the code. |
| The PCB has a short circuit. | Copper bridge or solder bridge. | Inspect the board, clean copper residue, and remove unwanted solder. |
23. Results
The final system allowed the XIAO ESP32-C3 to control a 12 V stepper motor through an A4988 driver. The motor was activated based on the humidity sensor reading and moved for a defined amount of time.
This confirmed that the custom PCB worked as an output device board. The board integrated the microcontroller, sensor input, motor driver, external power connection, and motor output into a single fabricated system.
Final working output device board controlling the stepper motor.
24. Download Files
The following buttons can be used to download the project files, including the KiCad design, fabrication files, and Arduino code for the stepper motor control system.
25. Evidence List
| Evidence | Suggested Image Path |
|---|---|
| Final hero shot | images/w10/hero_shot.jpg |
| Materials used | images/w10/materials.jpg |
| A4988 driver | images/w10/a4988_driver.jpg |
| A4988 connection diagram | images/w10/a4988_connections.jpg |
| KiCad schematic | images/w10/kicad_schematic.jpg |
| KiCad PCB layout | images/w10/kicad_pcb_layout.jpg |
| Fiber laser machine | images/w10/fiber_laser_machine.jpg |
| Laser engraving process | images/w10/laser_engraving.jpg |
| Drilling process | images/w10/drilling_process.jpg |
| Soldering process | images/w10/soldering_headers.jpg |
| Continuity test | images/w10/continuity_test.jpg |
| Arduino IDE setup | images/w10/arduino_setup.jpg |
| Motor testing | images/w10/motor_testing.jpg |
| Final working board | images/w10/final_working_board.jpg |
26. Learning Outcomes
Through this assignment, I learned how to:
- Design a custom output device PCB.
- Use the XIAO ESP32-C3 to control an external actuator.
- Connect and control an A4988 stepper motor driver.
- Use an external 12 V power supply safely.
- Understand the difference between logic power and motor power.
- Fabricate a PCB using a 90 watt fiber laser machine.
- Drill, solder, and inspect a custom PCB.
- Use a humidity sensor as a control condition.
- Program a stepper motor movement for an adjustable time.
- Validate the operation of an output device system.
27. Final Reflection
This assignment helped me understand how a microcontroller can control an output device that requires more power than the microcontroller can provide directly. The A4988 driver was necessary to connect the low-power control signals of the XIAO ESP32-C3 with the higher-power requirements of the 12 V stepper motor.
The project also showed the importance of designing the PCB carefully when power and logic signals are combined. The motor power traces, common ground, driver orientation, and external power input must be checked before testing the system.
The final result was a functional output device board that can activate a stepper motor based on a humidity sensor condition, making it useful as a first prototype for an automated plant watering mechanism.
28. Conclusion
In conclusion, this assignment successfully integrated the design, fabrication, assembly, programming, and testing of an output device board. The board used a XIAO ESP32-C3 to read a humidity sensor and activate a 12 V stepper motor through an A4988 driver.
The PCB was fabricated using a 90 watt fiber laser machine and assembled through drilling and soldering processes. The final system demonstrated how an embedded board can control a physical actuator and generate movement in response to sensor data.