본문 바로가기

라즈베리파이 5

라즈베리파이 5 WiringPi 설치 - 최강 라이브러리

반응형

 

wiringPi는 C 언어로 작성된 라즈베리 파이용 GPIO 제어 라이브러리다. 이 라이브러리를 사용하면 라즈베리 파이의 GPIO 핀을 쉽게 제어할 수 있다. 

 

wiringPi는 라즈베리 파이 개발자들에게 여러 가지 이점을 제공하며, 그 주요 의의는 다음과 같습니다.

1. 사용 편의성

wiringPi는 **아두이노(Arduino)**와 유사한 함수 이름을 사용하고 있어, 아두이노 개발 경험이 있는 사용자라면 쉽게 적응할 수 있습니다. 예를 들어, digitalWrite()나 pinMode()와 같은 함수는 아두이노에서 사용되는 것과 동일한 기능을 수행합니다. 이러한 친숙한 함수 이름 덕분에 라즈베리 파이를 처음 접하는 개발자도 GPIO를 손쉽게 제어할 수 있습니다.

2. 다양한 기능

단순한 GPIO 제어뿐만 아니라 PWM(펄스 폭 변조), 인터럽트(Interrupts), 시리얼 통신(Serial), SPI, I2C와 같은 다양한 기능들을 지원합니다. 이러한 기능들을 통해 센서, 모터, 디스플레이 등 여러 종류의 하드웨어와 라즈베리 파이를 연결하고 제어하는 것이 가능합니다.

3. 높은 접근성

wiringPi는 C/C++ 언어를 기반으로 하지만, 파이썬(Python), 자바(Java) 등 다양한 프로그래밍 언어에서 사용할 수 있도록 **바인딩(binding)**이 제공됩니다. 따라서 사용자는 자신이 선호하는 언어를 선택하여 GPIO를 제어할 수 있습니다.

4. 풍부한 자료

wiringPi는 오랫동안 사용되어 온 라이브러리인 만큼 온라인 문서, 예제 코드, 커뮤니티 등 다양한 자료가 풍부합니다. 문제가 발생했을 때 해결책을 찾기 쉽다는 점도 큰 장점입니다.

 

자, 바로 설치로 들어갑니다.

 

워낙 유명한 라이브러이면서도, 한때 업데이트가 중단된 적도 있지만 아직까지도 널리 사용되고 있습니다. 커뮤니티에 의해 발전하는 특성상 어떤 에러나 문제점도 지원은 어렵다고 합니다.

 

설치는 간단합니다. 가장 최근 버전의 파일을 안내하니 변경이 생길 경우 .deb 파일 이름을 확인하여 설치하세요.

 

1. 깃 설치 $ sudo apt install git  

 

2. 소스를 가져온다 

 

$ git clone https://github.com/WiringPi/WiringPi.git  

 

3. 폴더 변경 $ cd WiringPi  

 

4. 빌드 $ 이후 명령어만 참고

 

raspberry@raspberrypi:~/WiringPi $ ./build debian  

 

5. 빌드된 파일을 여기로 복사 $이후 명령어를 사용합니다. ^^ 

 

raspberry@raspberrypi:~/WiringPi $ mv debian-template/wiringpi_3.16_arm64.deb .  

 

6. 인스톨

 

raspberry@raspberrypi:~/WiringPi $ sudo apt install ./wiringpi_3.16_arm64.deb  

 

끝났어요. 지금까지 한 작업을 살짝 올리면 아래와 같습니다.

 

raspberry@raspberrypi:~/gt-data/Program_Source/ch4 $
raspberry@raspberrypi:~/gt-data/Program_Source/ch4 $ sudo apt install git
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
git is already the newest version (1:2.39.5-0+deb12u2).
The following packages were automatically installed and are no longer required:
  libbasicusageenvironment1 libgroupsock8 liblivemedia77 python3-v4l2
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
raspberry@raspberrypi:~/gt-data/Program_Source/ch4 $ cd
raspberry@raspberrypi:~ $
raspberry@raspberrypi:~ $
raspberry@raspberrypi:~ $
raspberry@raspberrypi:~ $
raspberry@raspberrypi:~ $
raspberry@raspberrypi:~ $ ls
Bookshelf  Desktop  Documents  Downloads  gt-data  Music  Pictures  Public  Templates  Videos
raspberry@raspberrypi:~ $
raspberry@raspberrypi:~ $
raspberry@raspberrypi:~ $
raspberry@raspberrypi:~ $ git clone https://github.com/WiringPi/WiringPi.git
Cloning into 'WiringPi'...
remote: Enumerating objects: 3488, done.
remote: Counting objects: 100% (1551/1551), done.
remote: Compressing objects: 100% (369/369), done.
remote: Total 3488 (delta 1367), reused 1182 (delta 1182), pack-reused 1937 (from 3)
Receiving objects: 100% (3488/3488), 1.39 MiB | 10.64 MiB/s, done.
Resolving deltas: 100% (2253/2253), done.
raspberry@raspberrypi:~ $ cd WiringPi
raspberry@raspberrypi:~/WiringPi $ ./build debian
version:3.16 architecture:arm64
[Compile] wiringPi.c
[Compile] wiringSerial.c
[Compile] wiringShift.c
[Compile] piHiPri.c
[Compile] piThread.c
[Compile] wiringPiSPI.c
[Compile] wiringPiI2C.c
[Compile] softPwm.c
[Compile] softTone.c
[Compile] mcp23008.c
[Compile] mcp23016.c
[Compile] mcp23017.c
[Compile] mcp23s08.c
[Compile] mcp23s17.c
[Compile] sr595.c
[Compile] pcf8574.c
[Compile] pcf8591.c
[Compile] mcp3002.c
[Compile] mcp3004.c
[Compile] mcp4802.c
[Compile] mcp3422.c
[Compile] max31855.c
[Compile] max5322.c
[Compile] ads1115.c
[Compile] sn3218.c
[Compile] bmp180.c
[Compile] htu21d.c
[Compile] ds18b20.c
[Compile] rht03.c
[Compile] drcSerial.c
[Compile] drcNet.c
[Compile] pseudoPins.c
[Compile] wpiExtensions.c
[Compile] wiringPiLegacy.c
[Link (Dynamic)]
[Install Headers: deb]
[Install Dynamic Lib: deb]
install -m 0755 -d                                                      /home/raspberry/WiringPi/debian-template/wiringPi/usr/lib
install -m 0755 libwiringPi.so.3.16                             /home/raspberry/WiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so.3.16
ln -sf /home/raspberry/WiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so.3.16    /home/raspberry/WiringPi/debian-template/wiringPi/usr/lib/libwiringPi.so
[Compile] ds1302.c
[Compile] maxdetect.c
[Compile] piNes.c
[Compile] gertboard.c
[Compile] piFace.c
[Compile] lcd128x64.c
[Compile] lcd.c
[Compile] scrollPhat.c
[Compile] piGlow.c
[Link (Dynamic)]
[Install Headers: deb]
[Install Dynamic Lib: deb]
install -m 0755 -d                                                      /home/raspberry/WiringPi/debian-template/wiringPi/usr/lib
install -m 0755 libwiringPiDev.so.3.16                          /home/raspberry/WiringPi/debian-template/wiringPi/usr/lib/libwiringPiDev.so.3.16
ln -sf /home/raspberry/WiringPi/debian-template/wiringPi/usr/lib/libwiringPiDev.so.3.16         /home/raspberry/WiringPi/debian-template/wiringPi/usr/lib/libwiringPiDev.so
[Compile] gpio.c
[Compile] readall.c
[Link]
[Install: deb]
dpkg-deb: building package 'wiringpi' in 'wiringPi.deb'.
dpkg-name: info: moved 'wiringPi.deb' to './wiringpi_3.16_arm64.deb'
raspberry@raspberrypi:~/WiringPi $ mv debian-template/wiringpi-3.16_arm64.deb .
mv: cannot stat 'debian-template/wiringpi-3.16_arm64.deb': No such file or directory
raspberry@raspberrypi:~/WiringPi $ ls
build           debian           devLib         examples  INSTALL     People  README.md  VERSION    wiringPi
COPYING.LESSER  debian-template  documentation  gpio      newVersion  pins    reinstall  version.h  wiringPiD
raspberry@raspberrypi:~/WiringPi $ mv debian-template/wiringpi-3.16_arm64.deb .
mv: cannot stat 'debian-template/wiringpi-3.16_arm64.deb': No such file or directory
raspberry@raspberrypi:~/WiringPi $ cd debian-template/
raspberry@raspberrypi:~/WiringPi/debian-template $ ls
wiringPi  wiringpi_3.16_arm64.deb
raspberry@raspberrypi:~/WiringPi/debian-template $ cd ..
raspberry@raspberrypi:~/WiringPi $ mv debian-template/wiringpi_3.16_arm64.deb .
raspberry@raspberrypi:~/WiringPi $ sudo apt install ./wiringpi_3.16_arm64.deb
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'wiringpi' instead of './wiringpi_3.16_arm64.deb'
The following packages were automatically installed and are no longer required:
  libbasicusageenvironment1 libgroupsock8 liblivemedia77 python3-v4l2
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  wiringpi
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/70.8 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 /home/raspberry/WiringPi/wiringpi_3.16_arm64.deb wiringpi arm64 3.16 [70.8 kB]
Selecting previously unselected package wiringpi.
(Reading database ... 151719 files and directories currently installed.)
Preparing to unpack .../wiringpi_3.16_arm64.deb ...
Unpacking wiringpi (3.16) ...
Setting up wiringpi (3.16) ...
Processing triggers for man-db (2.11.2-2) ...
N: Download is performed unsandboxed as root as file '/home/raspberry/WiringPi/wiringpi_3.16_arm64.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
raspberry@raspberrypi:~/WiringPi $
raspberry@raspberrypi:~/WiringPi $

 

 

잘 설치되었나 확인 $gpio readall 합니다. 아래와 같이 아름다운 화면을 볼 수 있어요.

 

 

 

 

 

wiringPi Git 상세 정보 참고 링크

 

반응형

캐어랩 고객 지원

취업, 창업의 막막함, 외주 관리, 제품 부재!

당신의 고민은 무엇입니까? 현실과 동떨어진 교육, 실패만 반복하는 외주 계약, 아이디어는 있지만 구현할 기술이 없는 막막함.

우리는 알고 있습니다. 문제의 원인은 '명확한 학습, 실전 경험과 신뢰할 수 있는 기술력의 부재'에서 시작됩니다.

이제 고민을 멈추고, 캐어랩을 만나세요!

코딩(펌웨어), 전자부품과 디지털 회로설계, PCB 설계 제작, 고객(시장/수출) 발굴과 마케팅 전략으로 당신을 지원합니다.

제품 설계의 고수는 성공이 만든 게 아니라 실패가 만듭니다. 아이디어를 양산 가능한 제품으로!

귀사의 제품을 만드세요. 교육과 개발 실적으로 신뢰할 수 있는 파트너를 확보하세요.

지난 30년 여정, 캐어랩이 얻은 모든 것을 함께 나누고 싶습니다.

카카오 채널 추가하기

카톡 채팅방에서 무엇이든 물어보세요

귀사가 성공하기까지의 긴 고난의 시간을 캐어랩과 함께 하세요.

캐어랩 온라인 채널 바로가기

캐어랩