UAT 204 Microcontrollers and Embedded Systems
Worksheet 4 Connecting a sensor and sending serial data
Objective
Read a sensor over I2C, analyse bus signals, send checksummed frames over UART and identify DroneCAN device settings
Equipment and materials
- Pico 2 board
- I2C sensor such as the training board's barometer or IMU
- Logic analyzer
- USB-UART adapter
- Computer with Python
- ArduPilot DroneCAN documentation
Safety
- Low-voltage bench work; check the sensor's logic level matches 3.3 V before connecting
- Share ground between the board and the USB-UART adapter
Steps
- Connect the I2C sensor, scan the bus for addresses and read values
- Capture SDA and SCL; identify start, address, ACK and data
- Send Example 2 frames over UART to the computer
- Write a receiver that checks the checksum
- Set a wrong baud rate on one side; observe and explain
- Study ArduPilot's DroneCAN page and list the parameters for a DroneCAN GPS
Record of results
| Address found (hex) | Device per datasheet | Reading (with unit) | Plausible? |
|---|---|---|---|
| Signal part | Value read (hex) | Time taken (µs) | Meaning |
|---|---|---|---|
| Test case | Baud sender / receiver | Bytes received (hex) | Checksum result | Explanation |
|---|---|---|---|---|
Questions
How many bytes is the Example 2 frame, how long does one frame take at your baud rate in µs, and what share of the link does it use if sent every 100 ms?
With mismatched baud rates, what did the received data look like, and why does the checksum let the receiver know the data is unusable?
Does a passing XOR checksum always mean the data is correct and fit to control with? Give a case where the checksum passes but the data should not be used.
From ArduPilot's DroneCAN page, why do larger drones put the GPS, ESCs and power module on a CAN bus instead of separate UART wires to each?
Check before you hand in
What to hand in
- Sensor address and readings
- Annotated I2C capture
- Sender and receiver code with checksum results
- Wrong-baud explanation and DroneCAN parameter list