0

Instant Camera with Pi Zero & Thermal Printer problems
Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Please be positive and constructive with your questions and comments.

Instant Camera with Pi Zero & Thermal Printer problems

by mrchrisdecastro on Sun May 29, 2016 8:29 pm

Been trying out the Instant Camerahttps://learn.adafruit.com/instant-camera-using-raspberry-pi-and-thermal-printer project using a Pi Zero, Pi Camera v2 & the Nano Thermal Printer. Followed the system setup instructions and wired up everything right but there is something wrong with the camera.sh script.

When the script is executed from rc.local the boot hangs randomly, sometimes at Creating Color Profiles, or Starting NTP daemon or Started Cleaning Temporary Directories. The led flashes when rc.local executes then stops and the boot process gets stuck. Left the pi on overnight hoping it would get past Cleaning Temporary Directories

Was able to SSH into the pi and comment out the camera.sh script.

Commented out camera.sh in rc.local and boot completes to prompt. When I execute camera.sh the prompt shows:
request id is ZJ-58-4 (0 file(s))

raspistill -o cam.jpg produces an image

I'm not quite sure how to debug from this.

IMG_4638.jpg
IMG_4638.jpg (664.72 KiB) Viewed 716 times

mrchrisdecastro
 
Posts: 8
Joined: Mon May 16, 2016 1:26 pm

Re: Instant Camera with Pi Zero & Thermal Printer problems

by adafruit_support_rick on Mon May 30, 2016 1:24 pm

Try soldering your wires. It really won't work if you don't

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Instant Camera with Pi Zero & Thermal Printer problems

by mrchrisdecastro on Tue May 31, 2016 7:26 pm

Soldered everything in and now stuck at
Started CUPS Printing Service.
Started CUPS Printing Service.
request id is ZJ-58-13 (0 file(s).)
Started CUPS Printing Service.
Started CUPS Printing Service.

Tried swapping the TX / RX cables between gpio's 14 & 15 and still no dice

Is there a command I can use to check the printer output?

mrchrisdecastro
 
Posts: 8
Joined: Mon May 16, 2016 1:26 pm

Re: Instant Camera with Pi Zero & Thermal Printer problems

by michaelmeissner on Wed Jun 01, 2016 8:23 am

One thing I've thought about since learning about the thermal printer is the power draw. According to the specs, the printer draws something like 1.5 amps at 5 volts. The Raspberry Pi + camera probably draws about 0.25 amps without a monitor. You used Energizer AA batteries, and perhaps they can't provide enough power for the whole combo.

The guide uses Enloop batteries, and I know from using Enloops in flashes, that Enloops can provide a little more power than normal batteries. However, a few years ago, Enloops disappeared from local brick & mortar sellers, and typically you can only get them online.

I don't know if it would help to upgrade to Enloops (or if you have had the batteries for awhile, getting new Energizer batteries). Or whether it is better to go to say 8 AA batteries (or a 7.4 volt li-po battery bought elsewhere) and a UEBC to reduce the voltage to 5 volts with 3 amps or so of power available.

michaelmeissner
 
Posts: 1377
Joined: Wed Aug 29, 2012 12:40 am

Re: Instant Camera with Pi Zero & Thermal Printer problems

by pburgess on Wed Jun 01, 2016 1:15 pm

Try echoing something to the serial device and see if there's a response from the printer, e.g.
echo 'This is a test' > /dev/ttyAMA0
-or-
cat /boot/cmdline.txt > /dev/ttyAMA0

You can also try running 'screen' on the port and typing some stuff. I don't recall if this is installed by default in Raspbian (don't think so), in which case:
sudo apt-get install screen
screen /dev/ttyAMA0 9600

(The latter assumes the Pi is on a network, which isn't always practical with the Pi Zero. Hence the guide's recommendation to set up on a more capable system and then move the card over.)

The hang-on-boot problem isn't always indicative of what's actually going on at the moment. For example, the boot-time filesystem consistency check may be chewing on something while other (unrelated) messages are displayed. (Speaking of which, are you using the halt button before powering off, and allowing it enough time to run? If you hold the halt button, do you get a steady-on LED for 15 seconds or so before the LED turns off?)

pburgess
 
Posts: 4041
Joined: Sun Oct 26, 2008 2:29 am

Re: Instant Camera with Pi Zero & Thermal Printer problems

by mrchrisdecastro on Thu Jun 02, 2016 9:01 am

Replaced power with a 5v 3a source just to rule power out as a problem.
I have a usb ethernet adapter that I SSH into to edit rc.local to comment out camera.sh
The shutdown button works and I use it when I can.
The echo and cat commands don't seem to do anything.

Led on the shutter button works. Blinks until I hit it.
When I do hit the shutter it shows:
request id is ZJ-58-20 (0 file(s).)
Started CUPS Printing Service.
Started CUPS Printing Service.

Where the number after ZJ-58-XX increases every time I try the shutter, but then the system stops.
You can still reboot from this.

Enabled serial in the raspi-config to check that the RX/TX connections are working and the printer spat out the test page then a bunch of gibberish. I'm assuming that means the printer is working.

What should I try next?

mrchrisdecastro
 
Posts: 8
Joined: Mon May 16, 2016 1:26 pm

Re: Instant Camera with Pi Zero & Thermal Printer problems

by mrchrisdecastro on Tue Jun 07, 2016 7:38 pm

So tried another tutorial to see if I could get the printer to work.
https://learn.adafruit.com/networked-thermal-printer-using-cups-and-raspberry-pi?view=all

Installed the full version of Jesse and disabled serial.
Tried
Code: Select all | TOGGLE FULL SIZE
stty -F /dev/ttyAMA0 9600

and got back
Code: Select all | TOGGLE FULL SIZE
stty: /dev/ttyAMA0: No such file or directory


tried
Code: Select all | TOGGLE FULL SIZE
ls /dev/tty*

and no ttyAMA0

guessing this is the problem
googling to find an answer but having a tough time finding a solution

mrchrisdecastro
 
Posts: 8
Joined: Mon May 16, 2016 1:26 pm

Re: Instant Camera with Pi Zero & Thermal Printer problems

by michaelmeissner on Tue Jun 07, 2016 7:56 pm

You might need to enable the serial port. A quick google found this: http://elinux.org/RPi_Serial_Connection.

You might want to try adding "enable_uart=1" to config.txt, even if you don't have a pi3. I haven't yet tried my printer on the pi (I've been soldering). Since I have the Tiny variant, mine also supports a USB interface, and I've printed a line via echo from my desktop system.

michaelmeissner
 
Posts: 1377
Joined: Wed Aug 29, 2012 12:40 am

Re: Instant Camera with Pi Zero & Thermal Printer problems

by mrchrisdecastro on Tue Jun 07, 2016 8:40 pm

IT LIVES!

Thank you michaelmeissner!
echo now works
going to continue the install and hopefully have this camera up and running

mrchrisdecastro
 
Posts: 8
Joined: Mon May 16, 2016 1:26 pm

Re: Instant Camera with Pi Zero & Thermal Printer problems

by mrchrisdecastro on Tue Jun 07, 2016 9:49 pm

IMG_4682.jpg
IMG_4682.jpg (581.59 KiB) Viewed 627 times


SUCCESS!

Thanks for all your help
now time to figure out a sweet compact enclosure...

mrchrisdecastro
 
Posts: 8
Joined: Mon May 16, 2016 1:26 pm

Re: Instant Camera with Pi Zero & Thermal Printer problems

by michaelmeissner on Tue Jun 07, 2016 11:07 pm

Glad it helped!

michaelmeissner
 
Posts: 1377
Joined: Wed Aug 29, 2012 12:40 am

Re: Instant Camera with Pi Zero & Thermal Printer problems

by monoroto on Tue Jun 14, 2016 9:44 am

Thanks for posting this. I am working on an identical project with pi zero, but trying to add a pitft viewfinder. Phil Burgess stated in the build comments that the code provided does not support a pitft viewfinder. I installed raspian Jessie lite image with support for pitft 2.8, and it is working, but does anyone know how I could get it to preview the camera before pressing shutter to print? Thanks.

monoroto
 
Posts: 6
Joined: Wed May 04, 2016 2:10 pm

Re: Instant Camera with Pi Zero & Thermal Printer problems

by michaelmeissner on Tue Jun 14, 2016 11:41 am

Unfortunately, I'm not aware of something off the shelf that will work, so you will need to do some programming.

If you use an HDMI or composite display, you could use the raspistill command to provide a live preview and then have it save the image, and exit. Then you would downsize the image, and feed it to the printer queue. However, when I last checked raspistill about 6 months ago, it did not support the PiTFT monitors. At some point in the future, I will probably explore this avenue, but right now, I haven't had the time.

The DIY Raspberry Pi camera tutorial (https://learn.adafruit.com/diy-wifi-raspberry-pi-touch-cam) does support the PiTFT 2.8" monitor, but it doesn't support an HDMI or composite monitor (and the 3.5" monitor isn't supported full screen). You could presumably hack the python code to do the printing instead of saving the file (or save the file, and then downsize).

michaelmeissner
 
Posts: 1377
Joined: Wed Aug 29, 2012 12:40 am

Re: Instant Camera with Pi Zero & Thermal Printer problems

by monoroto on Tue Jun 14, 2016 2:04 pm

Thanks. I found a similar project called PolaPi (https://hackaday.io/project/7176-polapi) but it is not really a step by step tutorial for the software portion, and I am relatively new at writing code in Linux or python, so it may be a bit beyond me

"There is two main external library/executable used by the Java program to achieve picture capturing and printing.

First is the program raspividyuv (in /opt/vc/bin/ of raspbian). It is launched within Java with the argument -o - in order to get the pixels data on stdout in an inputStream.

Second is the use of the Pi4J library. The Serial port is configured to send image data to the printer, a GPIO pin is used to read lines advance of the printer and another GPIO for the 'shutter' button event.

Before the Java program starts, the primary frame buffer is copied to the second frame buffer used for the PiTFT screen in order to see the camera preview on it. This is done by the fbcp program. (Credits to tasanakorn)

The Java program continuously receive the camera image and build a buffered array of pixels. Once the shutter button is pressed, the event launch two sequential process. The gray-scale image is converted in monochrome with Floyd–Steinberg dithering method. Then the printing thread is started, sending data to the printer on the serial port.

The sources and builds are here on: github. On the jar folder, there is the executable .jar file, the built fbcp program, and the config.txt file. On the last file, there is the welcome message, the header message, and the printer serial speed."

monoroto
 
Posts: 6
Joined: Wed May 04, 2016 2:10 pm

Please be positive and constructive with your questions and comments.