0

I'm using an arduino uno with a thermal printer and the following code:

#include "Adafruit_Thermal.h"
#include "skull.h"
#include "SoftwareSerial.h"
int printer_TX_Pin = 8;  // This is the yellow wire
int printer_RX_Pin = 9;  // This is the green wire
Adafruit_Thermal printer(printer_RX_Pin, printer_TX_Pin);

void setupPrinter() {
  printer.begin();
};

void doPrint(char* output) {
  Serial.print("Will print: ");
  Serial.print(output);
  Serial.print("\n");
  printer.println(output);
  printer.feed(2);
}

void setup() {
  setupPrinter();
  doPrint("This is a test to see if it will print only from power supply");
}

void loop() {
}

That code works fine if the arduino and printer are plugged into 5v and the arduino is also plugged in to a computer with USB. Once I remove the USB cable it starts printing:

This is a test to see if it will
This is a test to see if it will
This is a test to see if it will
This is a test to see if it will
This is a test to see if it will

over and over infinitely. In other programs it prints a slightly garbled first line then stops. When I remove the serial.print lines, this doesn't occur. Why would that be?

  • Are you using a standard Arduino board? E.g. the Arduino Uno? – Peter Bloomfield Mar 22 '15 at 23:34
  • Yes, it is an arduino uno – Tom Mar 23 '15 at 15:20
3

It seems likely that your Arduino is repeatedly resetting, which means it's starting the program again from the beginning all the time. This can be caused by insufficient power.

For the standard 5v Arduino boards, the minimum recommended voltage for an external power supply is usually 7v. An on-board regulator brings it down to 5v.

Technically, you can run them directly from an external 5v supply. However, you have to ensure that it's properly regulated, and that you bypass the on-board regulator.

Obviously you also have to ensure your external supply is capable of sourcing sufficient current. If you're just running an Arduino and a small thermal printer then it's probably OK, but it's certainly worth checking.

  • I'm using a 5v 4amp power supply with the arduino, neopixels and the printer powered directly from it and then a PIR sensor and adafruit musicmaker shield + 3w 4ohm speaker powered from the arduino. The printers maximum current draw is 1.5 amps. Should I use a 7v supply in this case? I have a program that runs the lights and sound and then resets only when it gets to the printing part. I suppose it could be when the printer runs this causes a problem with the power causing it to reset? Why would having the USB help though? I thought that the usb power was bypassed when using DC power. – Tom Mar 23 '15 at 15:17
  • 1
    @Tom - A supply of 7-12V would be a good idea. It will be falling-back on the USB power when possible because your DC supply is too low. – Peter Bloomfield Mar 23 '15 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.