Week 09 - Input Devices#

Week 9 focused on input devices, learning to interface sensors with microcontrollers and read data from the physical world.
The aim was to understand different sensor types, signal conditioning, and data acquisition.

This week explored how embedded systems sense and respond to their environment.


Group Assignment#

  • Probe an input device’s analog levels and digital signals

Individual Assignment#

  • Measure something: Add a sensor to a microcontroller board that you have designed and read it

Extra Credit Goals

  • Try multiple sensor types
  • Implement signal processing or filtering

What I Learned#

  • How to select and spec sensors based on electrical constraints — the RCWL-0516’s 4 V minimum supply forced me to think about power domains and level shifting properly
  • The difference between analog and digital sensor outputs at the signal level, not just in theory — seeing them on an oscilloscope made the distinction concrete
  • How to share multiple I²C devices on a single bus, manage addresses, and use interrupt lines so the MCU doesn’t have to poll
  • Why a minimal microcontroller like the ATtiny1624 is a better learning tool for this week than a feature-rich platform — it exposes the real constraints (pull-ups, bus loading, voltage compatibility) instead of hiding them
  • How to split a design across two boards to keep sensor breakouts swappable independently of the MCU board
  • KiCad PCB layout for mixed-signal boards — routing I²C traces with adequate clearances and placing decoupling caps close to power pins

Software Used#

  • Arduino IDE or other development environment
  • Oscilloscope for signal analysis
  • Serial monitor for data visualization
  • Browser + Git for documentation

Weekly Schedule#

DayWhat I Did
WEDLecture on input devices
THUGroup Assignment
FRIIndividual Assignment - Finding Sensors for the Project
SATSAMD-21 Board Design
SUNAttiny Board Design
MONSensor Board Design
TUERegional review

Group Assignment#

Objective#

Use multiple sensors and visualise their output signals using an oscilloscope. The goal was to observe both digital and analog signals and compare their amplitude/logic-level characteristics.

Sensors Tested#

We tested a range of sensors available in the lab, including a rotary encoder and several other input modules. Each was wired up to the oscilloscope probes and signals were captured in real time.

Observations#

  • Rotary encoder — produced a clean quadrature digital signal (two square wave signals called Channel A and Channel B, that are 90° out of phase with each other.). The logic levels toggled between 0 V and the supply voltage . Direction of rotation was readable from the phase relationship between the two channels.
  • Analog sensors — produced continuously varying voltage curves. Amplitude varied with the physical stimulus .
  • Digital sensors — produced discrete HIGH/LOW transitions.
  • We compared signals at different supply voltages (3.3 V vs 5 V logic) and noted how the logic HIGH threshold shifted accordingly.

The oscilloscope exercise gave a concrete feel for signal integrity, noise floors, and the difference between a “clean” digital edge and a slow analog ramp.


Individual Assignment#

First Attempt — SAMD21 Dev Board#

My first plan for this week was to design a custom SAMD21-based development board — a more capable platform that I could also reuse for my final project sensors. I went through the full design process: researched the chip, drew up the schematic, routed the PCB, and got a 3D model I was happy with.

SAMD21 pinout

SAMD21 board schematic

SAMD21 PCB layout

SAMD21 board 3D model

Bill of Materials:

SAMD21 board BOM

Gerber Visualization:

SAMD21 board gerber preview

After completing the board design, I had a discussion with my instructor Saheen. He pointed out that this week’s intent wasn’t about designing a powerful platform — it was about learning to work directly with sensors and input peripherals using a minimal microcontroller. The exercise is about doing embedded systems without the safety net of a feature-rich platform like the XIAO ESP32C6. The SAMD21 design, while complete, was overkill for what Week 9 is actually teaching.

So I scrapped it and started fresh with the ATtiny1624.


Microcontroller — ATtiny1624#

Switched to the ATtiny1624 — a small, cheap, capable AVR microcontroller from Microchip.

ATtiny1624 pinout diagram

ParameterValue
ArchitectureAVR (8-bit)
Flash16 KB
SRAM2 KB
EEPROM256 B
I/O Pins18
ADC12-channel, 10-bit
CommunicationUSART, SPI, TWI (I²C)
Operating Voltage1.8 – 5.5 V
PackageSOIC-14 / VQFN-20
ProgrammingUPDI

The ATtiny1624 hits the sweet spot: small enough to be genuinely constrained, but rich enough in peripherals (hardware I²C, hardware SPI, multiple ADC channels) to interface with real sensors without bit-banging everything.


Sensors Selected#

All three sensors are used as breakout modules (pre-assembled PCBs with the IC, decoupling caps, pull-up resistors, and level shifting already onboard where needed). This is noted where relevant.


1. RCWL-0516 — Microwave Motion Sensor#

RCWL-0516 module pinout diagram

ParameterValue
Detection methodDoppler radar (3.18 GHz microwave)
Supply voltage4 – 28 V (onboard regulator)
Output voltage3.3 V logic (HIGH on motion)
Output typeDigital (active HIGH)
Detection range~5–7 m (configurable)
Module pinsVIN, GND, OUT, CDS (light sensor pad), VREG (3.3 V out)

Pin description (module):

PinFunction
VINPower input — 4 V to 28 V
GNDGround
OUTDigital output — HIGH (~3.3 V) when motion detected
CDSPad for optional LDR (disable in daylight)
3V33.3 V regulated output (usable as logic reference)

⚠️ Level shift note: VIN needs at least 4 V, which means it cannot run directly off a 3.3 V rail. A separate 5 V supply is fed to VIN. The OUT pin is already 3.3 V logic, so it is safe for the ATtiny1624’s GPIO. However, since all sensor data lines are on a shared 3.3 V I²C bus, a logic level shifter is placed between the RCWL OUT line and the ATtiny to keep the power domains cleanly separated and to protect the microcontroller from any transient spikes from the higher-voltage domain.


2. APDS-9960 — Gesture / Proximity / Color / ALS Sensor#

APDS-9960 gesture sensor module

ParameterValue
ManufacturerBroadcom (via SparkFun / similar breakout)
InterfaceI²C (address: 0x39)
Supply voltage3.3 V
Logic level3.3 V
Gestures detectedUP, DOWN, LEFT, RIGHT, FAR, NEAR
Additional modesProximity (0–255), RGBC color, Ambient Light
Module pinsVCC, GND, SDA, SCL, INT

Pin description (module):

PinFunction
VCC3.3 V
GNDGround
SDAI²C data
SCLI²C clock
INTActive-LOW interrupt (fires on gesture/proximity event)

The APDS-9960 communicates over I²C. The INT pin pulls low when an event is ready — this is wired to an interrupt-capable GPIO on the ATtiny1624 so the MCU doesn’t have to poll.


3. VL53L0X — Time-of-Flight Distance Sensor#

VL53L0X Time-of-Flight Distance Sensor module

ParameterValue
ManufacturerSTMicroelectronics
InterfaceI²C (default address: 0x29, up to 400 kHz FAST mode)
Supply voltage3.3 V / 5 V (module has onboard 2.8 V LDO)
Operating voltage3.3 V / 5 V
Operating temperature−20 ℃ – 70 ℃
Logic level3.3 V
Infrared emitter940 nm laser
Ranging modeSingle / continuous / timed
Recommended measure distance30 mm – 1000 mm
Max range~2 m (ambient dependent)
Resolution1 mm
Module pinsVCC, GND, SDA, SCL, XSHUT, GPIO1

Pin description (module):

PinFunction
VCC2.6 V – 5 V (onboard LDO handles regulation)
GNDGround
SDAI²C data
SCLI²C clock
XSHUTActive-LOW shutdown / hardware reset. Pull LOW to disable the device (useful for address remapping when multiple VL53L0X devices are on the same bus)
GPIO1Interrupt output — signals data ready or threshold events

The VL53L0X uses 940 nm invisible laser pulses and measures the time for photons to return. It works on I²C and shares the bus with the APDS-9960. Since both sensors power up to the same default I²C address (VL53L0X = 0x29, APDS = 0x39 — these are actually different, so no conflict here), no address remapping is needed for this setup.

Reference: Seeed Studio — Grove Time of Flight Distance Sensor VL53L0X


Board Design — Split into Two PCBs#

The design was split across two boards for cleanliness:

Board 1 — Sensor Board

  • Connectors/pads for RCWL-0516 module
  • Connectors/pads for APDS-9960 module
  • Connectors/pads for VL53L0X module
  • BSS138 logic level shifter for RCWL OUT line
  • I²C pull-up resistors (4.7 kΩ on SDA and SCL)
  • Decoupling capacitors on power rails

Board 2 — ATtiny1624 Board

  • ATtiny1624 in SOIC-14 package
  • UPDI programming header (1x3: UPDI, VCC, GND)
  • 100 nF + 10 µF decoupling on VCC
  • 3.3 V power input
  • I²C bus connector (SDA, SCL, VCC, GND)
  • GPIO connector for RCWL digital output
  • Status LED + current-limiting resistor

Both boards were designed in KiCad, then fabricated using the lab’s PCB milling process.

KiCad schematic — full sensor + MCU system


Board 1 — Sensor Board (KiCad)#

Sensor board PCB layout

Sensor board 3D view


Board 2 — ATtiny1624 Board (KiCad)#

ATtiny1624 MCU board PCB layout

ATtiny1624 MCU board 3D view


Manufacturing#

(To be filled with process photos and milling parameters after fabrication)

  • Milling machine: Roland MDX-20
  • Substrate: FR1 single-sided copper clad
  • Trace width / clearance: 0.4 mm / 0.4 mm
  • Tool: 1/64" flat end mill (traces), 1/32" flat end mill (outline)
  • Software: Mods CE

Sensor Board#

Bill of Materials:

Sensor board BOM

Gerber Visualization:

Sensor board gerber preview

ATtiny1624 Board#

Bill of Materials:

ATtiny board BOM

Gerber Visualization:

ATtiny board gerber preview


Files#

FileDescription
sensor-board.kicad_schSensor board schematic
sensor-board.kicad_pcbSensor board layout
attiny1624-board.kicad_schMCU board schematic
attiny1624-board.kicad_pcbMCU board layout

Reflections#

  • The initial STM32 idea was over-engineered for this week’s intent. The constraint of using a minimal MCU like the ATtiny1624 actually makes the sensor interfacing problem more interesting — you have to think about bus loading, I²C pull-ups, voltage domains, and interrupt handling explicitly, rather than having a big SDK paper over them.
  • Splitting into two boards keeps the sensor breakout swappable independently of the MCU board — useful if a sensor gets damaged or needs to be replaced.
  • The RCWL’s 4 V minimum supply was the main electrical design challenge this week. The level shifter decision came directly from that constraint.