A new companion on my desk

in STEMGeeks2 months ago (edited)

I have this Pi Zero W for a while doing nothing but now it has a use case. :) I started monitoring my small GPU rig with it.

Scenario 1: Rig is up, everything is OK.


mining_ok.jpeg

Scenario 2: Rig is down, alarm!



mining_nok.jpeg


It was pretty cool to play with inky phat. I'll definitely try to hack more sophisticated things on it.

I use hiveon as pool, so it gathers stats from there. Based on the reported hash rate, one of the two different drawings shows up on the e-ink screen. If you want to try this, make sure you have libraries installed. (arrow, requests, etc.)

Here is the full script:

import requests
import inkyphat
import arrow
import os

wallet = os.environ['WALLET']
font_file = inkyphat.fonts.PressStart2P
font = inkyphat.ImageFont.truetype(font_file, 11)
inkyphat.set_colour('red')


def main():
    r = requests.get(f"https://hiveon.net/api/v0/miner/{wallet}?currency=ETH")
    r.raise_for_status()
    data = r.json().get("data")
    hash_rate = int(data.get("hashrate"))
    utc = arrow.utcnow()
    local = utc.shift(hours=2)
    last_update = local.format('HH:mm')

    if hash_rate > 0:
        mh = round(hash_rate / 1e6, 2)
        msg = f"MINING { mh} MH"

        inkyphat.set_border(inkyphat.WHITE)
        text_colour = inkyphat.BLACK
    else:
        msg = "Rig is DOWN!"
        inkyphat.set_border(inkyphat.RED)
        text_colour = inkyphat.RED

    print(msg)
    msg2 = last_update
    w, h = font.getsize(msg)
    msg_x = int((inkyphat.WIDTH - w) / 2)
    msg_y = int((inkyphat.HEIGHT - h) / 2)

    inkyphat.text((msg_x, msg_y - 11), msg, text_colour, font=font)
    inkyphat.text((inkyphat.WIDTH - 66, inkyphat.HEIGHT - 15), msg2, text_colour, font=font)

    inkyphat.show()

main()
Sort:  

Wish there were bigger e-ink displays. The small ones are relatively cheap though.

I’ve just been building a new open frame GPU mining rig from existing materials (aluminium extrusions, melamine panelling and 3D printed parts) and computer parts incl RX580s from earlier mining.

Hope to have it working soon.
img_2527.heic

Looks pretty cool mate! Mine doesn't look that organized. :)