Coinkite's blockclock is amazing. Blockclock inspired me to develop one using M5StickC IoT device for a cheaper price. Here is the result:
(display is pixelated due to the closeup shot)
Follow the steps for your next DIY project
- Buy M5StickC from here. It costs around $13.95 without a shipping charge
- Next you need to flash it with UIFlow firmware using M5's firmware burning tool. Please search on youtube for 'how-tos'. M5stack has hosted multiple videos on youtube. If your M5stickC is already flashed with UIFlow when you receive it, you can skip this step
- Connect your M5StickC with your wifi
- M5stack has an online IDE to code and flash your device remotely. Please connect your device with UIFlow by following the instruction.
- Get your coinmarketcap API to get the BTC price. Coinmarketcap offers a few thousand API calls free for a month. Create an API key in their portal.
- Copy the following micro python program in the UIFlow interface and run it to flash the device. Don't forget to replace coinmarketcap API key in the code.
from m5stack import * from m5ui import * from uiflow import * import urequests import json def setFont(): #lcd.clear() #setScreenColor(0x006600) lcd.setRotation(1) lcd.font(lcd. FONT_Default) #lcd.font(lcd.FONT_Small) #lcd.setTextColor(0xffffff,0x006600) def redBackDrop(): lcd.clear() setFont() setScreenColor(0xf80b0b) lcd.setTextColor(0xffffff,0xf80b0b) def greenBackDrop(): lcd.clear() setFont() setScreenColor(0x009900) lcd.setTextColor(0xffffff,0x009900) def displayContent(symbol,price, marketcap,block): lcd.print(str(symbol), 60, 5) lcd.print("Price : $" + str(price), 5, 20) lcd.print("M.Cap: $" + str(marketcap) + " Bn", 5, 35) if str(symbol) == 'BTC': lcd.print("1$ : " + str(round(1/(price/100000000))) + " Sat", 5, 50) lcd.print("Block : " + str(block) + "", 5, 65) def getAPI(): result = dict() try: # Replace 'X-CMC_PRO_API_KEY' with your coinmarketcap API req = urequests.request(method='GET', url='https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=BTC,ETH,LTC', headers={'X-CMC_PRO_API_KEY':'<replace your coinmarketcap API key here>','Accept':'application/json'}) req1 = urequests.request(method='GET', url='https://mempool.space/api/blocks/tip/height') BTCPrice = round(json.loads((req.text))["data"]["BTC"]["quote"]["USD"]["price"],2) BTCMarketCap = round(json.loads((req.text))["data"]["BTC"]["quote"]["USD"]["market_cap"]/1000000000,2) BTCBlock = req1.text result['btcprice'] = BTCPrice result['btcmarketcap'] = BTCMarketCap result['block'] = BTCBlock return result except: setScreenColor(0xff0000) lcd.print("Can't fetch API",5,30) result['btcprice'] = 0 result['btcmarketcap'] = 0 result['block'] = 0 result['ethprice'] = 0 result['ethmarketcap'] = 0 return result while True: result = getAPI() redBackDrop() displayContent('BTC', result['btcprice'],result['btcmarketcap'],result['block']) wait(150) greenBackDrop() displayContent('BTC', result['btcprice'],result['btcmarketcap'],result['block']) wait(150)
(this code does not format well on M5StickC Plus display)
The total cost of this project is not more than $30. It serves the purpose though it is not as beautiful as blockclock. I bought bitcoin for the rest of the cost of blockclock. Stack sats!!