아두이노 쪽은 이제 입문 단계라 설명을 잘 하지는 못하겠고 메모용으로 남긴다.
- .ino
- Arduino 프로젝트(스케치) 기본 코드 파일 확장자
- 하나의 스케치 파일로 프로그램이 실행되는 시작점
- C++ 기반으로 작성
- 자동 전처리 기능
- setup(), loop() 메소드를 필수로 작성해야한다.
- setup() : 초기화 작업
- loop() : 계속 실행될 코드 작성
- 여러 개의 보조 ‘.cpp, .h’ 파일을 포함시켜 프로젝트를 확장할 수 있다.
Arduino 관련 파일 모아 둘 디렉토리를 만든다.
알아서 만들자.
$ pwd
/arduino
나는 ‘/’ 경로에 ‘arduino’ 디렉토리를 생성했다.
프로젝트 하나 당 하나의 ino 파일을 가진다고 한다.
프로젝트 단위로 디렉토리를 만들자.
$ tree
.
└── test
테스트 코드를 실행할 ino 파일을 생성한다.
void setup() {
Serial.begin(115200);
while(!Serial) {
}
Serial.println("ESP32 통신이 정상적으로 연결되었습니다.");
}
void loop() {
Serial.println("ESP32가 정상적으로 동작하고 있습니다.");
delay(5000);
}
‘tree’ 명령어 때리면 아래와 같은 구조로 표출된다.
root@WAS-1:/arduino# tree
.
└── test
└── test.ino
2 directories, 1 file
root@WAS-1:/arduino#
이제 컴파일을 돌려보자.
$ arduino-cli compile --fqbn esp32:esp32:esp32 /arduino/test/
이번엔 컴파일된 스케치를 업로드하자.
$ arduino-cli upload --fqbn esp32:esp32:esp32 -p /dev/ttyUSB0 /arduino/test/
esptool.py v4.8.1
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP32-D0WD-V3 (revision v3.1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 14:2b:2f:c1:36:74
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00007fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00057fff...
Compressed 24976 bytes to 15952...
Writing at 0x00001000... (100 %)
Wrote 24976 bytes (15952 compressed) at 0x00001000 in 0.5 seconds (effective 414.4 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 146...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.0 seconds (effective 646.4 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 1112.9 kbit/s)...
Hash of data verified.
Compressed 294544 bytes to 157053...
Writing at 0x00010000... (10 %)
Writing at 0x0001bc5b... (20 %)
Writing at 0x000286d1... (30 %)
Writing at 0x0002dd73... (40 %)
Writing at 0x00033885... (50 %)
Writing at 0x00038a79... (60 %)
Writing at 0x0003e259... (70 %)
Writing at 0x00043a62... (80 %)
Writing at 0x0004b281... (90 %)
Writing at 0x000545a9... (100 %)
Wrote 294544 bytes (157053 compressed) at 0x00010000 in 2.4 seconds (effective 970.8 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
New upload port: /dev/ttyUSB0 (serial)
정상적으로 업로드됐다.
정상적으로 돌아가고 있는지 확인해보자!
$ arduino-cli monitor -p /dev/ttyUSB0 --config 115200
위에 있는 ‘115200’은 ‘test.ino’에서 작성했던 Serial.begin(115200);
부분에 있는 시리얼 통신 속도를 지정하는 부분으로 값을 같이 맞춰줘야 한다고 한다.

'Arduino' 카테고리의 다른 글
[Arduino] ESP32 기본 센서 호출 테스트 (0) | 2025.04.01 |
---|---|
[Arduino] MQTT로 JSON 데이터 타입 전송하기(+ JSON, NTPClient 라이브러리 다운로드) (0) | 2025.03.29 |
[Arduino] HTML/Javascript에서 WebSocket, MQTT를 이용한 Arduino 통신 (0) | 2025.03.29 |
[Arduino] Arduino CLI에서 .ino 실행하기 (0) | 2025.03.26 |
[Arduino] Arduino CLI 설치 및 ESP32 연결하기 (0) | 2025.03.26 |