WEEK 09 – Input Devices

Individual Assignment

Water Level Sensor Board using XIAO ESP32-C3

This assignment focuses on the design, fabrication, programming, and testing of an input device. For this week, I designed and fabricated my own PCB based on the reference of the FabXiao, using a Seeed Studio XIAO ESP32-C3 as the main microcontroller.

The purpose of this project was to create a board capable of reading data from a water level sensor. The sensor generates a signal when it is inserted into water, allowing the microcontroller to detect the presence or level of water and display the information through the Arduino IDE Serial Monitor.

The board was designed to connect the sensor to the XIAO ESP32-C3, process the analog signal, and provide readable values that can be used for future applications such as water monitoring, tank level detection, environmental sensing, or automated systems.

Final water level sensor board with XIAO ESP32-C3

Final board for input device testing with a water level sensor and XIAO ESP32-C3.

1. Assignment Objective

Main Objective

The main objective of this assignment was to design and fabricate a custom PCB that can read data from an input device. In this case, the input device is a water level sensor connected to an ESP32 XIAO C3 microcontroller.

Objective Description
Design a custom PCB Create my own board based on the FabXiao reference.
Use an input sensor Connect a water level sensor to detect contact with water.
Use the XIAO ESP32-C3 Control and read the sensor data using the ESP32 XIAO C3.
Fabricate the PCB Use a 90 watt fiber laser machine to produce the circuit board.
Program the board Use Arduino IDE to read and display sensor values.
Validate the input device Test the sensor in dry and wet conditions to observe changes in readings.

2. Project Concept

The project consists of a water level sensing system. When the sensor is outside water, the microcontroller reads a low or baseline value. When the sensor is inserted into water, the electrical behavior of the sensor changes and the XIAO ESP32-C3 receives a different signal. This change is interpreted as the presence of water.

Water Level Sensor → Custom PCB → XIAO ESP32-C3 → Arduino IDE Serial Monitor → Sensor Data
System Element Function
Water level sensor Detects contact with water and generates an input signal.
Custom PCB Provides electrical connections between the sensor and the XIAO ESP32-C3.
XIAO ESP32-C3 Reads the sensor signal and processes the input data.
Arduino IDE Used to program the microcontroller and observe the sensor readings.
Serial Monitor Displays the analog values and water detection status.

3. Materials and Components

The following materials were used to complete the input devices assignment. These components were selected to allow the design, fabrication, assembly, and testing of a functional board capable of reading a water level sensor.

Material / Component Quantity Purpose
Seeed Studio XIAO ESP32-C3 1 Main microcontroller used to read and process sensor values.
Water level sensor 1 Input device used to detect water presence or level.
Copper clad board 1 Base material for the custom PCB.
Header pins As needed Used to connect the XIAO ESP32-C3 and sensor to the board.
Jumper wires As needed Used for temporary tests and external connections.
Solder wire As needed Used to fix electronic components to the PCB.
USB-C cable 1 Used to program and power the XIAO ESP32-C3.
Water container 1 Used to test the sensor response when inserted into water.
Multimeter 1 Used to verify continuity and detect possible short circuits.
Materials for input devices assignment Water level sensor

4. Software Used

Arduino IDE

Arduino IDE was used to program the XIAO ESP32-C3 and read the data obtained from the water level sensor. The Serial Monitor was used to display the sensor values in real time.

KiCad

KiCad was used to design the schematic and PCB layout of the custom input board. The board was created using the FabXiao as a design reference.

Laser Software

The laser software was used to prepare and send the PCB design to the 90 watt fiber laser machine for fabrication.

Arduino IDE for input device programming

Arduino IDE used to program and monitor the water level sensor readings.

5. Reference Board: FabXiao

For this assignment, the FabXiao was used as a design reference. This helped me understand how the XIAO microcontroller can be integrated into a custom PCB and how to organize the connections for power, ground, and input/output pins.

The objective was not only to copy the reference board, but to use it as a starting point to develop my own input device board. I adapted the concept to include the connection for a water level sensor and the necessary pins for reading the sensor signal.

FabXiao Reference Element How It Was Used in My Design
XIAO footprint Used as a reference to correctly place and connect the XIAO ESP32-C3.
Power pins Used to organize 3.3V and GND connections for the sensor.
GPIO pins Used to select a suitable analog input pin for the water level sensor.
Compact board layout Used as a guide to create a small and functional custom PCB.
FabXiao reference board

FabXiao reference used as a starting point for my custom input device board.

6. Water Level Sensor Explanation

The water level sensor is an input device that changes its output signal when it comes into contact with water. The sensor usually has conductive tracks that interact with the water. When water touches the sensing area, the electrical resistance changes and the sensor produces a measurable analog signal.

The XIAO ESP32-C3 reads this signal through an analog input pin. The value can be observed in the Serial Monitor. When the sensor is dry, the value is low or close to a baseline. When the sensor is inserted into water, the value increases or changes depending on the amount of contact.

Sensor Condition Expected Reading Interpretation
Sensor dry Low or baseline analog value No water detected.
Sensor partially in water Medium analog value Water is detected at a low or medium level.
Sensor inserted deeper in water Higher analog value Greater water contact or higher level detected.

Important: The water level sensor should be used carefully. Only the sensing area should be inserted into water. The electronic connections and the microcontroller must remain dry.

7. Board Design in KiCad

The PCB design process started in KiCad. First, I created the schematic by placing the XIAO ESP32-C3 and the connector for the water level sensor. The sensor requires power, ground, and a signal connection to an analog input pin of the microcontroller.

The schematic was designed to keep the circuit simple, functional, and easy to fabricate. Since the objective of the assignment was to read an input device, the most important connection was the signal line between the sensor and the analog input pin.

Schematic Design Steps

  1. Create a new KiCad project for Week 09.
  2. Add the XIAO ESP32-C3 symbol.
  3. Add a connector for the water level sensor.
  4. Connect the sensor VCC pin to 3.3V.
  5. Connect the sensor GND pin to GND.
  6. Connect the sensor signal pin to an analog input pin of the XIAO ESP32-C3.
  7. Add labels to make the schematic easier to understand.
  8. Run the Electrical Rules Check.
  9. Correct warnings or unconnected pins.
KiCad schematic for water level sensor board

Schematic design of the input device board in KiCad.

8. PCB Layout Design

After validating the schematic, I moved to the PCB layout. The XIAO ESP32-C3 footprint was placed in a central and accessible position so that the USB-C port could be reached easily for programming. The connector for the water level sensor was placed near the edge of the board to simplify the connection with the sensor.

The traces were routed with enough width and separation to be fabricated with the fiber laser process. The board outline was also defined according to the size required for the circuit.

PCB Layout Steps

  1. Assign footprints to the XIAO ESP32-C3 and sensor connector.
  2. Open the PCB editor in KiCad.
  3. Import the components from the schematic.
  4. Place the XIAO ESP32-C3 footprint.
  5. Place the sensor connector near the board edge.
  6. Route the 3.3V, GND, and signal traces.
  7. Verify trace width and clearance.
  8. Define the board outline.
  9. Run the Design Rules Check.
  10. Export the fabrication files.
PCB layout for input device board 3D view of the input device PCB

9. Design Rules and Considerations

Design Consideration Application in This Board
Analog input selection The sensor signal was connected to a pin capable of reading analog values.
3.3V logic The XIAO ESP32-C3 works with 3.3V logic, so the sensor connection must be compatible.
Trace width Traces were designed wide enough to be fabricated using the fiber laser.
Trace clearance A safe separation was maintained to avoid short circuits after engraving.
Connector placement The sensor connector was placed near the edge for easy access.
USB access The XIAO ESP32-C3 was oriented so the USB-C port remained accessible.

10. Fabrication Equipment: 90 W Fiber Laser Machine

The PCB was fabricated using a 90 watt fiber laser machine. This equipment uses a focused laser beam to remove material from the copper surface of the board. In this case, the laser was used to isolate the copper traces and create the electrical paths of the PCB.

The fiber laser is especially useful for working with metallic surfaces because it can engrave and remove thin layers of copper with precision. However, the parameters must be adjusted carefully to avoid burning the substrate or damaging the copper traces.

Equipment Feature Description
Machine type Fiber laser engraving machine.
Power 90 watts.
Application PCB copper engraving and trace isolation.
Material Single-sided copper clad board.
Important parameters Power, speed, frequency, focus, and number of passes.
Safety Use appropriate protection, avoid reflective exposure, and supervise the engraving process.
90 watt fiber laser machine for PCB fabrication

90 watt fiber laser machine used to fabricate the input device PCB.

11. PCB Fabrication Process

Fabrication Steps

  1. Export the PCB trace design from KiCad.
  2. Prepare the file for the laser software.
  3. Clean the copper board before engraving.
  4. Place the copper board on the laser bed.
  5. Fix the board to avoid movement.
  6. Import the trace file into the laser software.
  7. Check the scale and orientation of the design.
  8. Adjust the focus height of the fiber laser.
  9. Configure the laser parameters.
  10. Run the engraving process.
  11. Inspect the copper removal.
  12. Repeat the pass if necessary.
Fabrication Stage Purpose Risk to Control
Cleaning the copper board Remove grease and dust before engraving. Poor engraving quality if the surface is dirty.
Focusing the laser Ensure that the laser energy is concentrated on the copper surface. Incomplete copper removal if focus is incorrect.
Engraving traces Remove copper to isolate the electrical paths. Burned substrate or broken traces.
Inspection Verify that there are no copper bridges or broken paths. Short circuits or open circuits.
Laser setup for PCB engraving PCB engraving with fiber laser

12. Inspection After Laser Engraving

After the engraving process, I inspected the PCB to confirm that the traces were clearly defined. This step was essential because a small copper bridge can create a short circuit, while an incomplete trace can prevent the sensor from working.

Inspection Point Expected Condition
Trace continuity The signal, VCC, and GND traces must be complete.
Isolation between traces There must be no unwanted copper bridges.
Pad condition The pads must remain large enough for soldering and drilling.
Board surface The substrate should not be excessively burned.
Engraved PCB for water level sensor

PCB after engraving with the fiber laser machine.

13. Drilling Process

After engraving, I drilled the holes required for the XIAO ESP32-C3 headers and the water level sensor connector. The drilling process was performed carefully to avoid damaging the pads.

Drilling Steps

  1. Identify the pads that require holes.
  2. Select the correct drill bit according to the pin diameter.
  3. Align the drill with the center of each pad.
  4. Drill vertically with controlled pressure.
  5. Remove dust and debris from the board.
  6. Inspect the drilled holes.
Possible Issue Cause Prevention
Pad lifting Too much pressure during drilling. Use a sharp drill bit and apply controlled pressure.
Misaligned hole The drill was not centered on the pad. Align carefully before drilling.
Damaged trace The hole was too close to the trace. Leave enough clearance during PCB design.
Drilling the input device PCB PCB after drilling

14. Soldering the Board

Once the board was engraved and drilled, I soldered the components. The main soldered parts were the header pins for the XIAO ESP32-C3 and the connector for the water level sensor.

During soldering, I checked that there were no solder bridges between adjacent pads and that each joint was mechanically stable and electrically connected.

Soldering Steps

  1. Prepare the soldering iron and solder wire.
  2. Place the header pins for the XIAO ESP32-C3.
  3. Solder the header pins carefully.
  4. Place the sensor connector.
  5. Solder the sensor connector pads.
  6. Inspect each solder joint.
  7. Check for solder bridges.
  8. Clean the board after soldering.
Soldering Check Description
Header alignment The XIAO ESP32-C3 headers must be straight and aligned.
Sensor connector The connector must be stable and correctly soldered.
Solder bridges No accidental connection between neighboring pads.
Cold joints Solder joints must be shiny and firm.
Soldering headers Soldering sensor connector
Final soldered water level sensor board

Input device board after soldering the components.

15. Continuity Test

Before connecting the board to the computer, I used a multimeter to test continuity. This helped me verify that the PCB was safe to power and that the sensor connections were correct.

Test Expected Result
3.3V line The sensor VCC pin must connect to the 3.3V pin of the XIAO ESP32-C3.
GND line The sensor GND pin must connect to the board ground.
Signal line The sensor signal pin must connect to the selected analog input pin.
Short circuit test There should be no short circuit between 3.3V and GND.
Continuity test with multimeter

Continuity test before powering the board.

16. Arduino IDE Setup

The board was programmed using Arduino IDE. Before uploading the code, I selected the correct board and port for the XIAO ESP32-C3. The Serial Monitor was configured to display the sensor readings.

Arduino IDE Setup Steps

  1. Connect the XIAO ESP32-C3 to the computer using a USB-C cable.
  2. Open Arduino IDE.
  3. Select the correct ESP32 board package.
  4. Select the XIAO ESP32-C3 board.
  5. Select the correct serial port.
  6. Open a new sketch.
  7. Write or paste the sensor reading code.
  8. Compile the code.
  9. Upload the code to the board.
  10. Open the Serial Monitor.
Arduino IDE setup for XIAO ESP32-C3

Arduino IDE setup for programming the XIAO ESP32-C3.

17. Programming the Water Level Sensor

The program reads the analog value from the water level sensor and prints the result in the Serial Monitor. A threshold value is used to determine whether water is detected or not.

The threshold can be adjusted after testing because the sensor value may change depending on the amount of water, the sensor type, and the quality of the electrical connection.

const int sensorPin = A0;
int sensorValue = 0;
int threshold = 500;

void setup() {
  Serial.begin(115200);
  delay(1000);

  Serial.println("Week 09 - Input Devices");
  Serial.println("Water Level Sensor Test with XIAO ESP32-C3");
}

void loop() {
  sensorValue = analogRead(sensorPin);

  Serial.print("Sensor value: ");
  Serial.print(sensorValue);

  if (sensorValue > threshold) {
    Serial.println("  | Water detected");
  } else {
    Serial.println("  | No water detected");
  }

  delay(500);
}

Note: The pin A0 must be adjusted according to the analog pin used in the final PCB design. The threshold value must also be calibrated after observing the real sensor readings.

18. Testing the Sensor

After uploading the code, I opened the Serial Monitor and observed the sensor readings. First, I tested the sensor in dry condition. Then, I inserted the sensing area into water and observed how the values changed.

Testing Steps

  1. Connect the board to the computer.
  2. Open the Serial Monitor at 115200 baud.
  3. Observe the value with the sensor dry.
  4. Insert only the sensing area of the sensor into water.
  5. Observe the change in analog readings.
  6. Adjust the threshold value if necessary.
  7. Repeat the test several times to confirm stable behavior.
Test Condition Expected Result Observation
Sensor dry Low analog value The Serial Monitor should display “No water detected”.
Sensor partially inserted in water Medium analog value The reading should increase compared to the dry condition.
Sensor inserted deeper in water Higher analog value The Serial Monitor should display “Water detected”.
Dry sensor test Water level sensor inserted in water
Serial Monitor showing water sensor readings

Serial Monitor showing the analog values from the water level sensor.

19. Data Interpretation

The values obtained from the water level sensor represent the electrical response of the sensor. These readings allow the microcontroller to determine whether water is present or not.

The most important part of this process was comparing the sensor value in different conditions. By observing the dry and wet values, I could define a threshold that separates the “No water” state from the “Water detected” state.

Reading Type Meaning Action
Low value The sensor is dry or has very little contact with water. Display “No water detected”.
Medium value The sensor has partial contact with water. Indicate initial water detection.
High value The sensor has greater contact with water. Display “Water detected”.

20. Problems and Solutions

Problem Possible Cause Solution
The sensor value does not change. Wrong signal pin, damaged sensor, or incorrect wiring. Check the sensor connector, verify the analog pin, and test the sensor with jumper wires.
The readings are unstable. Poor connection, water movement, or noise in the signal. Check solder joints, secure the sensor, and average several readings in the code.
The board is not detected by the computer. USB cable, driver, or board selection issue. Use a data USB cable, install drivers if needed, and select the correct board and port.
There is a short circuit. Copper bridge or solder bridge between traces. Inspect the board, clean copper residues, and remove solder bridges.
The laser engraving is incomplete. Incorrect focus, low power, or high speed. Adjust focus and laser parameters, then repeat the engraving process.

21. Results

The final board was able to read data from the water level sensor using the XIAO ESP32-C3. The sensor values were displayed in the Arduino IDE Serial Monitor.

When the sensor was dry, the readings remained in a lower range. When the sensing area was inserted into water, the readings changed, allowing the microcontroller to identify the presence of water.

This confirmed that the board was working as an input device system and that the XIAO ESP32-C3 was able to receive, process, and display sensor data.

Final working input device board

Final working board reading data from the water level sensor.

22. Download Files

The following buttons can be used to download the project files, including the KiCad design, fabrication files, and Arduino code for the water level sensor test.

23. Evidence List

Evidence Suggested Image Path
Final hero shot images/w09/hero_shot.jpg
Materials used images/w09/materials.jpg
Water level sensor images/w09/water_level_sensor.jpg
FabXiao reference images/w09/fabxiao_reference.jpg
KiCad schematic images/w09/kicad_schematic.jpg
KiCad PCB layout images/w09/kicad_pcb_layout.jpg
Fiber laser machine images/w09/fiber_laser_machine.jpg
Laser engraving process images/w09/laser_engraving.jpg
Drilling process images/w09/drilling_process.jpg
Soldering process images/w09/soldering_headers.jpg
Sensor test in water images/w09/water_sensor_test.jpg
Serial Monitor readings images/w09/serial_monitor_values.jpg
Final working board images/w09/final_working_board.jpg

24. Learning Outcomes

Through this assignment, I learned how to:

25. Final Reflection

This assignment helped me understand how a physical variable can be converted into digital data using an input device. In this case, the physical variable was the presence or level of water, and the sensor transformed that condition into an electrical signal that the XIAO ESP32-C3 could read.

Designing my own PCB based on the FabXiao reference allowed me to connect the theory of electronic design with the practical needs of sensor integration. The fabrication process with the 90 watt fiber laser machine also showed the importance of correct trace spacing, pad size, and careful inspection after engraving.

The final result was a custom board that successfully reads data from a water level sensor and displays the information in Arduino IDE.

26. Conclusion

In conclusion, this assignment successfully integrated the design, fabrication, assembly, programming, and testing of an input device board. The board was designed using the FabXiao as a reference, fabricated with a 90 watt fiber laser machine, soldered manually, and programmed using Arduino IDE.

The water level sensor responded when inserted into water, generating values that could be read by the XIAO ESP32-C3. This confirmed that the custom PCB works correctly as an input device system.