# \[BASIC] 007 WiFi SETUP WiFi (ต่อเน็ต)

สวัสดีครับ สำหรับหัวข้อบทเรียนพื้นฐานบนบอร์ด HONEYLemon ที่ใช้งานผ่าน arduino library โดยเป็นการใช้งานเกี่ยวกับการเชื่อมต่อ WiFi บนบอร์ดเพื่อให้สามารถใช้งานอินเตอร์เน็ตได้

สำหรับการต่อ WiFi บนบอร์ด HONEYLemon นั้นสามารถใช้เพียงคำสั่งเดียวก็สามารถเชื่อมต่ออินเตอร์เน็ตผ่าน WiFi ได้แล้ว โดยใช้คำสั่ง

```
lemon.setupWiFi(WIFI_SSID, WIFI_PASS);
```

โดยที่ WIFI\_SSID เป็นชื่อ WiFi และ WIFI\_PASS เป็นรหัสผ่าน WIFI

ตัวอย่างการใช้งาน \*แนะนำว่าควรอยู่ใน void setup() เพื่อให้เชื่อมต่อ WiFi ในกระบวนการเริ่มต้นของระบบ

```
void setup(){
...
    lemon.setupWiFi("myHOME", "12345678"); // เชื่อมต่ออินเตอร์เน็ตชื่อ myHOME ด้วยรหัสผ่าน 12345678
...
}
```

แล้วถ้าหากมี WiFi หลายๆ ตัวละ จะทำยังไง สำหรับบอร์ด HONEYLemon บน library ของ HONEYLemon เองได้คิดเรื่องนี้ไว้ให้ท่านเรียบร้อยแล้วสามารถใช้คำสั่งเดิมในการเพิ่มช่องทางในการเชื่อมต่อ WiFi ของท่านได้เลย เช่น มี WiFi ที่ต้องการเชื่อมต่อ 3 ชื่อที่เป็นไปได้ว่าจะใช้งาน\
1\. ชื่อ WiFi : myHOME รหัส 12345678\
2\. ชื่อ WiFi : HONEYLab รหัส @HONEYLab\
3\. ชื่อ WiFi : HONEYLemon รหัส HONEYLemon

```
void setup(){
...
    lemon.setupWiFi("myHOME", "12345678");
    lemon.setupWiFi("HONEYLab", "@HONEYLab");
    lemon.setupWiFi("HONEYLemon", "HONEYLemon");
...
}
```

สะดวกง่ายและรวดเร็วดีไหมครับ : )

**ตัวอย่าง source code**

```
/*
    Basic : การเขียนโปรแกรมกับการเชื่อมต่ออินเตอร์เน็ตผ่าน WiFi บนบอร์ดไมโครคอนโทรลเลอร์ HONEYLemon
*/
#include <HONEYLemon.h>

#define WIFI_SSID  "WiFi_Name"      // ตั้งค่าชื่อ WiFi
#define WIFI_PASS  "WiFi_Password"  // ตั้งค่ารหัสผ่าน WiFi

void setup()
{
    lemon.begin();          // เรียกใช้งานฟังก์ชั่นเริ่มต้นของบอร์ด HONEYLemon

    Serial.begin(115200);   // เรียกใช้งาน Serial
    lemon.debug(Serial);    // ขอดู debug ของบอร์ด HONEYLemon ผ่าน Serial

    // เรียกการใช้งานการตั้งค่า WiFi
    lemon.setupWiFi(WIFI_SSID, WIFI_PASS);
}

void loop()
{
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lemon.honey.co.th/blogs/basic/basic-007-wifi-setup-wifi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
