Sending image data from python to arduino to print with ttl thermal printer?

Hi, I'm doing my personal school job with python and arduino with TTL based thermal printer.

Currently, I'm done with a job that send string from python to arduino to print string with thermal printer.
Now, I wanna do to send bytes data of Black/White image from python to arduino, and printing it with thermal printer.

I'm using Adafruit-Thermal-Printer-Library which provided in Adafruit with its tutorial, and python 3.7 with newest version of pyserial(It's 3.4).

I thought printing an image is working with const bytes array which already compiled with .h file in arduino, but I need new way that use python and arduino together with serial.

So as I designed, what I need is:

  • How to change normal image to B/W bytes-based image in python(with PIL or opencv?)
  • How I can send encoded image data from python to arduino with serial(I can send string but how about bytes image?)

And this is my workspace specifications, hope it helps:

  • PC OS : Windows 10
  • Arduino : Arduino Uno
  • Printer : TTL based printer with normal TX/RX pin

How can I start? or is there any reference to help me?

Thanks

This Simple Python - Arduino demo may help get you started.

...R

Robin2:
This Simple Python - Arduino demo may help get you started.

...R

Hello, Robin, Thanks for you reply.
I got some inspiration from your codes and adapt your start and end token system :smiley:

Btw, I'm not sure how to send bytes array of BW bitmap images from python to arduino and store it to single variable in arduino to print it out.

Any ideas?

DevFallingstar:
Btw, I'm not sure how to send bytes array of BW bitmap images from python to arduino and store it to single variable in arduino to print it out.

How many bytes are there in an image and what Arduino board are you using?

...R