Thermal printer project

@Stu, part of the problem is that you are using too many versions of the thermal printer library. Can you tell me which library is the defacto one for use with exciting.io? If it is the lazyatom one then I can port it and you can go from there. :smile:

1 Like

@peekay123 Haha. I think I have tried them all.

Yes, ideally it’s the laztatom one. That seems to have been specifically adapted for use with exciting.printer.io

Thanks peekay123, you are turning out to be a legend! I do apologise for my lack of knowledge. I possibly took on more than I can chew with this one. Still, I had a good stab at it!

@Stu, I’ll port the ( correct :stuck_out_tongue: ) library and excite.io code tonight if I can and put it up on github as a whole. I think this is a cool project and having a working set is merited. :smile:

4 Likes

@Stu, after carefully reading the code on exciting-io, I now realize you do NOT need a printer driver to be added to the library. The print data you send via the web is already correctly formatted for the printer. Basically, you just need the exciting-io app, which you ported yourself and nothing else!

@peekay123 Oh! If that’s the case how do I define ‘printer’ after removing the adafruit printer library include.

For example, I currently have this (includes some old commented out code). I just tried printer = &Serial1; but still showing up errors when compiling.

// -- Initialize the printer connection

/*SoftwareSerial *printer;*/
printer = &Serial1;
/*Adafruit_Thermal printer;*/
#define PRINTER_WRITE(b) printer->write(b)

void initPrinter() {
//   printer = new SoftwareSerial(printer_RX_Pin, printer_TX_Pin);
//   printer->begin(19200);
  debug("Initializing printer");
  Serial.begin(9600);
  Serial1.begin(19200);
  printer.begin(&Serial1);
}

@Stu, couple of choices but the easiest is drop the “printer” var and do:

/*Adafruit_Thermal printer;*/
#define PRINTER_WRITE(b) Serial1.write(b)

    void initPrinter() {
      debug("Initializing printer");
      Serial.begin(9600);
      Serial1.begin(19200);
    }

We skip the whole printer pointer thing and just specify Serial1 since you are not using SoftwareSerial. It would be great if you could share pictures of the printout once you get this working! :smile:

@peekay123 That worked! … Kind of :slight_smile:
Managed to print a test page but was very faint so I’m going to play around with the heat time etc. the printers own test page does print ok so it’s getting enough power.

I think there is an issue with the backend. Looks like one of the images it creates failed and the app just gets stuck in a loop trying to download the data. I will have a word with exciting.io and see what we can do.

I’m have lots of trouble flashing to the core though. I suppose because the serial is getting locked up. I’m finding its often not showing online so I have to keep factory resetting it.

Might see if I can test it getting an image from my own server. Or just install their backend

I have the box I’m going to package it in already set up. Should be quite nice when it’s all working. Thanks for all your help on this. Once it’s wokrkibg I will post back my final code (cleaned up)

1 Like

@peekay123 I am now flashing the core over USB which makes life much easier! For a short while it was working - it was downloading data and printing but the print was very faint. But it was at least working fairly reliably for a short time … until it just stopped working.

It seems to get stuck in the loop when it is waiting for data and nothing every gets written to the SD card. I flashed the sd card test app again and it reads/writes correctly.

I was looking through the source code of exciting.io, there are some references to heat time etc. in here https://github.com/exciting-io/printer/blob/master/lib/printer/print_processor/a2_raw.rb but how could this commands be sent to the core. I don’t get it.

Anyway. I will keep experiments. Its all way above my level I’m afraid :frowning:

Would I bee able to use spark core cloud api to send data to the core, save it to SD and print. Not quite sure where to go next with this.

@peekay123 Hi. I got it all working in the end. I will post my code soon after giving it a tidy up.

I totally re-wired the circuit, its possible the SD card was not reading/writing correctly. I then tried powering the printer with 9v and the prints came out correctly. I presume the printer was not getting enough current. I then stupidly fried my core! I accidentally connected to the 9v to vin :cry: Live and learn I suppose!

I have ordered some more cores. I have another power supply that I can adjust. Is it safe to use 6v - 3000mA? It should be enough current for the printer but I am worried about the core!

6v is the upper limit, but add a diode in there and it will drop that by 0.6-0.7v so putting it in the 5.3/5.4v range. you could even go 2 diodes to be safe and make it 4.8v

I can adjust the power supply to 5v still at 3A - hopefully still enough current for the thermal printer. 3A ok for the core?

@Stu, you can also use two supplies, sharing a common ground. Try powering both with 5v and see if you get good print quality. DON’T power the printer off the Vin pin of the Core. Instead split the power wires so you power the Core and the printer in parallel. The Core will consume whatever current it needs, as will the printer. I would also add a set of decoupling capacitors at the Core - a 100uF (or more) and a 0.1uf, between the Vin and GND. :smile:

2 Likes

@peekay123 Still waiting for my replacement core … in the meantime I have been tidying up my wiring.

Is this the correct placement for the capacitors, across the power rails (5v coming in from the re and black wires on the right)? Or should it be a set of capacitor across on each rail, 5v and GND?

@Stu, the capacitors need to be close to the power pins on the Core. If you have a larger electrolytic (100uF), you should use that as well. You could also put a similar capacitor arrangement on the 3.3V rail but it’s not absolutely necessary. :smile:

@Stu Have you posted your final code yet? If so, where is it? I have a thermal printer I am thinking of connecting to a Spark Core, and I wanted to take a look at your code. Thanks in advance.

I am soon to be the proud owner of one of these Thermal Printers, I have been trying to get code ready for when it arrives

@Stu did you end up making it all work? Any chance you can share the code?

Another one of these thermal printers ordered here and intended to use with Photon. Can I find @Stu’s code anywhere or is this library the only available resource? Thanks!

Is there any final code?
I would love to do a similar project.