I'm working on a python application that's running on a raspberry pi that is intended to receive a data string from Azure IoT Hub, make a QR code off that string, then print that QR code as a label on a Brother QL 800 label printer. I've got it successfully receiving data from Azure IoT Hub and making QR codes, but I can't seem to get my label printer to print anything. Whenever I send a message to my pi from Azure, the printer does nothing and the green light over the power button turns too a blinking red. Here's the code I've got so far

import time import qrcode import cups from azure.iot.device import IoTHubDeviceClient CONNECTION_STRING = (Not Showing This) device_client = IoTHubDeviceClient.create_from_connection_string(CONNECTION_STRING) device_client.connect() def message_handler(message): try: print("Message received:") messageDataString = message.data.decode("utf-8") print(messageDataString) img = qrcode.make(messageDataString) img.save(str(messageDataString) + ".png") conn = cups.Connection() printers = conn.getPrinters() printerName = list(printers.keys())[0] conn.printFile(printerName, "/home/ahelm/printApi/" + str(messageDataString) + ".png", "", {}) print(printerName) except Exception as e: print(e) try: device_client.on_message_received = message_handler while True: time.sleep(300) except KeyboardInterrupt: print("IoT Hub Cloud to Device Messaging Device Sample Stopped") finally: print("Shutting Down") device_client.shutdown()

The past two times I've run this the console has printed this, but still, no label prints

Message received: test5 Brother_QL-800

Any help or ideas would be greatly appreciated!

gummy714's user avatar

1

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.