使用ESP32 / ESP8266 發送Line 訊息

2024/03/03 更新 找到問題了,之前SSID與password是傳值,後來是改用傳址的方式傳入到WiFi函式庫中。所以改為傳址的方式後,就可以正常使用了。

2024/02/23更新
目前新版IDE+Library的WiFi的組合,我自已試起來也是無法進行WiFi連線的動作,之後有時間再來找問題。

開發環境如下
Arduino IDE 2.3.2
Line Notify函式庫 3.0.6
NodeMCU-32S 開發板

#include <WiFi.h>  //這裡是ESP32 WIFI函式庫
#include <WiFiClient.h>
#include <TridentTD_LineNotify.h>
#define LINE_TOKEN "你的token放在這"

// Set WiFi credentials
const char* ssid     =  "你的無線網路SSID";
const char* password =  "無線網路的密碼";

WiFiClient client; //網路連線物件

void setup(){
  Serial.begin(115200);  // 設定速率
// 進行無線網路連接
  WiFi.mode(WIFI_STA); 
  WiFi.begin(ssid, password);

//等待無線網路連接
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(100);
    Serial.print(".");
  }
  LINE.setToken(LINE_TOKEN); //設定Line Token權杖

  LINE.notify("這裡的文字會出現在Line上面"); //發送訊息到Line上面
}

void loop() {
}

參考資料
[Day23] Esp32 + LINE
Line Notify服務首頁
申請Line Token教學

在Arduino IDE中進行ESP8266 開發的環境設定

單純來看來就是三個步驟可以完成開發環境設定。

  1. 安裝Arduino IDE
  2. 新增開發板管理員網址
  3. 下載開發板套件

額外的開發板管理員網址
http://arduino.esp8266.com/stable/package_esp8266com_index.json

參考資料
Arduino 官網下載位置
Arduino 介紹 & 安裝
如何在Arduino IDE中,新增ESP8266系列開發板