2024年3月2日 星期六

產專班 作業1 RFID + MQTT +Line Notify

產專班 作業1 

RFID + MQTT +Line Notify 

(需修改成自己的部分 參考作業說明)

wifi 帳號密碼 , 裡面alex9ufo , line的權杖



 *             MFRC522      ESP32    
 *             Reader/PCD            
 * Signal      Pin          Pin        
 * -----------------------------------
 * RST/Reset   RST          GPIO27  
 * SPI SS      SDA(SS)      GPIO5    
 * SPI MOSI    MOSI         GPIO23    
 * SPI MISO    MISO         GPIO19    
 * SPI SCK     SCK          GPIO18  




Arduino 程式 

需要 有2個檔案


一個是 Arduino 2024_RFID_LED.ino 檔案 

另一個是 arduino_secrets.h 有2行程式 如下

#define SECRET_SSID ""

#define SECRET_PASS ""


Arduino  2024_RFID_LED.ino 檔案


//定義MFRC522 RFID read 與 ESP32 介面 接腳連接Pin assign
/* Wiring RFID RC522 module  
==============================================================
GND     = GND   3.3V    = 3.3V
The following table shows the typical pin layout used:
 *             MFRC522      ESP32    
 *             Reader/PCD            
 * Signal      Pin          Pin        
 * -----------------------------------
 * RST/Reset   RST          GPIO27  
 * SPI SS      SDA(SS)      GPIO5    
 * SPI MOSI    MOSI         GPIO23    
 * SPI MISO    MISO         GPIO19    
 * SPI SCK     SCK          GPIO18    
 *
[1] (1, 2) Configurable, typically defined as RST_PIN in sketch/program.
[2] (1, 2) Configurable, typically defined as SS_PIN in sketch/program.
[3] The SDA pin might be labeled SS on some/older MFRC522 boards
=============================================================
*/
// Wifi 與 MQttClient 程式庫
#include <ArduinoMqttClient.h>
#include <WiFi.h>
#include "arduino_secrets.h"

//MFRC522 程式庫
#include <SPI.h>
#include <MFRC522.h>

//GPIO 2 D1 Build in LED

#define LED 13           //定義LED接腳

///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = "TOTOLINK_A3002MU";    // your network SSID (name)
char pass[] = "24063173";    // your network password (use for WPA, or use as key for WEP)
// WiFi SSID password , SSID 和密碼進行Wi-Fi 設定

//const char ssid[] = "alex9ufo"; // Enter your Wi-Fi name
//const char pass[] = "alex9981";  // Enter Wi-Fi password

//char ssid[] = "dlink-103A";    // your network SSID (name)
//char pass[] = "bdcce12882";    // your network password (use for WPA, or use as key for WEP)

WiFiClient wifiClient;
MqttClient mqttClient(wifiClient);

//const char broker[] = "test.mosquitto.org";
const char broker[] = "broker.mqtt-dashboard.com";
int        port     = 1883;
String json = "";

const char *SubTopic1 = "alex9ufo/2024/RFID/LED";
const char *PubTopic2 = "alex9ufo/2024/RFID/Back_LED";
const char *PubTopic3 = "alex9ufo/2024/RFID/RFID_UID";
const char *PubTopic4 = "alex9ufo/2024/RFID/RFID_PICC";

const char willTopic[] = "alex9ufo/2024/RFID/Starting";
//======================================================
#define RST_PIN      27        // 讀卡機的重置腳位
#define SS_PIN       5        // 晶片選擇腳位
MFRC522 mfrc522(SS_PIN, RST_PIN);    // 建立MFRC522物件
MFRC522::MIFARE_Key key;  // 儲存金鑰
MFRC522::StatusCode status;
//===========================================================
//布林代數 LED狀態 是否連上網路ESP32 ready ?
bool ledState = false;
bool atwork = false;
bool Send = false;  //true
String LEDjson = "";
int Count= 0;
//===========================================================
void onMqttMessage(int messageSize) {
  // we received a message, print out the topic and contents
  Serial.print("Received a message with topic '");
  Serial.print(mqttClient.messageTopic());
  String Topic= mqttClient.messageTopic();
  Serial.print("', duplicate = ");
  Serial.print(mqttClient.messageDup() ? "true" : "false");
  Serial.print(", QoS = ");
  Serial.print(mqttClient.messageQoS());
  Serial.print(", retained = ");
  Serial.print(mqttClient.messageRetain() ? "true" : "false");
  Serial.print("', length ");
  Serial.print(messageSize);
  Serial.println(" bytes:");
  String message="";
  // use the Stream interface to print the contents
  while (mqttClient.available()) {
    //Serial.print((char)mqttClient.read());
    message += (char)mqttClient.read();
  }

  Serial.println(message);
  message.trim();
  Topic.trim();

  if (Topic=="alex9ufo/2024/RFID/LED") {
  if (message == "on") {
    digitalWrite(LED, LOW);  // Turn on the LED
    //ledState = true;  //ledState = ture HIGH
    //設定 各個 旗號
    LEDjson ="ON";
    Send = true ;
    Serial.print("LED =");
    Serial.println(LEDjson);
    }
  if (message == "off" ) {
    digitalWrite(LED, HIGH); // Turn off the LED
    //ledState = false; //ledState = false LOW
    LEDjson ="OFF";
    Send = true ;
    Serial.print("LED =");
    Serial.println(LEDjson);
  }

    Serial.println();
    Serial.println("-----------------------");
  }  
}

//===========================================================
String printHex(byte *buffer, byte bufferSize) {
      String id = "";
      for (byte i = 0; i < bufferSize; i++) {
        id += buffer[i] < 0x10 ? "0" : "";
        id += String(buffer[i], HEX);
        id +=" ";
      }
      return id;
}
//===========================================================
//副程式  setup wifi
void setup_wifi() {
  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);     //print ssid
  WiFi.begin(ssid, pass);  //初始化WiFi 函式庫並回傳目前的網路狀態
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }   //假設 wifi 未連接 show ………

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}  
//===========================================================
//判斷 旗號Flash , Timer 是否為真
void LED_Message() {
  ////判斷 旗號 Send 是否為真 回傳MQTT訊息到MQTT Broker 
  if (Send) {
    // Convert JSON string to character array
    Serial.print("Publish message: ");
    Serial.println(LEDjson);
    LEDjson.trim();

    bool retained = false;
    int qos = 1;
    bool dup = false;
   
    // Publish JSON character array to MQTT topic
    mqttClient.beginMessage(PubTopic2,  LEDjson.length(), retained, qos, dup);  //LED Status
    mqttClient.print(LEDjson);
    mqttClient.endMessage();
    Send = false;    //處理過後 旗號 Send為假
  }

}
//===========================================================
void setup() {
  pinMode(LED, OUTPUT);
  digitalWrite(LED, HIGH);  // Turn off the LED initially
  //Initialize serial and wait for port to open:
  Serial.begin(115200);   // Initialize serial communications with the PC
  while (!Serial);    // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
 
  setup_wifi();
  Serial.println("You're connected to the network");
  Serial.println();
 
  String willPayload = "ESP32 Start working....!";
  bool willRetain = true;
  int willQos = 1;

  mqttClient.beginWill(willTopic, willPayload.length(), willRetain, willQos);
  mqttClient.print(willPayload);
  mqttClient.endWill();

  Serial.print("Attempting to connect to the MQTT broker: ");
  Serial.println(broker);

  if (!mqttClient.connect(broker, port)) {
    Serial.print("MQTT connection failed! Error code = ");
    Serial.println(mqttClient.connectError());

    while (1);
  }

  Serial.println("You're connected to the MQTT broker!");
  Serial.println();

  // set the message receive callback
  mqttClient.onMessage(onMqttMessage);
  Serial.print("Subscribing to topic: ");
  Serial.println(SubTopic1);
  // subscribe to a topic
  // the second parameter sets the QoS of the subscription,
  // the the library supports subscribing at QoS 0, 1, or 2
  int subscribeQos = 1;
  mqttClient.subscribe(SubTopic1, subscribeQos);


  Serial.println();
  SPI.begin();      // Init SPI bus
  mfrc522.PCD_Init();   // Init MFRC522
  delay(4);       // Optional delay. Some board do need more time after init to be ready, see Readme
  //mfrc522.PCD_DumpVersionToSerial();  // Show details of PCD - MFRC522 Card Reader details
  Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}
//===========================================================
void loop() {
 
  // call poll() regularly to allow the library to receive MQTT messages and
  // send MQTT keep alives which avoids being disconnected by the broker
  mqttClient.poll();
 
  LED_Message();
  // to avoid having delays in loop, we'll use the strategy from BlinkWithoutDelay
  // see: File -> Examples -> 02.Digital -> BlinkWithoutDelay for more info
  unsigned long currentMillis = millis();


 if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial()) {
   
     Serial.println(F("Please scan MIFARE Classic card..."));
    // 確認是否有新卡片
   
    byte *id = mfrc522.uid.uidByte;   // 取得卡片的UID
    byte idSize = mfrc522.uid.size;   // 取得UID的長度
    String Type;
    Serial.print("PICC type: ");      // 顯示卡片類型
    // 根據卡片回應的SAK值(mfrc522.uid.sak)判斷卡片類型
    MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
    Type= mfrc522.PICC_GetTypeName(piccType);
    Serial.println(mfrc522.PICC_GetTypeName(piccType));

    Serial.print("UID Size: ");       // 顯示卡片的UID長度值
    Serial.println(idSize);
 
    for (byte i = 0; i < idSize; i++) {  // 逐一顯示UID碼
      Serial.print("id[");
      Serial.print(i);
      Serial.print("]: ");
      Serial.println(id[i], HEX);       // 以16進位顯示UID值
    }
    Serial.println();



    json="";
    String json1=printHex(mfrc522.uid.uidByte, mfrc522.uid.size);
    json1.toUpperCase();
    json = json + json1;
    json.trim();

    bool retained = false;
    int qos = 1;
    bool dup = false;

    mqttClient.beginMessage(PubTopic3,  json.length(), retained, qos, dup);
    mqttClient.print(json);
    mqttClient.endMessage();

    json="";
    json = "PICC type: ";
    json =  json + Type;
    json.trim();
   
    retained = false;
    qos = 1;
    dup = false;

    mqttClient.beginMessage(PubTopic4,  json.length(), retained, qos, dup);
    mqttClient.print(json);
    mqttClient.endMessage();


    Serial.println();
    // Dump debug info about the card; PICC_HaltA() is automatically called
    // 令卡片進入停止狀態
    // Dump debug info about the card; PICC_HaltA() is automatically called
    // mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
   
    mfrc522.PICC_HaltA();
    mfrc522.PCD_StopCrypto1(); // stop encryption on PCD
  }
}
////===========================================================

Node=Red 程式


[{"id":"9f51922c96475745","type":"mqtt in","z":"024ba427a7f5812e","name":"Rack LED","topic":"alex9ufo/2024/RFID/Back_LED","qos":"1","datatype":"auto-detect","broker":"841df58d.ee5e98","nl":false,"rap":true,"rh":0,"inputs":0,"x":160,"y":520,"wires":[["a8fcaef90ac2a7ea","2778b0a8751644f1","5f2c87735b333a9c","c0707331bbc29acc"]]},{"id":"a8fcaef90ac2a7ea","type":"function","z":"024ba427a7f5812e","name":"function LED on ,off","func":"var onoff=msg.payload;\n\nif (onoff==\"ON\")\n{\n    msg.payload=true;\n}\nif (onoff==\"OFF\")\n{\n    msg.payload=false;\n}  \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":600,"wires":[["11f9b3fed3944fec"]]},{"id":"bfb3b1e0afad219b","type":"inject","z":"024ba427a7f5812e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":350,"y":680,"wires":[["11f9b3fed3944fec"]]},{"id":"03dd3a2a9506eea5","type":"inject","z":"024ba427a7f5812e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":370,"y":640,"wires":[["11f9b3fed3944fec"]]},{"id":"11f9b3fed3944fec","type":"ui_led","z":"024ba427a7f5812e","order":1,"group":"7b4b159b9632feb1","width":6,"height":5,"label":"","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"#ff0000","value":"false","valueType":"bool"},{"color":"#008000","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"shape":"circle","showGlow":true,"name":"","x":570,"y":600,"wires":[]},{"id":"1639f0d1ca085251","type":"ui_button","z":"024ba427a7f5812e","name":"","group":"7b4b159b9632feb1","order":2,"width":0,"height":0,"passthru":false,"label":"LED ON","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"on","payloadType":"str","topic":"topic","topicType":"msg","x":180,"y":80,"wires":[["1953eedb67e61c2c","16609fe88dddf2ab","1b28a9dbc6b3afc8"]]},{"id":"415bdb9608b58cee","type":"ui_button","z":"024ba427a7f5812e","name":"","group":"7b4b159b9632feb1","order":3,"width":0,"height":0,"passthru":false,"label":"LED OFF","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"off","payloadType":"str","topic":"topic","topicType":"msg","x":180,"y":180,"wires":[["1953eedb67e61c2c","16609fe88dddf2ab","1b28a9dbc6b3afc8"]]},{"id":"1953eedb67e61c2c","type":"ui_audio","z":"024ba427a7f5812e","name":"","group":"7b4b159b9632feb1","voice":"Google US English","always":"","x":420,"y":140,"wires":[]},{"id":"16609fe88dddf2ab","type":"mqtt out","z":"024ba427a7f5812e","name":"LED","topic":"alex9ufo/2024/RFID/LED","qos":"0","retain":"true","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"841df58d.ee5e98","x":410,"y":80,"wires":[]},{"id":"2778b0a8751644f1","type":"ui_text","z":"024ba427a7f5812e","group":"7b4b159b9632feb1","order":5,"width":0,"height":0,"name":"","label":"MQTT<<訂閱>>的訊息","format":"{{msg.payload}}","layout":"row-left","className":"","x":380,"y":560,"wires":[]},{"id":"1b28a9dbc6b3afc8","type":"ui_text","z":"024ba427a7f5812e","group":"7b4b159b9632feb1","order":4,"width":0,"height":0,"name":"","label":"MQTT  [ [發行] ] 的訊息","format":"{{msg.payload}}","layout":"row-left","className":"","x":460,"y":180,"wires":[]},{"id":"4d98ddd8f5354d4f","type":"ui_text","z":"024ba427a7f5812e","group":"7b4b159b9632feb1","order":6,"width":0,"height":0,"name":"","label":"MQTT 的Broker :","format":"<font color= {{msg.color}} > {{msg.payload}} </font>","layout":"row-left","className":"","x":710,"y":340,"wires":[]},{"id":"a6a877eb4be7a0cf","type":"function","z":"024ba427a7f5812e","name":"function on off","func":"var on_off=flow.get(\"onoff\");\n\nif (on_off== true)\n{\n    msg.payload='HiveMQTT';\n    flow.set(\"onoff\",false)\n}   \nelse\n{\n    msg.payload='   ';\n    flow.set(\"onoff\",true)\n}\nmsg.color=\"red\";\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":340,"wires":[["4d98ddd8f5354d4f","8f16f50beb2fd914"]]},{"id":"1ab8fc00ab6a2801","type":"inject","z":"024ba427a7f5812e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":170,"y":340,"wires":[["a6a877eb4be7a0cf","b234e6b8f0c79306"]]},{"id":"8f16f50beb2fd914","type":"delay","z":"024ba427a7f5812e","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":480,"y":280,"wires":[["a6a877eb4be7a0cf"]]},{"id":"b234e6b8f0c79306","type":"function","z":"024ba427a7f5812e","name":"function  flow set","func":"flow.set(\"onoff\",true);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":380,"wires":[[]]},{"id":"c6aada400221f416","type":"comment","z":"024ba427a7f5812e","name":"發行 alex9ufo/2024/RFID/LED","info":"","x":220,"y":140,"wires":[]},{"id":"a0786c74e597ace5","type":"comment","z":"024ba427a7f5812e","name":"訂閱 alex9ufo/2024/RFID/Back_LED","info":"","x":240,"y":440,"wires":[]},{"id":"cffb26e93155b0b4","type":"comment","z":"024ba427a7f5812e","name":"定期 閃爍 HiveMQTT","info":"","x":200,"y":280,"wires":[]},{"id":"a3da334ec58d571b","type":"inject","z":"024ba427a7f5812e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":740,"y":420,"wires":[["96d55c93b931523e"]]},{"id":"5ebf60e91bf99d7a","type":"template","z":"024ba427a7f5812e","name":"Image in","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<img src=\"data:image/png;base64,{{payload}}\"style=\"width=\"400\" height=\"300\"\"/>","output":"str","x":1280,"y":420,"wires":[["621cc26def28f659"]]},{"id":"621cc26def28f659","type":"ui_template","z":"024ba427a7f5812e","group":"610b6d14a9aef1a0","name":"MQTT","order":1,"width":10,"height":8,"format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","className":"","x":1410,"y":420,"wires":[[]]},{"id":"96d55c93b931523e","type":"file in","z":"024ba427a7f5812e","name":"","filename":"D:\\2024RFID\\作業1\\EX1.png","filenameType":"str","format":"","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":940,"y":420,"wires":[["c62ccd80dad331eb"]]},{"id":"c62ccd80dad331eb","type":"base64","z":"024ba427a7f5812e","name":"","action":"","property":"payload","x":1140,"y":420,"wires":[["5ebf60e91bf99d7a"]]},{"id":"b7ab30b1c8592615","type":"comment","z":"024ba427a7f5812e","name":"On inject add MQTT picture  to the dashboard","info":"","x":1110,"y":380,"wires":[]},{"id":"8d7b00ea7d339381","type":"comment","z":"024ba427a7f5812e","name":"存放路徑若是不同需修改","info":"存放路徑\nD:\\2024RFID\\作業1\\EX1.png\n若是不同需修改","x":770,"y":380,"wires":[]},{"id":"5f2c87735b333a9c","type":"function","z":"024ba427a7f5812e","name":"function ","func":"msg.payload=\" ---ESP32 回來 LED的狀態---\" +msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":520,"wires":[["7cb295df3f651ad8","a588fcd00a340802"]]},{"id":"7cb295df3f651ad8","type":"function","z":"024ba427a7f5812e","name":"Set Line API ","func":"msg.headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer A4wwPNh2WqB7dlfeQyyIAwtggn1kfZSI5LkkCdia1gB'};\nmsg.payload = {\"message\":msg.payload};\nreturn msg;\n\n//oR7KdXvK1eobRr2sRRgsl4PMq23DjDlhfUs96SyUBZu","outputs":1,"noerr":0,"x":550,"y":540,"wires":[["69f4d04c83a3b62d"]]},{"id":"69f4d04c83a3b62d","type":"http request","z":"024ba427a7f5812e","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"https://notify-api.line.me/api/notify","tls":"","persist":false,"proxy":"","authType":"","x":700,"y":540,"wires":[["3db96139024c408b"]]},{"id":"3db96139024c408b","type":"debug","z":"024ba427a7f5812e","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":850,"y":540,"wires":[]},{"id":"b53b1192a01aea88","type":"comment","z":"024ba427a7f5812e","name":"Line Notify Message ","info":"","x":790,"y":500,"wires":[]},{"id":"a588fcd00a340802","type":"ui_text","z":"024ba427a7f5812e","group":"610b6d14a9aef1a0","order":2,"width":0,"height":0,"name":"","label":"ESP32 LED至Line訊息","format":"<font color= {{msg.color}} > {{msg.payload}} </font>","layout":"row-left","className":"","x":580,"y":500,"wires":[]},{"id":"c51ffa9eeb9c79b7","type":"ui_text","z":"024ba427a7f5812e","group":"7bec0a4da1755d2d","order":1,"width":6,"height":4,"name":"","label":"RFID UID -->","format":"{{msg.payload}}","layout":"row-left","className":"","x":1290,"y":80,"wires":[]},{"id":"075b1e287e5d9347","type":"mqtt in","z":"024ba427a7f5812e","name":"RFID_UID","topic":"alex9ufo/2024/RFID/RFID_UID","qos":"1","datatype":"auto-detect","broker":"603bb104.d6134","nl":false,"rap":true,"rh":0,"inputs":0,"x":780,"y":80,"wires":[["c51ffa9eeb9c79b7","df55f1819e8b66e7","afdbad21b78a0b02"]]},{"id":"df55f1819e8b66e7","type":"delay","z":"024ba427a7f5812e","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":920,"y":40,"wires":[["dae09bddc266dc4c"]]},{"id":"dae09bddc266dc4c","type":"function","z":"024ba427a7f5812e","name":"function  覆蓋","func":"msg.payload=\"\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1130,"y":40,"wires":[["c51ffa9eeb9c79b7"]]},{"id":"afdbad21b78a0b02","type":"function","z":"024ba427a7f5812e","name":"function  ","func":"msg.payload=\" ---ESP32 回來 UID號碼---\" +msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":920,"y":180,"wires":[["66e6317ca7b54715","82904e831754affc"]]},{"id":"66e6317ca7b54715","type":"function","z":"024ba427a7f5812e","name":"Set Line API ","func":"msg.headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer A4wwPNh2WqB7dlfeQyyIAwtggn1kfZSI5LkkCdia1gB'};\nmsg.payload = {\"message\":msg.payload};\nreturn msg;\n\n//oR7KdXvK1eobRr2sRRgsl4PMq23DjDlhfUs96SyUBZu","outputs":1,"noerr":0,"x":1070,"y":180,"wires":[["10568f34aa90f487"]]},{"id":"10568f34aa90f487","type":"http request","z":"024ba427a7f5812e","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"https://notify-api.line.me/api/notify","tls":"","persist":false,"proxy":"","authType":"","x":1220,"y":180,"wires":[["6a38bfa68353e278"]]},{"id":"6a38bfa68353e278","type":"debug","z":"024ba427a7f5812e","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1350,"y":180,"wires":[]},{"id":"82904e831754affc","type":"ui_text","z":"024ba427a7f5812e","group":"610b6d14a9aef1a0","order":3,"width":0,"height":0,"name":"","label":"ESP32 RFID至Line訊息","format":"<font color= {{msg.color}} > {{msg.payload}} </font>","layout":"row-left","className":"","x":1090,"y":140,"wires":[]},{"id":"3b949643e95630ef","type":"mqtt in","z":"024ba427a7f5812e","name":"RFID_PICC","topic":"alex9ufo/2024/RFID/RFID_PICC","qos":"1","datatype":"auto-detect","broker":"603bb104.d6134","nl":false,"rap":true,"rh":0,"inputs":0,"x":790,"y":280,"wires":[["13f661295c829301","389105838630bc97"]]},{"id":"389105838630bc97","type":"delay","z":"024ba427a7f5812e","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":980,"y":240,"wires":[["22f59fb343de54a2"]]},{"id":"22f59fb343de54a2","type":"function","z":"024ba427a7f5812e","name":"function  覆蓋","func":"msg.payload=\"\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1130,"y":240,"wires":[["13f661295c829301"]]},{"id":"13f661295c829301","type":"ui_text","z":"024ba427a7f5812e","group":"7bec0a4da1755d2d","order":3,"width":6,"height":5,"name":"","label":"RFID  -->","format":"{{msg.payload}}","layout":"row-left","className":"","x":1320,"y":280,"wires":[]},{"id":"c0707331bbc29acc","type":"debug","z":"024ba427a7f5812e","name":"debug 270","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":350,"y":480,"wires":[]},{"id":"841df58d.ee5e98","type":"mqtt-broker","name":"","broker":"broker.hivemq.com","port":"1883","clientid":"","autoConnect":true,"usetls":false,"compatmode":false,"protocolVersion":"4","keepalive":"15","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"7b4b159b9632feb1","type":"ui_group","name":"LED","tab":"dd5fce9c0b030350","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"610b6d14a9aef1a0","type":"ui_group","name":"LINE","tab":"dd5fce9c0b030350","order":2,"disp":true,"width":10,"collapse":false,"className":""},{"id":"7bec0a4da1755d2d","type":"ui_group","name":"RFID","tab":"dd5fce9c0b030350","order":3,"disp":true,"width":"6","collapse":false,"className":""},{"id":"603bb104.d6134","type":"mqtt-broker","name":"","broker":"broker.mqtt-dashboard.com","port":"1883","clientid":"","autoConnect":true,"usetls":false,"compatmode":false,"protocolVersion":"4","keepalive":"15","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"dd5fce9c0b030350","type":"ui_tab","name":"2024RFID產業專班","icon":"dashboard","order":103,"disabled":false,"hidden":false}]


MQTT Explorer 設定畫面











Line Notify 手機畫面



沒有留言:

張貼留言

2024_09 作業3 以Node-Red 為主

 2024_09 作業3  (以Node-Red 為主  Arduino 可能需要配合修改 ) Arduino 可能需要修改的部分 1)mqtt broker  2) 主題Topic (發行 接收) 3) WIFI ssid , password const char br...