<acronym id="s8ci2"><small id="s8ci2"></small></acronym>
<rt id="s8ci2"></rt><rt id="s8ci2"><optgroup id="s8ci2"></optgroup></rt>
<acronym id="s8ci2"></acronym>
<acronym id="s8ci2"><center id="s8ci2"></center></acronym>

電子發燒友App

硬聲App

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示
電子發燒友網>電子資料下載>電子資料>使用Bolt IOT的帶有蜂鳴器的電報比特幣通知器

使用Bolt IOT的帶有蜂鳴器的電報比特幣通知器

2022-12-19 | zip | 0.90 MB | 次下載 | 免費

資料介紹

描述

一旦比特幣價格大幅下跌并且您首先收到通知,擁有一個個人機器人來提醒您不是很好嗎?此外,在達到一定水平后,警報會上升,表明現在是投資的黃金機會。

先決條件:

1.螺栓物聯網課程

2.使用botfather創建一個電報機器人

3.比特幣價格API

讓我們開始吧:

1.硬件部分:

進行如圖所示的基本連接:

?

poYBAGOYke-AIrAZAADP2NQK4Ls163.png
確保啟動 Bolt 并連接到 WIFI。綠燈應亮。
?

?

2.軟件部分:

登錄 linux 或使用 PuTTY 登錄 Digital Ocean 的 VPS。

conf.py使用命令創建文件sudo nano conf.py。編寫以下代碼:

"""Configurations for alert.py"""
bolt_api_key = "XXXX"                 # This is your Bolt Cloud API Key
device_id = "XXXX"                    # This is the device ID and will be similar to BOLTXXXX where XXXX is some numbers
telegram_chat_id = "@XXXX"            # This is the channel ID of the created Telegram channel. Paste after @ symbol.
telegram_bot_id = "botXXXX"           # This is the bot ID of the created Telegram Bot. Paste after bot text.
threshold = 700000                       # Threshold beyond which the alert should be sent

alert.py使用命令創建另一個文件sudo nano alert.py。編寫以下代碼:

import requests, time, json, conf                    
from boltiot import Bolt       
                
mybolt = Bolt(conf.bolt_api_key, conf.device_id)

def get_bitcoin_price():
   URL = "https://min-api.cryptocompare.com/" # REPLACE WITH CORRECT URL
   response = requests.request("GET", URL)
   response = json.loads(response.text)
   current_price = response["INR"]
   return current_price

def send_telegram_message(message):
    """Sends message via Telegram"""
    url = "https://api.telegram.org/" + conf.telegram_bot_id + "/sendMessage"
    data = {
        "chat_id": conf.telegram_chat_id,
        "text": message
    }
    try:
        response = requests.request(
            "POST",
            url,
            params=data
        )
        print("This is the Telegram URL")
        print(url)
        print("This is the Telegram response")
        print(response.text)
        telegram_data = json.loads(response.text)
        return telegram_data["ok"]
    except Exception as e:
        print("An error occurred in sending the alert message via Telegram")
        print(e)
        return False


while True:
    current_price = get_bitcoin_price()
    if current_price <= conf.threshold:
        print("Bitcoin has exceeded threshold")
        message = "Alert! The current Bitcoin Price is " + str(current_price)
        telegram_status = send_telegram_message(message)
        response = mybolt.digitalWrite('0', 'HIGH')
        print(response)
        time.sleep(5)
        response = mybolt.digitalWrite('0', 'LOW')
    time.sleep(10)

該程序的作用是在價格低于閾值時觸發警報并發送電報通知。

保存程序并使用sudo python3 alert.py

3.輸出

?

pYYBAGOYkfOAJNJ6AAArQUI5R-o078.jpg
?

?

poYBAGOYkgaAOahfAAL0qpyrYJw346.jpg
?

?


下載該資料的人也在下載 下載該資料的人還在閱讀
更多 >

評論

查看更多

下載排行

本周

  1. 1山景DSP芯片AP8248A2數據手冊
  2. 1.06 MB  |  532次下載  |  免費
  3. 2RK3399完整板原理圖(支持平板,盒子VR)
  4. 3.28 MB  |  339次下載  |  免費
  5. 3TC358743XBG評估板參考手冊
  6. 1.36 MB  |  330次下載  |  免費
  7. 4DFM軟件使用教程
  8. 0.84 MB  |  295次下載  |  免費
  9. 5元宇宙深度解析—未來的未來-風口還是泡沫
  10. 6.40 MB  |  227次下載  |  免費
  11. 6迪文DGUS開發指南
  12. 31.67 MB  |  194次下載  |  免費
  13. 7元宇宙底層硬件系列報告
  14. 13.42 MB  |  182次下載  |  免費
  15. 8FP5207XR-G1中文應用手冊
  16. 1.09 MB  |  178次下載  |  免費

本月

  1. 1OrCAD10.5下載OrCAD10.5中文版軟件
  2. 0.00 MB  |  234315次下載  |  免費
  3. 2555集成電路應用800例(新編版)
  4. 0.00 MB  |  33566次下載  |  免費
  5. 3接口電路圖大全
  6. 未知  |  30323次下載  |  免費
  7. 4開關電源設計實例指南
  8. 未知  |  21549次下載  |  免費
  9. 5電氣工程師手冊免費下載(新編第二版pdf電子書)
  10. 0.00 MB  |  15349次下載  |  免費
  11. 6數字電路基礎pdf(下載)
  12. 未知  |  13750次下載  |  免費
  13. 7電子制作實例集錦 下載
  14. 未知  |  8113次下載  |  免費
  15. 8《LED驅動電路設計》 溫德爾著
  16. 0.00 MB  |  6656次下載  |  免費

總榜

  1. 1matlab軟件下載入口
  2. 未知  |  935054次下載  |  免費
  3. 2protel99se軟件下載(可英文版轉中文版)
  4. 78.1 MB  |  537798次下載  |  免費
  5. 3MATLAB 7.1 下載 (含軟件介紹)
  6. 未知  |  420027次下載  |  免費
  7. 4OrCAD10.5下載OrCAD10.5中文版軟件
  8. 0.00 MB  |  234315次下載  |  免費
  9. 5Altium DXP2002下載入口
  10. 未知  |  233046次下載  |  免費
  11. 6電路仿真軟件multisim 10.0免費下載
  12. 340992  |  191187次下載  |  免費
  13. 7十天學會AVR單片機與C語言視頻教程 下載
  14. 158M  |  183279次下載  |  免費
  15. 8proe5.0野火版下載(中文版免費下載)
  16. 未知  |  138040次下載  |  免費
亚洲欧美日韩精品久久_久久精品AⅤ无码中文_日本中文字幕有码在线播放_亚洲视频高清不卡在线观看
<acronym id="s8ci2"><small id="s8ci2"></small></acronym>
<rt id="s8ci2"></rt><rt id="s8ci2"><optgroup id="s8ci2"></optgroup></rt>
<acronym id="s8ci2"></acronym>
<acronym id="s8ci2"><center id="s8ci2"></center></acronym>