Raspberry Pi ( python )
-
공공데이터 활용하기Raspberry Pi ( python ) 2023. 3. 8. 14:36
1 _ 공공데이터 : 공공데이터 포털은 공공기관이 생성 또는 취득하여 관리하고 있는 공공데이터를 한 곳에서 제공하는 통합 창구이다. 파일데이터, 오픈API, 시각화 등 다양한 방식으로 제공하고 있다. 공공 데이터를 이용하려면 JSON 데이터 타입에 대한 이해가 필요하다. JSON은 Int, String, Object, Array 4가지 데이터 타입으로 이루어져 있다. 공공 데이터와 사용자의 python 버전이 다르다면 데이터를 버전에 맞게 변경시켜서 사용해야한다. - Default 값인 XML 미리보기 JSON 타입을로 받으면 python의 dictionary 같은 형태로 값을 받을 수 있다. - 파이썬을 활용하여 온습도 확인하기 1) 사용하고자 하는 자료의 주소와 인증키를 찾는다 2) 공공데이터 센터에..
-
URL의 구조Raspberry Pi ( python ) 2023. 3. 8. 10:19
1 _ URL의 구조 http://music.naver.com/listen/top100.nhn?domain=OVERSEA&duration=1h#content 위의 주소를 자세하게 설명하면 http --> protocol music.naver.com --> domain - music -> 서브 도메인 naver -> 도메인 명 com -> 최상위 도메인 listen/top100.nhn --> path ?domain=OVERSEA&duration=1h --> parameter #content --> fragment path (/) , parameter (?) , fragment (#) - path (/) : 파일의 경로를 가르키며, / 뒤에 나온다. - parameter (?) : 쿼리 스트링이라고도 부르며..
-
Ch.06 Flask를 활용하여 센서 제어하기Raspberry Pi ( python ) 2023. 3. 7. 15:22
1 _ 프레임워크, Flask란? : 프레임워크는 앱이나 웹, 소프트웨어를 개발하기위해 들어가는 노력과 시간을 줄여주고자 다양한 기능을 집합시켜서 개발자가 개발에만 집중할 수 있도록 도와주는 역할을 한다. 대표적으로 장고(Django)와 플라스크(Flask)가 있는데, 장고는 큰 프로젝트를 진행하는데 유리한 프레임워크이다. 여기서는 가벼운 플라스크를 활용할 것이다. ** 라즈베리 파이에서 Flask를 사용하고싶다면, VS code와 flask를 라즈비안에 다운받고 Vs code의 터미널에서 python을 실행한 뒤 flask를 import한다. 2 _ Flask 웹 서버 구축하기 폴더와 파일 구성 webapps -ch06 -helloworld -app_start.py 코드 리뷰 from flask imp..
-
CH.05 라즈베리파이 GPIO 및 센서 활용하기Raspberry Pi ( python ) 2023. 3. 3. 15:28
1 _ GPIO 제어 및 테스트 1) 지니의 설정을 바꿔서 python 코드를 읽을 수 있게 만들기. 제작 -> 빌드설정으로 이동 Compile에 python3으로 변경 Execute에서 python3으로 변경 2) 파이썬 코드 작성하기 ** 코드 마지막에 GPIO.cleanup()은 스크립트 실행 시에 GPIO 모드 세팅 등을 초기화하고 리소스를 반환시켜서 중복이나 GPIO핀 쇼트 등의 하드웨어적인 문제를 방지할 수 있다. GPIO 4번 핀에 1초 동안 신호를 주고 1초동안 신호를 꺼서 LED가 10회 깜빡이도록 만들었다. import RPi.GPIO as GPIO -> as GPIO 명령어로 RPi.GPIO 모듈이름을 GPIO로 요약해서 사용할 수 있다 import time -> RPi.GPIO 모듈..
-
CH.04 라즈베리 파이를 위한 전자 기초 배우기Raspberry Pi ( python ) 2023. 3. 3. 09:34
1 _ 알기 쉬운 전자회로 1) 옴의 법칙 V = I * R 2) 콘덴서 : 축전기 (capacitor : 커패시터) 또는 콘던서 라고 부르며 전기를 저장할 수 있는 장치다. 콘덴서의 용량만큼 저장된 이후에는 전류가 흐르지 않는다. 콘덴서에 직류 전원을 연결하면 일정시간동안 충전되다가 전류가 흐르지 않는데, 만약 교류 전원을 연결하면 충전과 방전을 반복하면서 전류가 흐르게 된다. 콘덴서는 직류를 차단하고 교류를 통과한다. 3) 트렌지스터 : 트렌지스터는 크게 두 가지로 기능이 나뉜다. 증폭기능, 스위치 기능 트렌지스터는 3개의 다리가 있는데 각 부분을 다음과 같이 물이 지나가는 파이프의 밸브에 비유할 수 있다. 콜렉터 : 밸브의 물이 들어가는 입구 에미터 : 밸브의 물이 나가는 출구 베이스 : 밸브를 열..
-
CH.02 라즈베리 파이를 위한 리눅스 기초 배우기Raspberry Pi ( python ) 2023. 2. 28. 11:31
1 _ 리눅스 운영체제의 종류 : 리눅스 운영체제는 대형기종에 작업이 가능한 유닉스를 개인용 컴퓨터에서 작동할 수 있게 변형한 것이라고 볼 수 있다. 리눅스의 가장 큰 특징은 GNU 정신을 준수하기 때문에 대부분 무료이고 소스코드의 자유배포가 가능하다. 대표적인 리눅스의 종류는 Debian, Redhat 이 있다. 2 _ 원격 접속을 위한 VNC와 Putty : 라즈비안에 모니터, 키보드, 마우스를 연결하여 직접적으로 사용할 수 있지만 원격 접속하는 방법이 있다. CLI는 터미널 모드로 접속하기, GUI는 그래픽 모드로 접속하는 것이다. - 그래픽 모드 접속 1) www.realvnc.com/en/connect/download/vnc/ Download VNC Server | VNC® Connect Ena..
-
Ch01. 라즈베리파이 시작하기Raspberry Pi ( python ) 2023. 2. 27. 15:14
1 _ SD Card Format SD Card Formatter를 다운받아서 작업을 진행하기 전 SD Card를 포맷할 수 있습니다. 링크 : http://sd-card-formatter.kr.uptodown.com/windows/download SD Card Formatter 5.0.2을 위한 Windows을 다운로드하세요 | Uptodown.com 탄탄하고 용도가 다양하며, 맞춤 설정도 가능한 브라우저 컴퓨터 작업 손쉽게 자동화하기 DOS 를 위해 부팅가능한 USB를 만드세요. 사용중이거나, 보호되고 있거나 금지된 파일들을 삭제하세요 sd-card-formatter.kr.uptodown.com Volume label에 raspberry 라고 작성한 뒤, Overwrite format을 체크한 후 F..
-
Ch03. 파이썬 기초 (함수, 클래스, 모듈)Raspberry Pi ( python ) 2023. 2. 24. 12:07
1 _ 함수 : 함수 선언의 기본적인 형태는 다음과 같다. def 함수명( ):# 인수 없는 함수 실행문 def 함수명( 인수 ):# 인수 있는 함수 실행문 예제) 함수 선언 - def mydef02(str="인수함수를 선언합니다."): 파이썬의 특징으로 매개변수를 선언하면서 값을 저장할 수 있다. 예제) 함수 인수 사용하기 2 _ 클래스 : 클래스는 프로그래밍 과정에서 객체를 정의하는 데이터와 이를 활용하는 기능을 가질 수 있는 구조이다. 각 클래스는 객체의 상태를 정의할 수 있는 속성(attributes)과 객체의 기능을 정의하는 메서드(methods)를 가질 수 있는 구조이다. class 클래스명:#클래스 선언 name = "" velocity = 0# 숫자, 문자 등의 객체 선언 def 함수명( ..