Skip to main content

Installation-PlatformIO

· 6 min read
P'Kop
P'Erk

สวัสดีครับ เราจะเริ่มจากการติดตั้ง PlatformIO และการสร้าง Project สำหรับทำงานในบทถัด ๆ ไปนะครับ

Intro

PlatformIO เป็นซอฟแวร์แบบเปิด (Open Source) สำหรับพัฒนาระบบ IoT แบบ Cross-platform ซึ่งจะช่วยให้เราพัฒนาระบบ IoT ของเราบนบอร์ดทดลองใด ๆ ก็ได้โดยที่ใช้เพียงซอฟแวร์ตัวนี้ตัวเดียว

Install PlatformIO for VSCode

  1. เปิด VSCode Extension
  2. Search หา PlatformIO IDE
  3. กด Install

Install PlatformIO for VSCode

Setting Up the Project

  1. กดปุ่ม PlatformIO: Home ที่ PlatformIO Toolbar

PlatformIO: Home

  1. กด New Project เลือก Board WEMOS LOLIND32 PRO และ Framework Arduino จากนั้นกด Finish

Create Project

  1. โดยเราจะแก้ไขโค้ดของเราได้ที่ main.cpp ในโฟลเดอร์ src ซึ่งในตอนแรกจะมีโค้ดดังนี้
src/main.cpp
#include <Arduino.h>

void setup() {
// put your setup code here, to run once:
}

void loop() {
// put your main code here, to run repeatedly:
}
  1. สามารถกดปุ่ม Build และ Upload ได้ที่ PlatformIO Toolbar

Build and Upload Project

Install library

  1. กดที่PIO Home -> Open

    Example banner

  2. กดที่library

    Example banner

  3. จากนั้นกดหาlibraryที่จะลง จากนั้นกดAdd to Project

    Example banner

Serial Port Monitor

  1. หาไฟล์ชื่อ platformio.ini

    Example banner

  2. เพิ่มcodeนี้เพิ่มเข้าไป

upload_speed = 460800 
monitor_speed = 115200

ตรวจสอบอุปกรณ์ภายในกล่อง

น้องๆ ควรได้รับอุปกรณ์ 1 กล่อง / กลุ่ม (2 คนใช้ร่วมกัน) โดยอุปกรณ์ภายในกล่องมีดังนี้ หากได้อุปกรณ์ไม่ครบดังรายการต่อไปนี้ ขอให้แจ้ง TA บริเวณนั้นได้เลย

ชื่ออุปกรณ์จำนวน
ตัวต้านทาน 330Ω3
ตัวต้านทาน 10kΩ1
LED สี แดง เหลือง เขียวสีละ 1 ตัว
LDR1
Button 4 ขา1
Breadboard ตัวเล็ก1
สาย USB-A to micro1