2017年8月1日 星期二

NODE RED 上傳現在時間到GOOGLE FIREBASE 資料庫

OPEN NODE RED
  > http://127.0.0.1:1880

  • 安裝LIB
  • INSTALL LIB
    • node-red-contrib-firebase
    • node-red-contrib-moment

  • 匯入程式碼IMPORT > CLIPBOARD 




  • 請將以下程式碼貼到NODE RED

[{"id":"72409a95.293654","type":"firebase modify","z":"b260aad1.9b5d68","name":"","firebaseconfig":"","childpath":"TIME","method":"push","value":"msg.payload","priority":"msg.priority","x":532.5,"y":208,"wires":[[]]},{"id":"35e9aa4e.4e2ff6","type":"inject","z":"b260aad1.9b5d68","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":231.5,"y":52,"wires":[["144159f7.5f5fc6"]]},{"id":"144159f7.5f5fc6","type":"moment","z":"b260aad1.9b5d68","name":"","topic":"","input":"","inputType":"msg","inTz":"Asia/Taipei","adjAmount":"8","adjType":"hours","adjDir":"add","format":"","locale":"zh_TW","output":"","outputType":"msg","outTz":"Asia/Taipei","x":313.5,"y":124,"wires":[["72409a95.293654","1e9d788d.697c6f"]]},{"id":"1e9d788d.697c6f","type":"debug","z":"b260aad1.9b5d68","name":"output","active":true,"console":"false","complete":"true","x":487,"y":59,"wires":[]}]

  • 選"IMPORT"




  • 設定GOOGLE FIRBASE DATA BASE
    • https://console.firebase.google.com
    • 使用google 帳號登入
    • 設定認證方式:電子郵件/密碼

    • 設定Database規責:請copy以下code貼上
Realtime Database
// These rules give anyone, even people who are not users of your app,
// read and write access to your database
{
  "rules": {
    ".read": true,
    ".write": true
  }
}


    • Copy 資料連結(請使用自已設定名稱): https://punch-card-machine.firebaseio.com/
    • 貼到node red - firebase 程式模組如下圖所示
      • step 1
      • step 2

      • step 3

  • 點選node red "timestemp",再看一下是否有上傳現在時間到FIREBASE












沒有留言:

張貼留言