比特幣 (Bitcoin) 是由中本聰於 2009 年所提出的去中心化支付系統,從 2012 年 1 塊比特幣可對換 4.55 美金,到 2017 年 1 塊比特幣可對換 2789.4 美金,當中相差了 613 倍,也因而造成許多網友開始密切關注比特幣最新行情並也造成近日隨著挖礦導致顯示卡全球大缺貨,而本文描述如何利用 LinkIt Smart 7688 於每分鐘顯示最新的比特幣匯率於顯示器上。
學習目標
- 每分鐘取得目前最新比特幣 (Bitcoin) 匯率
- 將匯率顯示於 OLED
情境
執行步驟
前置準備作業
一台電腦
LinkIt Smart 7688 Duo 開發板
Arduino Breakout for LinkIt Smart 7688 Duo
Grove - OLED Display
Micro-USB Cable
將 LinkIt Smart 7688 與 Arduino Breakout for LinkIt Smart 7688 Duo 組裝、Grove - OLED Display 裝到 I2C 的位置並將 Micro-USB Cable 連接至電腦與 LinkIt Smart 7688
電腦端相關設定 - 請參考 LinkIt Smart 7688 / 7688 Duo 基礎教學 文章
連接圖
❖ 感謝 【 Anker Taiwan 】 提供拉不斷的 Micro USB Cable
LinkIt Smart 7688 端 - 下方範例使用 macOS Sierra
Step 1. 開啟 Arduino IDE
Step 2. 下載 Grove OLED Display 函式庫
❖ 2.1 ① 開啟瀏覽器再前往下方網址
https://github.com/Seeed-Studio/OLED_Display_128X64
② 點選【 Clone or download 】➙ 點選【 Download ZIP 】
Step 3. 匯入 Grove OLED Display 函式庫
❖ 3.1 將剛下載的函式庫匯入到 Arduino IDE
① 點選上方的【 草稿碼 】 ➙ 【 Include Library 】 ➙ 【 Add .ZIP Library... 】
② 將下載的函式庫匯入到 IDE 中
Step 4. 開啟 Arduino IDE
❖ 4.1 下載 【 getDHT_Bridge.ino 】 的程式碼
請到下方 URL 中的程式碼複制到 Arduino IDE
https://github.com/ArcherHuang/Linkit_Smart_7688/blob/master/IoT%20Cloud/Arduino/Serial_Bitcoin/Serial_Bitcoin.ino
Step 5. 燒錄程式
❖ 5.1 點選 【 檔案 】➙ 【 上傳 】
Step 6. 透過 Python 取得比特幣資訊並於 OLED 中顯示
❖ 6.1 下載 【 getBitcoin.py 】 的程式碼
請到下方 URL 中的程式碼複制到 IDE
https://github.com/ArcherHuang/Linkit_Smart_7688/blob/master/IoT%20Cloud/Python/getBitcoin.py
Step 7. 將上步驟的 Python 傳送到 LinkIt Smart 7688 開發板中
請參考【 傳送檔案與登入到開發板 】 教學文章
Step 8. 遠端登入到 LinkIt Smart 7688 開發板中
請參考【 傳送檔案與登入到開發板 】 教學文章
Step 9. 安裝相依套件
執行下方指令
① pip install pytz
Step 10. 執行 Python 程式
python getBitcoin.py