PiInstant Kamera

Kompakte DIY-Sofortbildkamera auf Basis des Raspberry Pi Zero WH. Perfekt für spontane Schnappschüsse und Retro-Fotoprojekte: schnell, kostengünstig und flexibel anpassbar.

Raspberry Pi Instant Kamera mit Thermodrucker

Hardware:

Schaltplan

HardwareRPi Zero
Shutter Button5
Utility Button
Status LED13
Printer TX wte15 (RX Pi)
Printer RX blu14 (TX Pi)
Printer DTS grn
Effect Switch7
Busy LED21
Power LED

Thermodrucker:

https://leap.tardate.com/playground/thermalprinter/qr701basics

https://www.aliexpress.com/item/4000724315117.html?spm=a2g0s.9042311.0.0.27424c4dTTFXPs

Hardware Specs

  • small size, light weight, fully functional
  • simple, easy connection
  • high-speed, high-quality, stylish
  • standard GB2312 large font
  • Printing method: Thermal dot line printing
  • RS232 / TTL interfaces, voltage 5-9V / 12V
FeatureSepcification
printing methodThermal line
Print width48 mm
Dot density384 points / line
printing speed90 mm / s
Interface TypeRS232 / TTL
Paper roll diameter≦ 40mm
Paper thickness0.06-0.08mm
Paper rollWidth: 57.5 ± 0.5 mm
Character sizeANK character, Font A: 12 × 24 dots, Font B: 9 × 17 dots
Barcode Hard fontGB2312 font
Barcode typeUPC-A / UPC-E / JAN13 (EAN13) / JAN8 (EAN8) / CODE39 / ITF / CODABAR / CODE93 / CODE128
Input buffer32k bytes
NV Flash64k bytes
Printer input voltageDC 5V / 2A
Cash drawer controlDC 5V / 1A
weight0.183 kg
dimension109 × 94 × 66mm (depth × width × height)
working environmentTemperature: 0 ~ 45 °C, Humidity: 10 ~ 80%
Storage environmentTemperature: -10 ~ 60 °C, humidity: 10 ~ 90%
Print head life50 km

Testbild aus dem Drucker

Aperture Value: 3,07 Brightness Value: 0,14 Colour Space: sRGB Components Configuration: 1, 2, 3, 0 Date Time Digitised: 16.12.2020 at 19:21:04 Date Time Original: 16.12.2020 at 19:21:04 Exif Version: 2.2 Exposure Mode: Auto exposure Exposure Program: Aperture priority Exposure Time: 1/10 Flash: No Flash FlashPix Version: 1.0 FNumber: 2,898 Focal Length: 3,598 ISO Speed Ratings: 400 Max Aperture Value: 3,07 Metering Mode: CentreWeightedAverage Pixel X Dimension: 512 Pixel Y Dimension: 384 Shutter Speed Value: 1/10 White Balance: Auto white balance

Status LEDs

Alle Leds sollen gleich viel Strom bekommen:

Vorwiderstand Rechnung:

LEDSpannungVorwiderstandStrom
Rot (Power) (2,1V)5V330 R9mA
Rot (Busy) (2,1V)5V330 R9mA
Grün (Ready) (2,1V)5V330 R9mA

Software

Shell Script in Autostart:

#!/bin/bash

SHUTTER=5
EFFECT=7
GREEN=13
RED=21

# Initialize GPIO states
gpio -g mode $SHUTTER up
gpio -g mode $EFFECT up
gpio -g mode $GREEN out
gpio -g mode $RED out

# Print welcome message on startup
stty -F /dev/ttyS0 9600
echo "Hi. Ready 4 Pics!" > /dev/ttyS0
echo " " > /dev/ttyS0
echo " " > /dev/ttyS0
gpio -g write $RED 0
gpio -g write $GREEN 0

# While Loop forever
while :
do
	# Check for shutter button
	if [ $(gpio -g read $SHUTTER) -eq 0 ]; then
	 	starttime=$(date +%s)
	 	# read how long shutter button was pressed
		while [ $(gpio -g read $SHUTTER) -eq 0 ]; do
			time=$(($(date +%s)-starttime))
			if [ $time -ge 3 ]; 
			then
				gpio -g write $RED 1
				gpio -g write $GREEN 1
			fi
		done
		
		# check how long button was pressed. mode select
		if [ $time -ge 3 ]; 
		then
			# longer than 3s
			# diagnostics
			HOST=$(hostname)
			IP=$(hostname -I | cut -d" " -f1)
			echo "$USER @ $HOST" > /dev/ttyS0
			echo "$IP" > /dev/ttyS0
			echo "$(df -h --output=size --output=avail --output=used --output=pcent /)" > /dev/ttyS0
			echo "$(du -h /home/pi/Pictures/)" > /dev/ttyS0
			echo "Pictures saved: $(ls /home/pi/Pictures/ | wc -l)" > /dev/ttyS0
			echo "Last: $(ls /home/pi/Pictures/ | tail -n 1)" > /dev/ttyS0
			echo " " > /dev/ttyS0
			echo " " > /dev/ttyS0
			gpio -g write $RED 0
			gpio -g write $GREEN 0
		else
			# shorter than 3s
			# picture mode
			gpio -g write $GREEN 1
			NAME=$(date '+%d.%m.%Y %H:%M:%S');
			FILE="/home/pi/Pictures/$NAME.jpg"
			if [ $(gpio -g read $EFFECT) -eq 1 ]; 
			then
				FX="none"
			else
				FX="sketch"
			fi
			# taking picture
			raspistill -n -br 60 -co 80 -sh 100 -ifx $FX -t 200 -w 512 -h 384 -o "$FILE"
			echo "saved $FILE"
			gpio -g write $GREEN 0
			# printing
			gpio -g write $RED 1
			if [ $FX == "none" ]
			then
				echo "$NAME" > /dev/ttyS0
			else
				echo "$NAME $FX" > /dev/ttyS0
			fi
      lp -o fit-to-page "$FILE"
      #sleep 10
      gpio -g write $RED 0
    fi
	fi
done

Random Stuff

  • Auflösung VNC ändern: sudo nano /boot/config.txt und Framebuffer Kommentar entfernen
  • Autostart hinzufügen oder entfernen: sudo nano /etc/rc.local
  • Autostart killen:
pi@PiInstant:~ $ ps aux | grep camera
root       362  4.8  0.3   1924  1156 ?        S    19:35   0:45 sh /home/pi/zj-58/extras/camera.sh
pi       13221  0.0  0.5   7332  2176 pts/0    S+   19:50   0:00 grep --color=auto camera
pi       16859 17.5  9.8  85192 37112 ?        Sl   19:40   1:48 geany /home/pi/zj-58/extras/camera.sh
pi@PiInstant:~ $ sudo kill -TERM 362
pi@PiInstant:~ $ ps aux | grep camera
pi       16559  0.0  0.5   7332  2032 pts/0    S+   19:51   0:00 grep --color=auto camera
pi       16859 15.9  9.8  85192 37112 ?        Sl   19:40   1:48 geany /home/pi/zj-58/extras/camera.sh

Linksammlung

Nächste Schritte

PolaPi Zero: https://github.com/pierre-muth/polapi

Ältere Version: https://hackaday.io/project/7176-polapi

Neue Version (Anderer Drucker): https://hackaday.io/project/19731-polapi-zero

Ideen

Switch für Image Effekte: Sketch, Normal, …

Button für Diagnostics: WIFI status, Hostename, PW, USer

Display für Vorschau: 240×320*4D Systems uLCD-32PTU*

oder 4.3Zoll version 480×272 ULCD-43DT