<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天內不再提示
電子發燒友網>電子資料下載>電子資料>樹莓派監視器開源項目

樹莓派監視器開源項目

2023-06-14 | zip | 0.00 MB | 次下載 | 免費

資料介紹

描述

向任何 Raspberry Pi 項目添加狀態監視器對于實時了解 CPU 在使用、溫度和 RAM 使用以及重要連接信息方面的執行情況非常有用。如果超頻是您的事,那么這對于查看您的設置對 Pi 的影響并做出相應的調整非常有價值。

Breadboard Mates TIMI-130顯示器與 Breadboard Mates Pi 適配器一起,是該項目的完美選擇,因為它易于使用且啟動和運行所需的代碼簡單。

面包板伴侶 TIMI-130
?

Breadboard Mates 提供了一個 Python 庫,使 Python 編碼體驗變得輕松。

第 1 步:需要什么。

該項目需要以下內容。

硬件

軟件

第 2 步:樹莓派設置。

通過訪問https://www.raspberrypi.com/software/并按照安裝操作系統的說明,設置 Raspberry Pi 非常容易。

安裝 Python 庫和 Git 克隆項目文件需要 Internet 連接。

Pi OS 需要配置為啟用 SSH 并啟用我們將用來與 TIMI-130 通信的串行端口 (UART)。

第 3 步:TIMI-130 設置。

Pi 適配器需要連接到 Pi GPIO 接頭和連接到適配器的 TIMI-130,如下所示。

poYBAGNYweiAUT97AAaYdV2kusI061.png
?

由于需要為狀態監視器配置 TIMI-130,因此需要將 Pi 適配器上的開關設置為 PROG。

接下來,將Mates Programmer連接到 Pi 適配器。

pYYBAGNYwe2ANyAJAAZjZYfyNjY613.png
?

USB 電纜連接到 Mates Programmer 和 PC USB 端口。TIMI-130 現在已準備好安裝狀態監視器項目。

需要Mates Studio來配置 TIMI-130,您可以從這里下載https://breadboardmates.com/products/mates-studio/

創建狀態監視器項目當您啟動 Mates Studio 時,系統會提示您選擇您的產品。

pYYBAGNYwfCAOzVhAACkvhoAaTU576.png
?

單擊 TIMI-130,TIMI-130 的圖形表示將出現在右側面板上。

pYYBAGNYwfKASBpLAAC4NziNZSQ658.png
?

在 TIMI-130 的圖像上單擊兩次可將顯示屏旋轉 180 度。

pYYBAGNYwfWAZwa-AAC84VQ1GYo868.png
?

點擊 CONFIRM 然后選擇Commander Environment 。

poYBAGNYwfiAYT2JAAD65YW72bc281.png
?

Commander 環境現在將打開。

poYBAGNYwfuAA33-AABuRGM3oC8411.png
?

點擊“+”瀏覽頁面庫。

然后從通知選項卡中選擇狀態和資源監視器,然后單擊確認。

poYBAGNYwf2AO2RLAAE_wOk6RWE514.png
?

波特率需要從 9600 更改為 115200,方法是單擊工具和配置按鈕并選擇 115200

pYYBAGNYwgCAJUuIAAGkKH26ylU803.png
?

接下來,通過單擊 COM 面板并從下拉菜單中選擇正確的端口,為 Mates Programmer 選擇 com 端口。

poYBAGNYwgOABTesAAF8sS42j-E801.png
?

最后,單擊上傳按鈕將狀態監視器上傳到 TIMI-30。

poYBAGNYwgWABA-uAAAOc_F-EkI370.png
?

狀態監視器現在將顯示在 TIMI-130 上

poYBAGNYwgqAJ7KQAAPSfzxMruM355.png
?

現在可以從 Pi 適配器中移除 USB 引線和 Mates Programmer。Pi 適配器開關現在可以設置為 HOST,準備好接收來自 Pi 的命令。

第 4 步:安裝 Python 應用程序。

所有最近的 Raspberry Pi OS Distro 都預裝了 Python 3,因此我們可以使用 PIP 安裝所需的 Python 庫。

psutil庫可以通過運行安裝

pip3 install psutil

接下來,可以通過運行安裝 Breadboard Mates Controller 庫

pip3 install rpi-mates-controller

接下來,我們可以從 Github 克隆 Python 代碼

git clone https://github.com/BreadBoardMates/RPi-Status-Monitor.git

或者,可以從這里下載 Python 代碼https://github.com/BreadBoardMates/RPi-Status-Monitor

第 5 步:運行應用程序。

移動到 RPi-Status-Monitor 文件夾

cd RPi-Status-Monitor

然后運行應用程序

python3 ./BBMPiStatusMonitor.py

TIMI-130 應首先重置為屏幕外,然后開始顯示 CPU 使用狀態、CPU 溫度和 RAM 使用狀態以及連接的 IP 地址和正常運行時間。

如果您希望狀態監視器作為后臺任務運行,只需在命令中添加“&”即可。

python3 ./BBMPiStatusMonitor.py &

享受您閃亮的 Raspberry Pi 顯示器。

通過在 Mates Studio 中創建新頁面并更改 Python 代碼以匹配所使用的任何新小部件,可以簡單地更改或改進該項目以獲得所需的外觀。唯一的限制是想象力。

?

Python 代碼。

import time
import sys
import psutil
import socket
import fcntl
import struct
import uptime
from gpiozero import CPUTemperature
from rpi_mates.controller import RPiMatesController as MatesController
from mates.constants import *

def up():
    t = uptime.uptime()
    days = 0
    hours = 0
    min = 0
    out = ''
    while t > 86400:
        t -= 86400
        days += 1
    while t > 3600:
        t -= 3600
        hours += 1
    while t > 60:
        t -= 60
        min += 1
    out += str(days) + 'd '
    out += str(hours) + 'h '
    out += str(min) + 'm'
    return out


def get_interface_ipaddress(network):
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
        return socket.inet_ntoa(fcntl.ioctl(s.fileno(), 0x8915,
                                struct.pack('256s',
                                network[:15].encode('utf-8')))[20:24])  # SIOCGIFADDR
    except OSError:
        return '0.0.0.0'


if __name__ == '__main__':

    mates = MatesController('/dev/ttyS0')

    mates.begin(115200)

    gtime = up()
    lastCpuUse = 0
    lastTemp = 0
    lastlTemp = 0
    lastRamUse = 0
    lastWIPaddr = '0.0.0.0'
    lastEIPaddr = '0.0.0.0'

    mates.updateTextArea(5, gtime, True)
    cpu = CPUTemperature()
    lastlTemp = int(cpu.temperature * 10)

    IPinterval = 0

    while True:
        cpu = CPUTemperature()
        gcpu = int(cpu.temperature)
        lcpu = int(cpu.temperature * 10)
        cpuuse = int(psutil.cpu_percent())
        ramuse = int(psutil.virtual_memory().percent)

        if cpuuse < lastCpuUse:
            lastCpuUse = lastCpuUse - (1 + (lastCpuUse - cpuuse > 9))
        if cpuuse > lastCpuUse:
            lastCpuUse = lastCpuUse + 1 + (cpuuse - lastCpuUse > 9)
        if gcpu < lastTemp:
            lastTemp = lastTemp - (1 + (lastTemp - gcpu > 9))
        if gcpu > lastTemp:
            lastTemp = lastTemp + 1 + (gcpu - lastTemp > 9)
        if lcpu < lastlTemp:
            lastlTemp = lastlTemp - 1
        if lcpu > lastlTemp:
            lastlTemp = lastlTemp + 1
        if ramuse < lastRamUse:
            lastRamUse = lastRamUse - (1 + (lastRamUse - ramuse > 9))
        if ramuse > lastRamUse:
            lastRamUse = lastRamUse + 1 + (ramuse - lastRamUse > 9)

        if gcpu != lastTemp:
            mates.setWidgetValueByIndex(MatesWidget.MATES_MEDIA_GAUGE_B,0, lastTemp)
        if lcpu != lastlTemp:
            mates.setLedDigitsShortValue(0, lastlTemp)
        if cpuuse != lastCpuUse:
            mates.setWidgetValueByIndex(MatesWidget.MATES_MEDIA_GAUGE_B,1, lastCpuUse)
            mates.setLedDigitsShortValue(1, lastCpuUse)
        if ramuse != lastRamUse:
            mates.setWidgetValueByIndex(MatesWidget.MATES_MEDIA_GAUGE_B,2, lastRamUse)
            mates.setLedDigitsShortValue(2, lastRamUse)

        if IPinterval > 20:
            tempIPaddr = get_interface_ipaddress('eth0')
            if tempIPaddr != lastEIPaddr:
                mates.updateTextArea(1, tempIPaddr, True)
                lastEIPaddr = tempIPaddr

            tempIPaddr = get_interface_ipaddress('wlan0')
            if tempIPaddr != lastWIPaddr:
                mates.updateTextArea(3, tempIPaddr, True)
                lastWIPaddr = tempIPaddr
            IPinterval = 0

        IPinterval = IPinterval + 1
        time.sleep(0.060)

        tempTime = up()
        if tempTime != gtime:
            mates.updateTextArea(5, tempTime, True)
            gtime = tempTime
        time.sleep(0.040)

Python 代碼將創建一個 Mates Controller 實例并以 115200 波特率啟動它。

mates = MatesController('/dev/ttyS0')
mates.begin(115200)

然后創建一組變量,這些變量將在每次更新各種狀態后設置。這使主循環能夠將剛剛讀取的狀態與其上一個狀態進行比較,然后僅在其值發生變化時才更新相應的小部件。

lastCpuUse = 0
lastTemp = 0
lastlTemp = 0
lastRamUse = 0
lastWIPaddr = '0.0.0.0'
lastEIPaddr = '0.0.0.0'

如果需要,循環的每次迭代都將使用以下簡單命令更新顯示屏上的小部件

mates.setWidgetValueByIndex(MatesWidget.MATES_MEDIA_GAUGE_B,0, lastTemp)
mates.setLedDigitsShortValue(0, lastlTemp)
mates.setWidgetValueByIndex(MatesWidget.MATES_MEDIA_GAUGE_B,1, lastCpuUse)
mates.setLedDigitsShortValue(1, lastCpuUse)
mates.setWidgetValueByIndex(MatesWidget.MATES_MEDIA_GAUGE_B,2, lastRamUse)
mates.setLedDigitsShortValue(2, lastRamUse)
mates.updateTextArea(1, tempIPaddr, True)
mates.updateTextArea(3, tempIPaddr, True)
mates.updateTextArea(5, tempTime, True)

可下載資源

以下是軟件應用程序、庫和已完成項目文件的鏈接。


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

評論

查看更多

下載排行

本周

  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>