Created
May 15, 2023 23:36
-
-
Save lizzybrooks/d2a19452b596c97fd0c30ba7eb9d353f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import serial | |
uart = serial.Serial("/dev/serial0", baudrate=19200, timeout = 3000) | |
import firebase_admin | |
from firebase_admin import credentials | |
from firebase_admin import db | |
import adafruit_thermal_printer | |
ThermalPrinter = adafruit_thermal_printer.get_printer_class(2.69) | |
# Fetch the service account key JSON file contents | |
cred = credentials.Certificate('secret.json') | |
# Initialize the app with a service account, granting admin privileges | |
firebase_admin.initialize_app(cred, { | |
'databaseURL': "https://saferheart-c5f98-default-rtdb.firebaseio.com" | |
}) | |
printer = ThermalPrinter(uart) | |
ref = db.reference('SAFERHEART') | |
ref = db.reference('SAFERHEART') | |
myData = ref.get() | |
#bprint(myData) | |
#print(myData['-NUzVu3L4BeSRk-2K8zp']['messageContent']) | |
keys = (list(myData.keys())) | |
#print(keys) | |
# for key in keys: | |
# print(myData[key]['messageContent']) | |
currentMessage = len(keys)-1 | |
#print(currentMessage) | |
nowPrinting = (myData[keys[currentMessage]]['messageContent']) | |
print(nowPrinting) | |
printer.print(nowPrinting) | |
printer.feed(4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment