일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- scss
- 비동기기술
- Flask 오류
- CORS
- 웹 클라이언트
- 웹 렌더링
- 다양한 기능
- prettier
- 신한투자증권
- 프로디지털아카데미
- jwt
- 웹
- 예외 클래스
- 백그라운드 실행
- Boxmodel
- 서버 통신
- 기본 타입
- HTTP
- eslint
- 쿠키
- 세션
- 정적 타입
- Visual Studio Code
- 자바
- 동적 타입
- 웹 스크래핑
- gatsby.js
- 웹 기초
- 타입스크립트
- 프디아
- Today
- Total
Moon Blog
IoT 융합보안 교육과정 본문
NodeMCU 핀
- GPIO : 범용 목적 핀으로 다용도 입출력 포트를 의미함
NodeMCU 환경 설정
- 드라이버 다운로드 : https://goo.gl/49nZPz
CP210x USB to UART Bridge VCP Drivers - Silicon Labs
The CP210x USB to UART Bridge Virtual COM Port (VCP) drivers are required for device operation as a Virtual COM Port to facilitate host communication with CP210x products. These devices can also interface to a host using the direct access driver.
www.silabs.com
- 라이브러리 설치
File -> Preferences -> Addtitional Board Manager URLs : http://arduino.esp8266.com/stable/package_esp8266com_index.json
NodeMCU 스케치 코드
void setup() {
pinMode(D0, OUTPUT); // Tool -> Board -> ESP8266 Board -> NodeMCU 1.0 설정해서 D0 사용
}
void loop() {
digitalWrite(D0,HIGH);
delay(1000);
digitalsWrite(D0,LOW);
delay(1000);
}
포트 연결 : Tool -> Port -> COM숫자
외부 라이브러리 연결
Ex) DHT(온습도 센서)
https://github.com/markruys/arduino-DHT
GitHub - markruys/arduino-DHT: Efficient DHT library for Arduino
Efficient DHT library for Arduino. Contribute to markruys/arduino-DHT development by creating an account on GitHub.
github.com
ZIP 파일 다운로드 -> 아두이노 스케치 -> 라이브러리 포함하기 -> .ZIP 라이브러리 추가
- 아두이노와 라즈베리파이의 서버/클라이언트 통신
아두이노 IDE 메뉴에서 예제 코드 여는 방법 : File -> Examples -> ESP8266WebServer -> HelloServer
#define STASSID에는 와이파이 아이디를 #define STAPSK에는 와이파이 비밀번호 입력
void ledOn() {
digitalWrite(led, HIGH);
server.send(200, "text/plain", "on\r\n");
}
void ledOff() {
digitalWrite(led, LOW);
server.send(200, "text/plain", "off\r\n");
}
server.on("/on", ledOn);
server.on("/off", ledOff);
- 라즈베리파이에서 파이썬 코드로 led 컨트롤
import requests
r = requests.get('http://192.xxx.xxx.xxx/on').text
print(r)
import requests
r = requests.get('http://192.xxx.xxx.xxx/off').text
print(r)