Arduino 8

[Arduino] ESP32 4채널 릴레이 모듈 배선 작업 및 테스트 코드 작성

준비물점퍼 케이블ESP32 보드4채널 릴레이 모듈 릴레이 모듈ESP32설명VCC3.3V전원 공급GNDGND접지 연결IN1GPON26(혹은 D6)릴레이 1 제어  위에 꺼 참고해서 점퍼 케이블로 갖다 꽂으면 된다. 맞물리는 소리나면 연결 된거다. 이제 ino 파일 작성해서 릴레이 모듈 연결이 됐는지 테스트해보자. int relayPin = 26;void setup() { pinMode(relayPin, OUTPUT);}void loop() { digitalWrite(relayPin, LOW); delay(2000); digitalWrite(relayPin, HIGH); delay(2000);} # ino 컴파일$ arduino-cli compile --fqbn esp32:esp3..

Arduino 2025.04.05

[Arduino] MQTT로 JSON 데이터 타입 전송하기(+ JSON, NTPClient 라이브러리 다운로드)

작업 전에 필요한 라이브러리를 다운로드 받는다. 테스트 용으로 여러 데이터를 담아 보내기 위해 JSON 라이브러리, 현재 시간을 받을 수 있는 NTPClient를 다운로드 받았다. $ arduino-cli lib install "ArduinoJson"$ arduino-cli lib install "NTPClient" #include #include #include #include const char* ssid = "WIFI";const char* pwd = "PASSWORD";const char* mqttServer = "MQTT INSTALL SERVER";WiFiClient esbClient;PubSubClient client(esbClient);WiFiUDP nt..

Arduino 2025.03.29

[Arduino] HTML/Javascript에서 WebSocket, MQTT를 이용한 Arduino 통신

0. 라이브러리 설치$ arduino-cli lib install "WiFi"Downloading WiFi@1.2.7...WiFi@1.2.7 downloadedInstalling WiFi@1.2.7...Installed WiFi@1.2.7$ arduino-cli lib install "PubSubClient"Downloading PubSubClient@2.8.0...PubSubClient@2.8.0 downloadedInstalling PubSubClient@2.8.0...Installed PubSubClient@2.8.01. mqtt_test.ino 작성#include #include const char* ssid = "WIFI";const char* pwd = "PASSWORD..

Arduino 2025.03.29

[Arduino] CLI에서 테스트 코드 실행하기

아두이노 쪽은 이제 입문 단계라 설명을 잘 하지는 못하겠고 메모용으로 남긴다. .inoArduino 프로젝트(스케치) 기본 코드 파일 확장자하나의 스케치 파일로 프로그램이 실행되는 시작점C++ 기반으로 작성자동 전처리 기능setup(), loop() 메소드를 필수로 작성해야한다.setup() : 초기화 작업loop() : 계속 실행될 코드 작성여러 개의 보조 ‘.cpp, .h’ 파일을 포함시켜 프로젝트를 확장할 수 있다. Arduino 관련 파일 모아 둘 디렉토리를 만든다. 알아서 만들자. $ pwd/arduino 나는 ‘/’ 경로에 ‘arduino’ 디렉토리를 생성했다. 프로젝트 하나 당 하나의 ino 파일을 가진다고 한다. 프로젝트 단위로 디렉토리를 만들자. $ tree.└── test 테스트 코드를..

Arduino 2025.03.29

[Arduino] Arduino CLI에서 .ino 실행하기

최근에 하게 된 토이 프로젝트가 아두이노에 센서 모듈 붙여서 통신해야하는거라 겉핡기 식으로 배우긴 싫었고 직접 사서 해보자 싶어서 공부 중이다. 아두이노 쪽은 이제 입문 단계라 설명을 잘 하지는 못하겠고 메모용으로 남긴다. .inoArduino 프로젝트(스케치) 기본 코드 파일 확장자C++ 기반으로 작성setup(), loop() 메소드를 필수로 작성해야한다.자동 전처리 기능 Arduino 관련 파일 모아 둘 디렉토리를 만든다. 알아서 만들자. $ pwd/arduino 나는 ‘/’ 경로에 ‘arduino’ 디렉토리를 생성했다. 프로젝트 하나 당 하나의 ino 파일을 가진다고 한다. 프로젝트 단위로 디렉토리를 만들자. $ tree.└── test 테스트 코드를 실행할 ino 파일을 생성한다. void se..

Arduino 2025.03.26

[Arduino] Arduino CLI 설치 및 ESP32 연결하기

설치 환경Raspberry PI5Debian 1. Arduino CLI 설치$ curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh 나는 ‘/opt’ 경로에 설치했으며 설치 후 ‘/opt/bin/’ 내부에 ‘arduino-cli’ 디렉토리가 설치되길래 ‘/opt’에서 바로 접근 가능하게 디렉토리를 옮겼다.2. Arduino CLI PATH 추가[참고] 해당 작업은 Arduino CLI를 설치해놓은 경로에서만 ‘arduino-cli’ 명령어가 적용되길래 설정해놓은 부분이다. $ echo 'export PATH=$PATH:/opt' >> /root/.bashrc$ source /root/.bashrc ‘e..

Arduino 2025.03.26