---
# System prepended metadata

title: Lab07 用 Make 取代 IFTTT
tags: [FM623A]

---

# 使用 Make 服務之前請先參閱 

- [使用 Make 取代 IFTTT](/focrkHpNSv-6XjxfQDOy5Q)

# 使用 Make 發送 Line 通知(原使用 IFTTT 發送 Line 通知)
1. 建立 webhooks 腳本並命名, 將網址複製並打開瀏覽器貼上網址, 最後面加上?value1, 請按 OK 儲存
```
https://hook.eu2.make.com/xl.....9ot4c.....pm.....83qt?value1
```
2. 成功後會顯示 Successfuly determined
![FM623A_1](https://hackmd.io/_uploads/H10qlFGOp.png)
3. 建立 Line 腳本並輸入訊息, 請按 OK 儲存
![FM623A_2](https://hackmd.io/_uploads/rkRtetGua.png)
4. 記得要先按底下的儲存存檔
![FM617A_3](https://hackmd.io/_uploads/rJxzfnqDa.png)
5. 最後打開成 ON
![FM617A_4](https://hackmd.io/_uploads/S1A8fhqD6.png)
6. 以下為 Lab07 修改後的程式, 請將程式中 "MAKE 腳本網址" 更改成 Make 的 webhooks 腳本中的網址
```
from machine import Pin,ADC
import time
from keras_lite import Model  
import ulab as np
import network     # 匯入network模組
import urequests   # 匯入urequests模組
from umqtt.robust import MQTTClient

# 連線至無線網路
sta=network.WLAN(network.STA_IF)
sta.active(True)   
sta.connect('無線網路名稱','無線網路密碼')  # 更換為無線網路帳號、密碼 

while not sta.isconnected() :
    pass

print('Wifi連線成功')

# Adafruit IO 設定
aio_username = "你的Adafruit用戶名"
aio_key = "你的AIO密鑰"

mqtt_client = MQTTClient(
    client_id=aio_username,
    server="io.adafruit.com",
    user=aio_username,
    password=aio_key,
    ssl=False)
url_line="MAKE 腳本網址"

mean = 170.98275862068965
std = 90.31162360353873
model = Model('temperature_model.json')

adc_pin = Pin(36)
adc = ADC(adc_pin)
adc.width(ADC.WIDTH_9BIT)
adc.atten(ADC.ATTN_11DB)

mqtt_client.connect()
print("MQTT 連線成功")

while True:
    data = 0
    for i in range(20):
        thermal = adc.read()
        data += thermal
        time.sleep(0.01)

    data = data / 20
    data = np.array([int(data)])
    data = data - mean
    data = data / std
    tem = model.predict(data)
    tem = round(tem[0] * 100, 1)
    print(tem, end='   ')

    # 將數據發布到 Adafruit IO
    topic = aio_username + "/feeds/temperature"
    mqtt_client.publish(topic, str(tem))
    print("數據已發布至 Adafruit IO")
    
    if(tem>=37.5):   # 當體溫超過37.5度時, 傳LINE做警告
        r = urequests.get(url_line+"?value1="+str(tem)) # 傳送至LINE
        r.close()
        print("警告!!!發燒了!!!")

    time.sleep(60)  # 暫停60秒    

```
成功後 Line 就會出現訊息
![FM623A_6](https://hackmd.io/_uploads/HkPdxFMOa.png)


