-
1Parts and Materials
The following parts and materials are required (as detailed in the Components section)
- Raspberry Pi Zero W with Raspbian Jessie Lite installed (this version is important if you want to make the file system read-only; see the optional last step)
- 3D prints of the files in the "3D Files" directory
- Soldering equipment
- A thermal printer and required paper (DP-58C)
- DC power supply (12V 5A) with a corresponding plug for the barrel jack
- Wire
- Some stripboard
- Electronic components as shown in the PrinterPi BOM.csv and pin headers and sockets (1-pin width)
- M2.5x12 and M2x6 machine screws
- A sacrificial pencil for the roll holder
-
2Software Setup
You will need access to the Raspberry Pi (through either SSH or console) to install the software.
After booting up the Raspberry Pi, we need to setup the WiFi; open the WiFi configuration file:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
And then add the following to the bottom:
network={ ssid="YOUR_SSID_HERE" psk="YOUR_PSK_HERE" }
Next, get the IP address of the Raspberry Pi (and write it down; we will be using the IP address later to communicate with the extension):
sudo ifconfig
After this, run
raspi-config
to setup some further settings as shown in the table belowOption Description Change User Password Change to something more secure as the Raspberry Pi will be available the network Hostname Name your Pi so that it can be addressed without an IP address Interfacing Options -> SSH Enable (for maintenance) Interfacing Options -> Serial Disable console, enable serial Boot Options -> Desktop/CLI -> Console Autologin Enable this so that the script will run automatically To compile the code, we need to install Java on the Raspberry Pi. Run the following commands to do this:
Now, you can either use the precompiled code from the Releases page. (You may need to install the Java Runtime Environment with
sudo apt-get install default-jre
), or compile the code yourself using the method below:sudo apt-get update sudo apt-get install openjdk-8-jdk -y
Finally, download a copy of the code in the "PrinterPiServer" directory in this repository and place the files in the home directory of the Raspberry Pi.
You will need to compile the code before it can run; this can be done with the following command:
javac *.java
(continue here if using precompiled code) Additionally, we need to make the power button management script executable with the following command:
sudo chmod +x power_button.sh
To make the Raspberry Pi run the code automatically on boot, add a couple of lines of code to the .bashrc file, which runs when the user logs in (done automatically on boot up with the console autologin selection in raspi-config). Open up the file with:
sudo nano ~/.bashrc
And add the following lines to the end:
/bin/bash /home/pi/power_button.sh& stty -F /dev/serial0 115200 java -cp /home/pi Main&
Finally, we need a logo for the receipt to print. Generate this from any size and color picture with the Python code in the Logo directory with the following steps:
- Take a copy of your logo and place it into the Logo directory (rename it to Logo_in.png)
- Next, open and run the Python program "Image Processing.py"
- This will create a binary file, Logo.bin. You need to copy this file and place it into the directory with the other code on the Raspberry Pi for it to run
If you do not have a logo, just create an empty file called Logo.bin on the Raspberry Pi in the same folder as the PrinterPiServer code.
Optional additional steps
- Use HOSTNAME.local instead of an IP address, where HOSTNAME is the hostname set with raspi-config. This should work automatically on Macs and Linux/Unix computers. For Windows machines, you will need to install Bonjour. To implement this system, change the value in IP_ADDRESS.txt to HOSTNAME.local.
- Convert Raspberry Pi to read-only to remove the need for power button and risk of SD card corruption such as at https://medium.com/@andreas.schallwig/how-to-make-your-raspberry-pi-file-system-read-only-raspbian-stretch-80c0f7be7353
-
3Wiring
First, solder together the circuit board as shown below (reference the pictures with the Wiring diagram file (Note: you will need to cut some of the traces, so please look carefully.)
Next, solder up the power jack and thermal printer cables (power and data; these will need to be spliced) to the wires from the circuit board. The LED and power button also need to be soldered, but in this case to pin headers instead of directly to the circuit board.
Finally, connect all corresponding cables and sockets and check that the Raspberry Pi boots and runs successfully.
-
4Assembly
Now that the circuit is complete, assemble the printer as shown below.
Raspberry Pi and Circuit
First, install the Raspberry Pi. Using the M2x6 screws, mount the Raspberry Pi with the GPIO header to the right and ports and connectors to the left. Next, insert the circuit board on top of the Raspberry Pi's GPIO header. You can use tape and/or a mirror to help line up the pins. Now install the power button and LED; the former needs to have the nut screwed on from the back, whereas the latter is just a press fit.
Thermal Printer
Before the printer will fit, you will need to remove one screw from each side of the printer as highlighted in the picture below. Then just slot the printer in at an angle. Add the M2.5 screws and the printer is installed.
Paper Roll
To keep the paper roll easily accessible, use a pencil as a roll holder. First, you will have to cut it down to the correct length, and (maybe) trim the ends to fit. This is easily done with a craft knife.
Final Steps
Place a roll of paper on the pencil and feed it into the printer. Note: you may need to install some tape to prevent paper from curling up in the gap between the printer's output and the lid. Finally slide on the lid, and it should click into place (if not, sand and trim until it fits).
-
5Client Setup - Chrome Extension
To install the Chrome Extension, navigate to chrome://extensions and check the box in the upper right corner reading "Developer mode." After this, click the "Load unpacked" button, and select the folder containing the extension. Finally, after the extension appears, you can uncheck the "Developer mode" box. Instead, this application is pending review in the Chrome Store, and may become available.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.