Heltec WiFi LoRa 32 (V3)
การใช้งานด้วย PlatformIO
บทความนี้แนะนำการ Compile โปรแกรม Blink เพื่อกระพริบไฟ LED บนบอร์ด Heltec WiFi LoRa 32 V.3
บอร์ดนี้ใช้ MCU ESP32-S3 ซึ่งค่อนข้างใหม่ การใช้งานโปรแกรม PlatformIO หรือ ArduinoIDE ควรติดตั้งเวอร์ชั่นล่าสุด
คลิกหน้ามนุษย์ต่างดาว แล้วคลิก New Project
ใส่ Name ตามที่เราต้องการ เลือก Board เป็น Heltec WiFi LoRa (V3)
แก้ไข File main.cpp เป็นตามตัวอย่างด้านล่าง
File main.cpp
#include <Arduino.h>
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(35, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(35, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(35, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
เช็คดู File platformio.ini จะเป็นไปตามตัวอย่าง
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html[env:heltec_wifi_lora_32_V3]
platform = espressif32
board = heltec_wifi_lora_32_V3
framework = arduino
เสียบสาย USB เข้ากับ Board แล้วคลิก
หากกด Build แล้วทำงานปรกติจะเห็นข้อความคล้ายตัวอย่างด้านล่าง
Executing task: C:\Users\somsak\.platformio\penv\Scripts\platformio.exe run — target upload — environment heltec_wifi_lora_32_V3Processing heltec_wifi_lora_32_V3 (platform: espressif32; board: heltec_wifi_lora_32_V3; framework: arduino)
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — Verbose mode can be enabled via `-v, — verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/heltec_wifi_lora_32_V3.html
PLATFORM: Espressif 32 (6.0.0+sha.fbec5d0) > Heltec WiFi LoRa 32 (V3)
HARDWARE: ESP32S3 240MHz, 320KB RAM, 8MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-builtin, esp-prog, iot-bus-jtag, jlink, minimodule,
olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
— framework-arduinoespressif32 @ 3.20006.221224 (2.0.6)
— tool-esptoolpy @ 1.40400.0 (4.4.0)
— tool-mkfatfs @ 2.0.1
— tool-mklittlefs @ 1.203.210628 (2.3)
— tool-mkspiffs @ 2.230.0 (2.30)
— toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
— toolchain-xtensa-esp32s3 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies…
No dependencies
Building in release mode
Retrieving maximum program size .pio\build\heltec_wifi_lora_32_V3\firmware.elf
Checking size .pio\build\heltec_wifi_lora_32_V3\firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [= ] 5.9% (used 19172 bytes from 327680 bytes)
Flash: [= ] 7.4% (used 247449 bytes from 3342336 bytes)
Configuring upload protocol…
AVAILABLE: cmsis-dap, esp-bridge, esp-builtin, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port…
Auto-detected: COM3
Uploading .pio\build\heltec_wifi_lora_32_V3\firmware.bin
esptool.py v4.4
Serial port COM3
Connecting….
Chip is ESP32-S3 (revision v0.1)
Features: WiFi, BLE
Crystal is 40MHz
MAC: f4:12:fa:81:64:8c
Uploading stub…
Running stub…
Stub running…
Changing baud rate to 460800
Changed.
Configuring flash size…
Flash will be erased from 0x00000000 to 0x00003fff…
Flash will be erased from 0x00008000 to 0x00008fff…
Flash will be erased from 0x0000e000 to 0x0000ffff…
Flash will be erased from 0x00010000 to 0x0004cfff…
Compressed 14768 bytes to 10149…
Writing at 0x00000000… (100 %)
Wrote 14768 bytes (10149 compressed) at 0x00000000 in 0.5 seconds (effective 246.0 kbit/s)…
Hash of data verified.
Compressed 3072 bytes to 146…
Writing at 0x00008000… (100 %)
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.2 seconds (effective 147.2 kbit/s)…
Hash of data verified.
Compressed 8192 bytes to 47…
Writing at 0x0000e000… (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.2 seconds (effective 400.2 kbit/s)…
Hash of data verified.
Compressed 247840 bytes to 137463…
Writing at 0x00010000… (11 %)
Writing at 0x0001da01… (22 %)
Writing at 0x000240f4… (33 %)
Writing at 0x0002957f… (44 %)
Writing at 0x0002ea06… (55 %)
Writing at 0x00034c89… (66 %)
Writing at 0x0003f258… (77 %)
Writing at 0x00044aab… (88 %)
Writing at 0x0004a39a… (100 %)
Wrote 247840 bytes (137463 compressed) at 0x00010000 in 4.0 seconds (effective 496.6 kbit/s)…
Hash of data verified.Leaving…
Hard resetting via RTS pin…
=========================================== [SUCCESS] Took 22.35 seconds ===========================================* Terminal will be reused by tasks, press any key to close it.
จะเห็น LED สีขาวบนบอร์ด Heltec เริ่มกระพริบ