> For the complete documentation index, see [llms.txt](https://sharinghub.kittenbot.hk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sharinghub.kittenbot.hk/wifibrick_iot/futureboard/thingspeak.md).

# 未來板與ThingSpeak編程快速入門

ThingSpeak作為免費的IoT平台，的確是方便大家可以實現IoT應用，不過ThingSpeak的設定可能比較繁複，對初學者來說可能比較麻煩，故此KittenBot特地為大家提供一個從0開始的教學，讓大家都可以輕易使用ThingSpeak實現IoT。

### ThingSpeak帳號申請

請大家首先按照以下教學，申請一個免費的ThingSpeak帳號。

[ThingSpeak 平台介紹](/wifibrick_iot/iotplatform/thingspeak.md)

### ThingSpeak平台設置

申請帳號之後，我們還未可以開始編程，因為我們要先在ThingSpeak設置好平台。

#### 建立新頻道

在My Channel的頁面建立新頻道。

![](/files/t3uf1hDCLh4Q2UGiX2uK)

除了頻道名稱之外其他可以不用理會。

![](/files/GqIVVSQwwPfyEE8wLa0G)

完成之後就可以按Save Channel。

![](/files/CvhtyKv2e2woQe3VkTgk)

進入Sharing。

![](/files/3n9cG0OKqCZUcyDVNLUP)

最方便和簡單地使用ThingSpeak的方法是將頻道設為公開，所以我們選擇第二個選項。

![](/files/FYldIaoxYHEcnPpJgYrn)

當你看到Access由Private變為Public就代表頻道完成了。

![](/files/Kw9KWTSCu7wJWvG3LqAt)

#### 添加新裝置

然後請前往Devices，選擇MQTT。

![](/files/5LDBSQOTS8CVT7i2e1M4)

添加一個新裝置。

![](/files/UVJGqm88N4jWhI3cWXEY)

選擇剛才建立的頻道，點擊Add Channel。

<div><img src="/files/L0yL6fTZRNsWV3oHOwU2" alt=""> <figure><img src="/files/HLp9UPnqGdyR5iRC3QgE" alt=""><figcaption></figcaption></figure></div>

最後就可以點擊Add Device。

添加裝置後，這一個頁面非常重要！這些是大家的未來板用來連接ThingSpeak的登入資料，請大家自行記下，或者下載登入資料，儲存在電腦。

![../../\_images/128.png](/files/OZMIQaxKsO9aFLEGxpB0)

![](/files/VK6irh0vD575aHINW7iS)

### KittenBlock編程

對初學者而言，使用KittenBlock編程是最簡單的。

#### 連接ThingSpeak

搭建出以下程式，將未來板連接上網絡，然後連接到ThingSpeak的伺服器。

* 伺服器網址: mqtt3.thingspeak.com
* ID: 按照ThingSpeak裝置的ID
* 用戶名: 按照ThingSpeak裝置的username
* 密碼: 按照ThingSpeak裝置的Password

![](https://kittenbothk.readthedocs.io/en/latest/_images/144.png)

#### 發佈到ThingSpeak頻道

在發佈上ThingSpeak頻道之前，我們需要先查看頻道的ID。 頻道ID是一個7位的數字。

![](/files/zFPVhE6XyHWDTTXBQ4m8)

搭建出以下程式，按下A鍵發布信息20到ThingSpeak頻道。

* MQTT主題: channels/\[頻道ID]/publish
* 信息: field\[欄位號碼]=\[數字信息]

![](https://kittenbothk.readthedocs.io/en/latest/_images/162.png)

發佈成功的話，在ThingSpeak的頁面上會看到剛才發布的信息。

![](/files/7YOuspofuUhkGvmsbtRW)

#### 讀取ThingSpeak頻道信息

使用頻道ID訂閱頻道之後，就可以收取到頻道的訊息。

按A鍵發布信息到頻道，未來板收到訊息之後會顯示出來。

* MQTT主題: channels/\[頻道ID]/subscribe/fields/field\[欄位號碼]

![](https://kittenbothk.readthedocs.io/en/latest/_images/183.png)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://sharinghub.kittenbot.hk/wifibrick_iot/futureboard/thingspeak.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
