Recently I started a new hobby; 3D printing. This is my first blog post about this subject and I intend to create many more. To control my 3d printer, I use a Raspberry Pi 4 with a HyperPixel 4.0 Touch screen and the Raspberry Pi Camera module v2. On the Raspberry Pi, I am using an OctoPi image (Currently v0.18.0 32-bit) with OctoPrint installed. I will also install OctoDash to show some magic on the screen.
Page Contents
Bill of Materials (BOM)
Product | SKU / EAN | NL Link |
---|---|---|
Raspberry Pi 4 Model B v1.2 – 4GB | 0765756931182 | Kiwi Electronics |
Raspberry Pi 4 USB-C Power Supply – Black – EU | 0644824914886 | Kiwi Electronics |
Transcend 32GB microSD Premium 400x Class 10 UHS-I + Adapter – 60MB/s | TS32GUSDU1 | Kiwi Electronics |
HyperPixel 4.0 – Hi-Res Touch Display for Raspberry Pi | PIM-369 | Kiwi Electronics |
Raspberry Pi Camera Board V2 – 8MP | 5060214370240 | Kiwi Electronics |
Flex cable for Raspberry Pi Camera Board – 100cm | KW-2286 | Kiwi Electronics |
Heat Sink Kit for Raspberry Pi | KW-1598 | Kiwi Electronics |
Micro-HDMI to HDMI Cable – 1m – White (Optional) | 4250236819921 | Kiwi Electronics |
Tp-Link HS100 Kasa (Optional) | 6935364081362 | Amazon.nl |
Warning: If you are using a Display with your Raspberry Pi, always make sure that you have a powerful adapter. I would like to suggest the original Raspberry Pi Adapter. This adapter has 3A of power. A phone charger does not have enough power!
3D Printed case
I am currently using the Hyperpixel 4.0 touch and Raspberry Pi 4B case on Thingiverse that I am remixing to have a slot for the Ribbon Cable and an adjustable mount. If you want to use that case, the description on Thingiverse explains how you should print it. I would like suggest to printing it in PETG due to the temperature of the Pi.
The remixed model is now available on Printables / Thingiverse
Required hardware/software
Hardware
Aside from the BOM above, you’ll need some hardware that you probably already have, however, I am adding them here in case you don’t have them.
To flash your SD card for your Raspberry Pi, you’ll need a computer or laptop with a (Micro)SD card slot. The SD card that I bought has an adapter for Micro SD to SD. Depending on your machine, you might need such an adapter to insert the card into your PC.
While not required, an HDMI monitor or TV and USB keyboard are handy during setup. The Raspberry Pi 4b has two Micro-HDMI ports, these ports are quite new and most people will probably not have a cable or an adapter that fits those ports. A 1m cable is added optionally in the BOM above.
Software
To unzip the archive, the default Windows “Extract All” is sufficient, however, I like to use 7-zip (Chocolatey users: “choco install 7zip.install”).
You’ll need to have a tool that can write the OctoPi image to your SD card. I like to use Win32DiskImager to write the image (Chocolatey users: “choco install win32diskimager.install”). During this tutorial, I am going to use that tool. Other tools that you could use are Rufus or balenaEtcher.
One other tool that you need is a good text editor, I like to use Notepad++ (Chocolatey users: “choco install notepadplusplus.install”) or VSCode (Chocolatey users: “choco install vscode”) Please do not use Notepad, Word, Wordpad or any rich text editors. Your editor needs to be able to handle files with Linux line endings.
To connect to your Raspberry Pi, once connected to your network, you’ll need an SSH tool. I like to use PuTTY (Chocolatey users: “choco install putty.install”), it’s a tool that has been around for quite a while. If you like to use another tool, feel free to do so.
Setting up OctoPi
Currently, OctoPi only comes in a 32-bit version. There is a nightly build with 64-bit available but I’ll be using the 32-bit version for now. In theory, OctoPi runs on all Raspberry Pi devices, however, an Raspberry Pi Zero or Zero W is not recommended due to performance reasons. The HyperPixel 4.0 display only works with a Pi 2, 3, or 4. Therefore a Pi 2, 3, or 4 is required.
Download OctoPi
To get started, you should download the latest OctoPi image. Head over to the download page on the OctoPrint website and download their latest release, at the time of writing this is version 0.18.0 32-bit. This file will be 700MB – 800MB in size. Once downloaded, extract the file with 7zip or the Windows extract. Inside the extracted folder you’ll find an .img file. This file is a couple of GBs in size.
Insert your SD card into your computer, a window might pop up showing the contents of your SD card.
Warning: Make sure there isn’t anything on that SD card that you want to save, after this section all data on that card will be gone!
Flashing SD Card
Start Win32 Disk Imager. You will probably get a pop-up that this tool wants to make changes to your device, you’ll need to accept it. Once started, click on the folder icon on the right side of the “Image File” section in the tool and browse to the .img file of OctoPi. If you have done everything correctly, the program should look like this:
The Image filename and the device shown on the right might be different on your machine. Make sure the Device matches the drive letter of the SD card that you inserted. Once all the settings are entered correctly, press Write. A pop-up message should appear asking if you want to overwrite the image. If you are sure you want to use that device, click Yes. Win32 Disk Imager should now start flashing your SD card with the OctoPi image.
Depending on the speed of your SD card, this can take up to a couple of minutes. During the flashing of the SD card, an Explorer window might pop up asking you if you want to format a drive. Do NOT format this drive, this is the Linux partition where OctoPi is installed. If you have formatted this drive, you should flash your SD card again.
When Win32 Disk Imager finishes with a “Write Successful” message, you can click on OK and Exit after that.
Configure WiFi (Optional)
Note: If you intent to connect your Raspberry Pi to your network using an Ethernet cable, you could skip this step. You can connect that cable now.
Just to be sure Windows has detected all changes on your SD card, eject your SD card and put it back in. In some rare cases, files do not show up right after flashing your SD card. This can happen with any tool that you use. Windows may ask you to format a drive again, do NOT do so!
Depending on your Windows configuration, an Explorer window should pop up. In that folder are a couple of TXT files. One of them is “octopi-wpa-supplicant.txt” Open this file in Notepad++ or VSCode.
I am assuming your WiFi network is configured with WPA or WPA2. If you are not sure, check your router configuration.
Inside that file, you’ll find a section that starts with “##WPA/WPA2 secured”. Remove the hashtag (#) before the 4 lines underneath that line and edit the SSID (WiFi network name) and PSK (WiFi network password). Both the SSID and PSK should stay surrounded with double quotes (“)
Almost at the bottom, a line with “country=GB” is shown. Change the letters of the country to match your two country letters. In my case, this would be “NL” Check this list if you are not sure what letters to use.
Once completed, save the file and close the editor.
Connecting the hardware
Warning: Like all hardware, an Raspberry Pi is sensitive to Static electricity. Make sure that you handle the boards correctly by only touching their edges.
Eject the SD card from your computer, if you have not already done so, and slide it into your Raspberry Pi. The connector of your SD card should face the bottom side of the Raspberry Pi.
If you have bought the heat sink kit, apply them now on the chips. Depending on the kit, there might be different heat sinks in there.
Raspberry Pi Camera
The Camera module comes with a short ribbon cable by default. Depending on how you want to set up your camera, this may or may not be enough length. There are different lengths available, I have used a 100cm one.
If you have bought a separate ribbon cable, you should remove the one that came with the Camera device. Lay your Camera module down with the camera facing your desk. Make sure you put the lens on something soft like the bag it came in.
To remove the cable, carefully pull the two black corners on the connector away from the Camera board. It only goes out 3mm or so and remove the ribbon cable by pulling it out. You shouldn’t have to apply any force to remove the cable. Attach one end of the longer ribbon cable to the camera and push the corners back. Make sure the metal connectors of the cable are in the same orientation as you pulled them out before.
On your Raspberry Pi board between the Audio and HDMI ports, there is a similar connector for the Camera. Carefully pull the left and right side of that port and slide the other end of the ribbon cable in there. The metal connectors should face the same side as your SD card is located.
HyperPixel 4.0
Inside the HyperPixel box, there are 4 standoffs, 4 screws, a 40-pin header, and the display.
Place the display on a flat surface, do not remove the protective cover yet. Screw in the standoffs and connect the 40-pin header. Do not apply any excessive force to the display as it might crack. Turn over your Pi, align the 40-pin header on the Pi with the header on the display, and gently push your Pi down. If you do not intend to use the case, use the 4 screws to attach your Pi to your display. Otherwise, follow the documentation of the case.
Configuring your Raspberry Pi
Once all hardware steps are completed, we are ready to power up our Pi. Connect your powerful adapter to your Pi and the socket. The HyperPixel Display will not display any output. This is because we need to install the drivers for the HyperPixel. (Optional) To be able to see any of the outputs, connect the Pi with an HDMI screen.
Most times, you can connect to your OctoPrint instance by using the “octopi.local” hostname. If this is not the case, you can find its IP address in your DHCP server. This is most likely the router in your home. For information on how to access your router and DHCP leases, please have a look at the documentation of your router.3
Tip: Search in the documentation of your router how to give your Pi a static lease, if possible. That way you are sure that your Pi gets the same IP address every time it starts and you can always find it in your network
Connect to the OctoPrint instance on http://octopi.local your newly created Pi and complete the Setup Wizard. I would like to advise you to set up Access Control, Enable the Connectivity Check, Enable Plugin Blacklist Processing, and set up your printer profile.
The instance that comes with the OctoPi image is probably outdated, while still connected to OctoPrint in your browser, open settings () and go to “Update Software”. Click on the “Check for update now” button and “Update all” after that. OctoPrint shows a screen that it’s updating and after it’s finished it automatically restarts the OctoPrint instance. Once OctoPrint is started, press “Refresh Now” to reload the screen.
Connecting to your Pi using SSH
SSH is enabled by default on your OctoPi. To connect to your Pi over SSH, you’ll need an SSH client, like PuTTY. In the Host Name field enter “pi@octopi.local” or change “octopi.local” to the IP of your Pi. This will connect to your Raspberry Pi with the username pi:
Click on Open. An SSH connection to your Pi will be made. If this is the first time you connect to this machine, a PuTTY Security Alert will appear. Click on Yes to continue.
The SSH connection now asks for a password. By default the password for your Pi is “raspberry” without quotes.
Warning: You should always change the password for the pi user. Use the command “passwd” to change your password. Store this password in a safe place, you cannot recover from a lost password.
Updating your Pi
I think it is always a good idea to update your Pi before making any changes. To update your Pi, run the commands below. The first command will ask for your password. This is the password for the Pi user that you just changed, right? Depending on your internet speed, the age of the image, and the speed of your SD card, this might take some time.
sudo apt update sudo apt upgrade -y sudo reboot
HyperPixel 4.0 driver installation
The installation of the HyperPixel 4.0 driver is quite simple. It’s well documented on their GitHub page. In this configuration, please follow these steps. In your PuTTY window, paste, by right-clicking in the window, the following command:
sudo apt install arandr i2c-tools xinput
curl -sSL https://get.pimoroni.com/hyperpixel4 | bash
The first command will ask for your password, enter it. After you have entered the second command, you will be asked to continue, type “y” and press enter. The installation wizard now asks what combo of HyperPixel and Raspberry Pi you have. In my case, this is a Pi 4, and a Rectangular screen. As there are some known issues, I picked option 2 and pressed enter. It asks you to verify again. If it’s correct, type “y” and press enter. Enter your password for the user Pi
After some checks and installation of software, the Pi asks you to reboot. Type “y” again and press enter. Your SSH session will be disconnected, don’t close the window just now, you’ll need it later. You’ll see text scrolling on your screen during reboot if you have done everything correctly. The screen is probably not in the correct orientation, but that’s what we are going to fix next.
HyperPixel 4.0 orientation
Right-click on the title bar of the Putty window and click “Restart Session”. PuTTY will ask for your password again. Type your (changed) password and press enter.
First, we need to set some parameters for the touch screen. Enter the command below:
DISPLAY=":0.0" sudo hyperpixel4-rotate right
In case you have your HDMI connectors at the bottom of your screen, change right to left in the command above. Your screen will rotate, but this is not saved for reboot. We are going to fix that next.
We need to edit the startup configuration of your Pi. I like to use “vi” for that, but it might be a bit hard for people who are just starting with Linux. Therefore I will explain this using the “nano” tool. Execute the command below to open up the configuration file:
sudo nano /boot/config.txt
This command will ask you for your password, type in your password to continue. With the page down button or arrow keys on your keyboard scroll down to the line that starts with “[pi4]”. Add a pound sign (#) before the line that starts with “dtoverlay=vc4-fkms-v3d” Right-blow that line, and add an extra line “display_lcd_rotate=1”. Use 1 when your power and HDMI ports are on top. Change it to 3 when they are at the bottom.
Press “CTRL + O” to save your file. Do not change the filename, press enter to confirm. Press “CTRL + X” to exit nano. type “sudo reboot” to reboot your Pi. Your SSH session will be disconnected again, don’t close the window, you’ll need it later to install OctoDash. The orientation should now be correct. If the orientation is upside-down, change the “display_lcd_rotate” line. When using your Pi horizontally this value should either be 1 or 3.
Automatic login
By default, a Pi starts with a login prompt. In our case, we would like to show OctoDash on the screen and we need to change the default settings for login. Reconnect your SSH session, just like you did before, and execute the command below.
sudo raspi-config
Type your password to continue. A menu should appear. Select option “1. System Options” and press enter. Next, we will select the option “S5. Boot / Auto Login” and press enter. The last option we should select is “B2 Console Autologin” and press enter. Press “Tab” 2 times to go to “<Finish>” and press enter. Press “Enter” again to reboot your Pi.
Installing OctoDash
The next thing that we are going to install is OctoDash. Reconnect your SSH session, just like you did before. To install OctoDash, run the command below.
bash <(wget -qO- https://github.com/UnchartedBull/OctoDash/raw/main/scripts/install.sh)
The command will ask you for your password. Type in your password to continue. It takes a while and it seems to not be doing anything, it just takes a bit of time before output will be shown. This will happen a couple of times during the installation. The script will install a lot of packages to enable a graphic interface on your Pi, depending on the speed of your internet and your SD card, this might take some time.
After the installation of the packages, the installer asks the plugins that you want to install. Depending on the configuration of your printer and the plugins that you would like to use, select the line with your arrow keys and press the “spacebar” to select them. In this example, I have enabled them all. Press “Enter” to confirm. The installer now asks you if you want to start OctoDash during boot. I selected yes and pressed “Enter” Same for the automatic update script and reboot.
Configuring OctoDash
After your Pi is rebooted, you will be greeted by OctoDash. It takes a few seconds to start and you will be taken to a wizard to configure OctoDash.
Make sure you have your OctoPrint window open in your browser. You should be seeing the normal screen. You’ll need this window in a second to approve a connection between OctoDash and OctoPrint.
With your Touch Screen, tap on “next >”. The wizard asks you which OctoPrint instance you want to use. Tap on the OctoPrint instance on the screen. OctoDash wants to connect to OctoPrint, tap on “send request”.
In your OctoPrint instance, click on Allow. The wizard will now continue. By default the printer name is set to Default, you can change this with a USB keyboard or later by editing a file on the Pi (see below), tapping on “next >”. Enter the values that match your printer extruder. Currently, there isn’t a list of known printers. These values can be changed in a later state, tap on “next >” to continue.
Depending on the Plugins you picked during installation, enable or disable the plugins to match the installation. You can disable or enable them later again, tap on “next >” to continue. The wizard now stores your values in the settings file. Tap on “done” to complete the wizard.
If your printer isn’t attached to your screen, OctoDash will go into a sleep mode. OctoDash only works when your printer is connected to your Pi.
OctoDash printer name
If you want to change the name of your printer that is shown in the bottom left of your screen, enter the command below:
nano ~/.config/octodash/config.json
Change the text “Default” in the line ‘”name”: “Default”,’ to match your printer name. Press “CTRL + O” to save your file. Do not change the filename, press enter to confirm. Press “CTRL + X” to exit nano. For the changes to take effect, type “sudo reboot” to reboot your Pi.
Hi, thank you for your tutorial. I followed this one and many others but I still can’t use Octodash on my Raspberry 🙁
I keep getting an error after ratpoison starts .
xinit: connection to X server lost
Don’t know what to do anymore :/
Hi Manuel,
Based on the error, it seems that there is something wrong with your x session. X is responsible for your graphical output.
Did you follow the steps here? https://github.com/UnchartedBull/OctoDash/wiki/Troubleshooting#cannot-open-display-xinit-failing-
Maurice
Thank you for the answer..I tried everything from the wiki..still no luck.. 🙁
This is what I get:
https://imgur.com/0xnaAYa
If you have any ideas..
Ma I think I found the problem reading some Issues on Github..
I’m using and old Raspberry 1 B+..and it’s not supported..getting a 3 B+ tomorrow to try!
If possible, I would go with the Pi4 (2 or 4GB), it’s way faster and fully supported.
Thanks so much for this!! I worked perfectly with one little issue. The screen displays correctly with the usb ports on the right, but the touch areas are upside down. For example, when finishing install… I would press the lower left corner for ‘Next’ and lower right corner for ‘Back’…. what did I miss??
Thanks again – Bob Saunders
Hey Nevermind! I found the answer here: https://youtu.be/OJ59hXSyBoI
Thanks for this! DId you post your remix of the Rpi case yet?
Hi @Jammerwoch,
No I have not. I haven’t finished it yet
Thank you! Best instructions on this topic that I have found.
Hi Maurice
For weeks now, I have been searching for help high and low. Finally I found your walk-through on installing Octoprint on RPi4 with Hyperpixel4 touchscreen.
A really nice guide that I have followed from a to z…but it still doesn´t work
A clean image from RPi Imager (Octopi OS) Check!
Installed the Hyperpixel4 drivers Check!
Rotated the screen Check!
Installed the Octodash Check!
Rotated the touch —–NOT!
The Screen is rotated 90 degree right but touch is still off.
I would expect to have the forward touch in the upper right corner and the back touch in the upper left corner. I do have the forward in the upper right but the back is now in the lower right corner.
I have tinkered with all possible inverted and swap commands but now I am ready to give up…
If you could share light over the error, I would be your forever fan
The Config.txt sections and
the 40-libinput.conf sections looks like this:
——————————————————————————-
[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
#dtoverlay=vc4-fkms-v3d
display_lcd_rotate=1
max_framebuffers=2
[all]
#dtoverlay=vc4-fkms-v3d
# enable raspicam
start_x=1
gpu_mem=128
dtoverlay=hyperpixel4-common
dtoverlay=hyperpixel4-0x14
dtoverlay=hyperpixel4-0x5d
dtoverlay=hyperpixel4,touchscreen-inverted-x,touchscreen-inverted-y
enable_dpi_lcd=1
dpi_group=2
dpi_mode=87
dpi_output_format=0x7f216
dpi_timings=480 0 10 16 59 800 0 15 113 15 0 0 0 60 0 32000000 6
——————————————————————————————-
Section “InputClass”
Identifier “libinput pointer catchall”
MatchIsPointer “on”
MatchDevicePath “/dev/input/event*”
Driver “libinput”
EndSection
Section “InputClass”
Identifier “libinput keyboard catchall”
MatchIsKeyboard “on”
MatchDevicePath “/dev/input/event*”
Driver “libinput”
EndSection
Section “InputClass”
Identifier “libinput touchpad catchall”
MatchIsTouchpad “on”
MatchDevicePath “/dev/input/event*”
Driver “libinput”
EndSection
Section “InputClass”
Identifier “libinput touchscreen catchall”
MatchIsTouchscreen “on”
MatchDevicePath “/dev/input/event*”
Driver “libinput”
Option “TransformationMatrix” “0 -1 1 1 0 0 0 0 1”
EndSection
Hi Ronnie, it should work with the steps described in this section: https://kevenaar.name/octopi-with-octodash-on-rpi-4-with-hyperpixel-4-0/#HyperPixel_40_orientation
Hi Maurice
After yet another shot with your guide, I regret to inform you that he problem persists. I am able to manipulate the touch overlay, but no matter what I try I can not find the correct orientation.
Are there anything in the config.txt that looks suspicious to you?
Hi Ronnie,
Based on the documentation of Pimoroni you should be able to rotate them to the correct orientation like this: https://github.com/pimoroni/hyperpixel4#rotation-on-pi-4
On my Pi, I don’t have the line “dtoverlay=hyperpixel4,touchscreen-inverted-x,touchscreen-inverted-y” in the config.txt. You could try to comment it out and reboot to test if that works.
Greetings again
I totally agree, bit unfortunately no. Probably someting to do with the headless distro of Octopi. With the Raspberry Pi Desktop OS, everything works as a charm, inkluding the touch overlay.
I could use this OS branch, but unfortunately I can not install Octoprint manually on this. Kind of catched in a loop here.😢
Hi Ronnie,
I have my HDMI connectors on top and the rotate tool should add something like this:
$ cat /etc/udev/rules.d/98-hyperpixel4-calibration.rules
ATTRS{name}=="Goodix Capacitive TouchScreen", ENV{LIBINPUT_CALIBRATION_MATRIX}="0 1 0 -1 0 1"
Please look at that file if it’s there and set to someting like this
Soo.. following your advice, I outcommented the suggested lines in config.txt and in 40-libinput.conf and added the line in 98-hyperpixel4-calibration.rules.
This did nothing of use, and when re-commanding DISPLAY=:0.0 hyperpixel-rotate right, the following error occurs:
[REMOVED EXPIRING IMAGE]
Hi Ronnie,
I have seen this before with someone. They had an issue with the touch screen. They could fix that by reseating the small ribbon cable on the back of the HyperPixel display. But to be sure, please reseat both. Before removing your screen, make sure your Pi is shut down and powered off!
Give my guide a go.
It’s now an official part of the OctoDash Wiki.
I have also been solving the wrong rotation of the touch part for several days now. The ‘DISPLAY = “: 0,0” sudo hyperpixel4-otočit doprava’ command looks promising, but I don’t know how to list it. It is not possible via a remote console and OctoDash starts automatically on the RPi.
Hi Michal,
It seems that you have translated the page and the commands that are used for rotating the screen. Please do not translate the commands / page when following a guide.
Hope that helps!
I know about the translation, I want to enter it in the original, of course. But I have nowhere to write it. It is not possible via the remote console and OctoDash starts automatically on the RPi.
Hi Michal,
you should be able to use a tool like PuTTY (Windows) to connect to your Pi using SSH. You should be able to enter it there. I have created a page for a different project with some additional information on how to use SSH: https://farmpi.kevenaar.name/guides/ssh.html
Have a look at connecting to your Pi using a tool appropriate for your computer.
I use Putty, but this command cannot be used remotely.
Yes, you can. That’s why there is a
DISPLAY=":0.0"
in front. When using the full commandDISPLAY=":0.0" sudo hyperpixel4-rotate right
in one line, you set the display to be used to be the attached HyperPixel display, assuming you do not have any other attached displays. If you do, disconnect them before using the commandI already understand. But the command doesn’t work in my case. I think I’m using the desktop version. The error listed is:
This rotate utility only works with the Raspberry Pi OS desktop version.
Rotating display
Traceback (most recent call last):
File “”, line 3, in
ImportError: No module named screenlayout
Failed to set display orientation. Make sure you’re running Raspberry Pi OS desktop on a Pi 4.
Thank you for your patience.
Could you try doing this after you have installed octodash? That should install all the stuff required for the Desktop. Hope that helps!
Hi, I was wondering if you had the remix for the case available yet?
Thanks
Hi Mark,
No I haven’t published it, but I am working on a file
can you send a photos how it looks like? where is the camera cable output?
Hi,
I am going to publish it soon.
It has been published: https://www.thingiverse.com/thing:4940698
Just a heads up… To comment on what issues people are having with this method, there were two issues I ran into and solved.
1. I did not comment out dtoverlay=vc4-fkms-v3d
2. I followed the instructions on Persisting Rotation and created a /usr/share/X11/xorg.conf.d/88-hyperpixel4.conf file.
https://github.com/pimoroni/hyperpixel4#persisting-rotation
Thank you so much for a straight forward and detail blog that works.
better than most YouTube videos I’ve seen and much easier to follow so thank you.
Thank you for your kind words!
I know many many people have been experiencing issue with getting the HyperPixel to work.
The ‘support’ from Pimoroni is non-existent.
With a lot of frustrated hours spent trying to resolve getting mine working, I came up with a formula that works.
It is now part of the OctoDash Wiki.