ปัญหาที่พบบ่อยตอนคอมไพล์
1.ถ้าเจอ Error ตอน Compile แสดง "'_FDEV_SETUP_WRITE' was not declared in this scope.". ให้เปิดไฟล์ config.h ใน LMIC Library. ใส่ // หน้าบรรทัด #define ตามตัวอย่าง
//#define LMIC_PRINTF_TO Serial
2. บางครั้งเราติดตั้ง LMIC บางตัว จะเจอ Error ตอน Compile แสดงบรรทัดแรก LMIC-Arduino-AS923-upper-master\lmic\lmic.c.o: In function `calcRxWindow':
เช่น LMIC Lib ที่ได้จาก https://github.com/orenonline/arduino-lmic-as923
หรือ LMIC Lib ที่ได้จาก https://github.com/promwungkwa/LMIC-Arduino-AS923-upper
ให้ ไปที่ C:\Users\yourUserName\Documents\Arduino\libraries\arduino-lmic-master\src\lmic
แทนที่ที่ขีดเส้นใต้ด้วย User Name บน PC ที่ใช้อยู่
เปิด ไฟล์ oslmic.h
หาคำ table_get ## postfix; ประมาณบรรทัดที่ 229-230
ใส่ static ด้านหน้า
static inline type table_get ## postfix(const type *table, size_t index) { \
Save ไฟล์
และ Complie ใหม่ 3. สำหรับ ESP32 Dev Board หรือ ESP32 Heltecเมื่อทำการ Flash โปรแกรม และไม่สามารถ Auto Flash ได้หน้าจอแสดง Error ดังนี้
C:\Users\somsak\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\2.6.1/esptool.exe --chip esp32 --port COM4 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 C:\Users\somsak\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.2/tools/partitions/boot_app0.bin 0x1000 C:\Users\somsak\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.2/tools/sdk/bin/bootloader_dio_80m.bin 0x10000 C:\Users\somsak\AppData\Local\Temp\arduino_build_981274/abp07.ino.bin 0x8000 C:\Users\somsak\AppData\Local\Temp\arduino_build_981274/abp07.ino.partitions.bin
esptool.py v2.6
Serial port COM4
Connecting........_____....._____....._____....._____....._____....._____.....____An error occurred while uploading the sketch
_
A fatal error occurred: Failed to connect to ESP32: Invalid head of packet (0x53)
หลังจอขึ้นคำว่า connecting ให้
ถ้าเป็นบอร์ด Heltec กดปุ่ม prg ค้างไว้ แล้วกด rst หนึ่งครั้ง แล้วจึงปล่อยปุ่ม prg
ถ้าเป็นบอร์ด ESP32 กดปุ่ม Boot ค้างไว้ แล้วกด EN หนึ่งครั้งแล้วจึงปล่อยปุ่ม Bootการแก้ไขสามารถทำได้โดยการใส่ Capacitor (แบบไม่มีขั้ว) คล่อมขา EN-GND ใช้ Capacitor ขนาด 1-10UF
3.Preference ควรตั้งค่าให้ Show verbose ทั้งเวลา Compile และ Upload

4.หน้าต่าง Output ควรขยายเพื่อให้เห็นข้อความ error สีแดงได้ง่ายขึ้น การ debug ปัญหาให้สังเกตุจากบรรทัดแรกที่เปลี่ยนจากตัวอักษรสีขาวเป็นสีแดง สีขาวคือ info ส่วนสีแดงคือ error

5. Config LMIC lib บางอย่างแก้ไขได้ที่ไฟล์
Documents\Arduino0\libraries\MCCI_LoRaWAN_LMIC_library\src\lmic\config.h
เช่น
// Set this to 1 to enable some basic debug output (using printf) about
// RF settings used during transmission and reception. Set to 2 to
// enable more verbose output. Make sure that printf is actually
// configured (e.g. on AVR it is not by default), otherwise using it can
// cause crashing.
#ifndef LMIC_DEBUG_LEVEL
#define LMIC_DEBUG_LEVEL 0
6. Multiple Hal Library
ต้องกำหนดค่าในไฟล์ lmic_project_config ซึ่งอยู่ใน Directory C:\Users\User\Documents\Arduino0\libraries\MCCI_LoRaWAN_LMIC_library\project_config
หมายเหตุ User ให้เลือก User Windows ที่ใช้ Login ขณะนั้น
เช่น
#define CFG_as923 1
#define CFG_sx1276_radio 1
#define hal_init LMICHAL_init
#define LMIC_DEBUG_LEVEL 2
ถ้าใช้ PlatformIO แก้ไข ไฟล์ platformio.ini
ใส่ -D hal_init=LMICHAL_init
ถ้าใช้ LMIC LIB เก่า
เพิ่มบรรทัด
#define hal_init LMICHAL_init
ในไฟล์ config.h