9. Input Devices
This week focused on input devices: sensors and modules that read information from the physical world and send it to a microcontroller. My assignment was to use an input device, measure and display data from it. I chose a DS3231 Real-Time Clock (RTC) module, which keeps precise track of date and time even when the main circuit is powered off. To connect it to my custom PCB (which I made in week 8), I also had to design and fabricate a small I2C adapter board, since my base PCB didn't include the pull-up resistors that I2C communication requires.
The general workflow this week was:
- Understanding what an input device is and how the I2C communication protocol works.
- Designing an I2C adapter PCB in KiCad (schematic + layout). Following the week 08 workflow.
- Milling & Soldering the adapter
- Setting up the Arduino IDE with the XIAO board library and the RTC DS3231 library.
- Programming and troubleshooting: no communication, COM port issues, and false-positive I2C scan results.
To know more about different input devices and the I2C protocol, check out the group assignment.
Key Concepts
What is an Input Device?
In electronics, devices can be divided into two categories: inputs and outputs. An input device is any sensor or module that gathers data from the physical world and sends it to a microcontroller. Examples include: temperature sensors, buttons, microphones, cameras, light sensors, and clocks. The microcontroller reads that data and decides what to do with it, like turning on a fan when temperature is too high or displaying the current time on a screen.
This is the opposite of an output device (like a motor or LED), which receives a command from the microcontroller and does something in the physical world. A complete project usually has both: inputs that read data, and outputs that react to it.
I2C Adapter PCB
Since my base PCB from week 8 did not include I2C pull-up resistors, I designed a small adapter board in KiCad. This board adds the two 4.7 kΩ resistors on the SDA and SCL lines and breaks out the I2C connector so the DS3231 module can plug directly in. The design and fabrication process followed the same workflow as week 8: KiCad, Gerber2PNG, Mods Project, milling, and soldering.
I2C Adapter Design in KiCad
I designed the adapter from scratch in KiCad. The goal was simple: two pull-up resistors (4.7 kΩ each) connecting SDA and SCL to 3.3 V, plus a connector for the DS3231 module. The schematic defines the electrical connections, and the PCB layout defines the physical position of each component and the copper traces.
Programming
With the adapter board built, the next step was to write code for the XIAO microcontroller to read the time from the DS3231 and print it to the serial monitor. This required setting up Arduino IDE with the right board definition and library, then troubleshooting several communication issues.
Setting Up Arduino IDE
Arduino IDE is a free software that lets you write and upload code to microcontrollers. Before using the XIAO board and the DS3231, two things need to be installed: the XIAO board library (so Arduino IDE recognizes the board and knows how to program it) and the RTClib library (which gives us ready-made functions to talk to the DS3231 without having to write all the I2C communication from scratch).
Learning Outcomes
This week pushed me to understand not just how to follow a process, but why each step matters and what happens when something goes wrong at a component level.
- Always verify component values before soldering: The 4.7 Ω vs 4.7 kΩ mistake cost significant time in desoldering and rework. SMD resistor codes are small and easy to misread. Using a multimeter to verify before placing the component is a habit I will keep from now on.
- Pull-up resistors are not optional for I2C: I now understand why they exist. Without them, the SDA and SCL lines have no defined resting state and communication is impossible or unreliable. The value matters too — too low (4.7 Ω) clamps the line too hard; too high and the signal rise time becomes too slow for the clock speed.
- Driver and port issues are software problems, not hardware failures: When the COM port disappeared, my first instinct was that the board was broken. It wasn't. Learning to use Device Manager and check for driver issues before assuming a hardware fault saved me from unnecessary rework.
- False positives in I2C scanning indicate a signal problem: Seeing random addresses on the scanner is a red flag, not a green one. It means the bus is noisy or the pull-ups are not doing their job. A healthy I2C bus should only show the addresses of real, connected devices.
- Documentation of failures is as important as documentation of successes: Every error I hit this week gave me a deeper understanding of how I2C works than if everything had worked perfectly on the first try.
The sensor is partially working and I will continue troubleshooting the stable communication issue. The I2C adapter board is functional and the infrastructure is in place — it is a wiring or timing issue that remains to be resolved.