Working with GPIO, ADC, Cameras, and I²C Sensors
← Back to Course HomeThis laboratory introduces students to practical sensor interfacing and data acquisition techniques on the Jetson Orin Nano platform. Building on the hardware familiarization from Week 1, you will now learn to programmatically interface with various types of sensors and input devices. Through hands-on exercises, you'll work with analog-to-digital conversion (ADC) for reading continuous sensor values, camera systems using the CSI interface for computer vision applications, and I²C communication for accessing digital environmental sensors. These fundamental skills form the foundation for collecting real-world data that will feed into the AI models you develop in later weeks.
Sensor interfacing is the critical first step in any edge AI application—without the ability to acquire data from the physical world, AI models have nothing to process. Understanding how to properly interface with different sensor types and communication protocols enables you to build complete AI systems that can perceive and respond to their environment. Whether you're building autonomous robots, smart environmental monitoring systems, or computer vision applications, the skills learned in this lab are fundamental. The combination of analog sensors, digital sensors, and cameras provides the multimodal sensing capabilities required for advanced AI applications, from simple classification tasks to complex autonomous navigation systems.
This laboratory consists of three progressive parts, each introducing different sensor interface methods:
By the end of this laboratory session, you will be able to:
GPIO pins are the fundamental interface between a computer and the physical world. The Jetson Orin Nano features a 40-pin GPIO header compatible with Raspberry Pi HAT accessories, providing digital input/output capabilities, PWM (Pulse Width Modulation), and communication protocols like I²C, SPI, and UART. Each GPIO pin can be configured as either an input (to read signals from sensors or buttons) or an output (to control LEDs, relays, or other devices). Understanding GPIO programming is essential for any embedded system project.
The Jetson.GPIO library provides a Python interface similar to RPi.GPIO, making it easy to control pins with simple commands. Pin numbering can follow either BOARD mode (physical pin numbers 1-40) or BCM mode (Broadcom chip-specific GPIO numbers). Proper GPIO usage requires understanding voltage levels (3.3V logic on Jetson), current limitations (typically 50mA per pin), and proper grounding to avoid damaging the hardware.
While the Jetson Orin Nano's GPIO pins can read digital signals (HIGH or LOW), many sensors produce analog signals that vary continuously over a range of voltages. To read these analog values, we need an Analog-to-Digital Converter (ADC). ADC chips convert continuous analog voltage signals into discrete digital numbers that a computer can process. The resolution of an ADC determines how precisely it can measure voltages—a 10-bit ADC divides the voltage range into 1024 steps (2^10), while a 12-bit ADC provides 4096 steps for more precise measurements.
Common ADC interfaces include I²C (for moderate-speed applications) and SPI (for higher speeds). Key specifications include resolution (bits), sample rate (samples per second), input voltage range, and reference voltage. In this lab, you'll use an I²C ADC to read analog sensor values such as potentiometers, light sensors, or analog temperature sensors. Understanding ADC characteristics helps you select appropriate sensors and interpret readings correctly.
The Camera Serial Interface (CSI) is a high-speed interface designed specifically for camera modules. The Jetson Orin Nano includes two MIPI CSI-2 connectors that support up to 8 lanes of high-bandwidth video data transfer. CSI cameras offer advantages over USB cameras including lower latency, higher bandwidth, and direct integration with the Jetson's Image Signal Processor (ISP) for hardware-accelerated image processing.
Common CSI cameras for Jetson include the IMX219 (8MP) and IMX477 (12MP) from Sony, which provide excellent image quality for computer vision applications. The GStreamer multimedia framework is typically used to capture and process CSI camera streams on Jetson, offering hardware-accelerated encoding/decoding. Understanding camera parameters like resolution, frame rate, exposure, and white balance is important for capturing high-quality images that feed into AI models for tasks like object detection, classification, and autonomous navigation.
Inter-Integrated Circuit (I²C, pronounced "I-squared-C") is a two-wire serial communication protocol widely used for connecting low-speed peripherals to microcontrollers and embedded computers. I²C uses only two signals: SDA (Serial Data) for bidirectional data transfer and SCL (Serial Clock) for synchronization. Multiple devices can share the same I²C bus, each identified by a unique 7-bit or 10-bit address. This makes I²C ideal for systems with many sensors since it requires minimal wiring.
The QWIIC system from SparkFun standardizes I²C connections using 4-pin JST connectors (SDA, SCL, 3.3V, GND), allowing sensors to be daisy-chained without soldering. The Jetson Orin Nano's GPIO header includes I²C buses, and with a QWIIC pHAT adapter, you can easily connect QWIIC-compatible sensors. Understanding I²C addressing, clock speeds (typically 100kHz standard or 400kHz fast mode), and the master-slave architecture is essential for debugging communication issues and building reliable sensor networks.
The BME280 is a highly accurate digital sensor from Bosch that measures three environmental parameters: temperature (±1°C accuracy), relative humidity (±3% accuracy), and barometric pressure (±1 hPa accuracy). It communicates via I²C or SPI and operates at 1.8-3.6V, making it perfect for embedded applications. The BME280's small size, low power consumption, and high precision make it popular for weather stations, indoor air quality monitors, altitude estimation, and environmental control systems.
The sensor includes built-in calibration data stored in non-volatile memory, which must be read and applied to raw measurements to obtain accurate results. Python libraries like Adafruit_BME280 and smbus2 simplify the process of reading sensor data by handling I²C communication and calibration calculations. Understanding how to interpret environmental sensor data is valuable for applications ranging from climate monitoring to UAV flight control (pressure-based altitude estimation).
| Interface Type | Signal Type | Wires Required | Typical Use Cases | Speed |
|---|---|---|---|---|
| GPIO Digital | Digital (0/1) | 1 per signal | Buttons, LEDs, simple sensors | Instant |
| ADC | Analog → Digital | 2-4 (I²C/SPI) | Potentiometers, analog sensors | kHz range |
| I²C | Digital (serial) | 2 (SDA, SCL) | Sensors, displays, low-speed | 100-400 kHz |
| CSI-2 | Digital (high-speed) | Multiple lanes | Cameras, video streaming | 1-2 Gbps/lane |
Before coming to lab, please review the following resources:
The Jetson Orin Nano uses 3.3V logic levels on its GPIO pins. Applying higher voltages (like 5V) directly to GPIO pins can permanently damage the board. Always verify voltage compatibility before connecting sensors or external circuits. Use level shifters when interfacing with 5V devices. Never connect or disconnect sensors while the Jetson is powered on, as this can cause voltage spikes that damage components.
Instructions: Complete this quiz to assess your readiness for the lab. Click on your answer choice to see if you're correct.
This laboratory consists of three hands-on exercises that progressively build your sensor interfacing skills. Each part focuses on a different communication method and sensor type. Work through the exercises in order, as concepts build upon each other. Take time to understand the code and experiment with different parameter values to see how they affect sensor readings.
In this exercise, you'll learn to read analog sensor values using an external ADC chip connected via I²C. You'll interface with an analog sensor (such as a potentiometer or analog temperature sensor) and convert its continuous voltage output into digital values that the Jetson can process. This exercise teaches you how to work with analog sensors and understand ADC resolution and reference voltages.
This exercise introduces you to camera interfacing using the MIPI CSI-2 connector on the Jetson Orin Nano. You'll learn how to capture images from a CSI camera module, display them in real-time, and save frames for processing. Understanding camera interfaces is essential for computer vision and autonomous robotics applications that will be explored in later weeks.
In the final exercise, you'll work with a digital environmental sensor that communicates via the I²C protocol. The BME280 provides accurate measurements of temperature, humidity, and atmospheric pressure—data that's valuable for environmental monitoring, weather prediction, and altitude estimation. You'll learn how to use I²C to read sensor registers and apply calibration data for accurate measurements.
The following hardware components are required for this laboratory:
The following software packages are pre-installed on your Jetson Orin Nano:
Note: All required software has been pre-configured by your lab technician. If you encounter missing packages, please notify your instructor.
Your JetBot system from Week 1 already has the QWIIC pHAT installed. For this lab:
⚠️ Always power off the Jetson before connecting or disconnecting hardware!
Prepare a comprehensive lab report documenting your work on all three sensor interface exercises. Your report should demonstrate understanding of the communication protocols, proper implementation of sensor reading code, and analysis of the acquired data. Include code snippets, sensor readings, and visualizations where appropriate.
Submit your completed lab report by [Insert Deadline - Typically 1 week after lab session]. Late submissions will be penalized according to course policy (10% per day, maximum 3 days).
Your lab report must include the following sections:
For each of the 3 parts (ADC, CSI Camera, BME280):
| Component | Points | Criteria |
|---|---|---|
| Title Page & Formatting | 5 | Complete information, professional appearance |
| Objectives | 10 | Clear understanding of learning goals |
| Procedure & Results | 50 | All parts complete, correct implementation, clear documentation |
| Discussion | 20 | Thoughtful analysis, proper comparisons, evidence-based |
| Challenges & Solutions | 10 | Detailed problem-solving documentation |
| Conclusion | 5 | Reflective summary with future applications |
| Total | 100 |