rpi_gpio는 Linux 시스템에서 Raspberry Pi의 GPIO 핀에 직접 접근할 수 있도록 해주는 Dart 라이브러리입니다. 개발자가 디지털 입력 및 출력을 제어하고 센서, LED, 모터와 같은 물리적 하드웨어와의 상호작용을 가능하게 합니다. IoT 애플리케이션을 위한 것으로, Flutter 또는 Raspberry Pi에서 실행되는 독립형 Dart 프로젝트 내에서 GPIO 기능을 관리하기 위한 간단한 인터페이스를 제공합니다. 이 패키지는 Raspberry Pi가 작동하는 Linux 환경과 원활하게 통합되어 임베디드 및 실시간 하드웨어 제어 시나리오에 이상적입니다.
사용 사례
LED 및 리레이 제어
GPIO에서 센서 데이터 읽기
홈 자동화 시스템 구축
상호작용형 IoT 장치 만들기
로봇 인터페이스 개발
주요 기능
직접 GPIO 핀 접근
Linux 전용 호환성
입출력 제어를 위한 간단한 API
인터럽트 기반 이벤트를 지원합니다
경량이며 최소한의 종속성
적합한 대상
Raspberry Pi 개발자
사물인터넷 애호가
하드웨어 인터페이싱 플러터 앱
임베디드 시스템 프로젝트
실시간 장치 제어
고려 사항
리눅스가 설치된 라즈베리파이에서만 작동합니다
일부 작업에는 루트 권한이 필요합니다
리눅스 플랫폼에 한정
다른 마이크로컨트롤러에 대한 지원 없음
GPIO 권한을 위한 추가 설정이 필요할 수 있습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
rpi_gpio.dart
rpi_gpio is a Dart package for accessing the Raspberry Pi GPIO pins.
Overview
Gpio provides the API
for accessing the various General Purpose I/O pins on the Raspberry Pi.
RpiGpio provides the implementation
for the Gpio API via the native libgpiod.so.2 library.
Setup
Installing libgpiod (should already be installed)
RpiGpio accesses the GPIO pins using the native libgpiod.so.2 library.
If you are running the latest Raspberry Pi OS (formerly Raspbian),
then this library should already be installed by default on your Raspberry Pi.
If you are unsure, see #2 below in the troubleshooting section.
If it is not already installed, open a terminal and run
Blinking an LED along with software based PWM on a second LED.
Responding to a button press by turning on an LED.
The example is structured such that the example test
can inject a mock gpio to facilitate testing and allow test execution on platforms
other than the Raspberry Pi.
Testing
Latest Raspberry Pi OS (2024-05-29)
Raspberry Pi Hardware
Dart version
Pi 5 Model B Rev 1.0
3.3.4 (stable) (Tue Apr 16 19:56:12 2024 +0000) on "linux_arm64"
Pi 3 Model B Rev 1.2
3.3.4 (stable) (Tue Apr 16 19:56:12 2024 +0000) on "linux_arm64"
Pi 2 Model B Rev 1.1
3.3.4 - 32 bit
Pi 1 Model B Rev 2
unsupported
Troubleshooting
Run test/src/native/show_hardware_and_os.dart and record the output
Run test/src/native/show_lib_version.dart to see if the libgpiod.so.2 library can be located
If running test/src/native/blink_led.dart crashes then there may be a 32 bit / 64 bit mismatch. Check that the board, the OS, and the Dart SDK are all either 32 bit or 64 bit.
If running test/src/native/blink_led.dart doesn't crash, but doesn't blink the LED
(where the LED and resistor are connected in series to GPIO 17 (pin 11) and ground) then
sudo apt-get install libgpiod-dev
gpioinfo
and and check to see that the gpiochip# listing all of the GPIO#
(for example "gpiochip4" below)