Sunday, March 26, 2017

3D Printing - OctoPi Setup with 7in PiTFT Touchscreen LCD

OctoPrint is a great companion for any 3D printer.  I used it with my Monoprice Mini, and now with the Original Prusa i3 MK2. The web based interface works great, but I wanted a way to monitor the prints both when I am away from the house, and a way to just check on the status on the print in passing. I will show both the physical assembly process and how I set up all the settings within the Pi and OctoPrint to work for me.  Also working on a video walkthrough that I will post at the end of this post when completed. 

I had seen a few examples on of the OctoPrint interface running on a 3.5in TFT display.  I already had one of those screens, so I gave it a try.  


























I got it working, but found the touch display too small to really be of much use, so decided to jump to a larger version.  Went with the official Raspberry Pi 7in TFT display.  Here is an Amazon link


There are plenty of enclosures available for this screen that also allow you to mount the Pi on the back, but I found some 3D printed plans that looked a bit nicer, and the fact that I could make my own with customized colors was a plus!  Here is the link to the one I made, and some pictures of the assembly process. 








Now that everything is put together, here is the step by step guide that I made to get everything up and running. I pieced this together from various sets "how-to" documentation, as they all seemed to not have all the info I needed, or missing some step that was causing the setup to not work for me. 


OctoPi Setup with 7in PiTFT Touchscreen LCD

Part 1: Install & Setup OctoPi
  • Download Image and burn to MicroSD Card using Win32 Disk Imager or Etcher
  • Once image is burnt to card access the following files in the boot directory to modify configuration of the OctoPi
    • octopi-network.txt
      • Remove the "#" from the follwoing 3 lines, and add your network info
      • ## WPA/WPA2 secured
        iface wlan0-octopi inet manual
            wpa-ssid "put SSID here"
            wpa-psk "put password here
    • octopi.txt
      • Modify these settings for your specific webcam. These settings for for the Logitech C615
      • Remove the "#" from the following line and change settings to match your camera
      • camera_usb_options="-r 1280x720 -f 25"
    • config.txt
      • An update has been pushed to Raspbian to flip the screen ( rotate it by 180 degrees ) for a better desktop viewing angle. This makes it upside-down in our stand and the official Pi stand, so you'll need to change a setting to flip it back. To do this, open /boot/config.txt in your favourite editor and add the line:
      • lcd_rotate=2
      • This will rotate both the LCD and the touch coordinates back to the right rotation for our display stand
  • Assemble the Raspberry Pi
    • Insert MicroSD card into Pi, Connect TFT Display, Keyboard, and HDMI Display, then boot up device
    • Once device boots up and launches the Console, enter default user credentials
      • Username: pi
      • Password: raspberry
    • obtain IP address
      • ifconfig

  • Enter the IP address found with ifconfig into your web browser to launch the OctoPrint web Interface
  • Complete Setup Wizard on Web Interface and establish log-in credentials
    • Username: XXXXXXXXX
    • Password: XXXXXXXXX
  • Import CURA slicing profile if desired, for the Prusa i3 MK2 I am using, head here:
  • Install Plugins
    • Settings > Plugin Manager
      • Automatic Shutdown
      • STL Viewer
      • TouchUI
  • Add the Prusa i3 as the Default printer with the following parameters 


    • Settings > Serial Connection
      • Serial Port > Auto (
      • Baudrate > 115200
    • Save Settings
  • Verify WebCam feed is working
    • Go to "Control" tab to verify you see the streaming image from your webcam
    • Go to Settings > Webcam & Timelapse > Stream URL
      • Use the "Test" button to verify everything is working properly
      • Also test the "Snapshot URL" 
      • Save Settings
  • Update the instance of OctoPi if update is available
    • Reboot the system once update is complete


Part 2: Configure PiTFT Touchscreen LCD
  • You may need to provide yourself root access first
    • sudo passwd
    • change root password to something you will remember
    • To gain SuperUser access
    • su
  • From the Command line, update the database of available software
    • sudo apt-get update
      sudo apt-get upgrade
  • Once update is complete, shutdown system
    • sudo shutdown -h now
    • Power on sytem and verify the the Touchscreen is working and the display is the correct orientation
  • If desired, access the Raspberry Pi Configuration screen and change the default password to something more secure
    • sudo raspi-config

Part 3: Setup: Boot to Browser (for OctoPi or Jessie Light)
  • **NOTE** This section will be easier to complete if you access your PI via SSH using Putty
  • From the piTFT screen, enter in user credentials and elevate to SU if needed
    • sudo apt-get update
      sudo apt-get install --no-install-recommends xinit xinput xserver-xorg xserver-xorg-video-fbdev x11-xserver-utils matchbox unclutter chromium-browser
      sudo nano /usr/share/X11/xorg.conf.d/99-fbdev.conf
  • Enter this information into the file if using an offical Pi Touchscreen
    • Section "Device"
       Identifier "touchscreen"
       Driver "fbdev"
       Option "fbdev" "/dev/fb0"
      EndSection
    • If using an HDMI display, chang to "fb1"
  • Save and exit (CTR-O, Enter, and CTR-X)
  • Allow X11 to run as anybody
    • sudo sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config
      git clone https://github.com/BillyBlaze/OctoPrint-TouchUI-autostart.git ~/TouchUI-autostart/
  • Copy Service File and Register
    • sudo cp ~/TouchUI-autostart/touchui.init /etc/init.d/touchui
      sudo chmod +x /etc/init.d/touchui
      sudo cp ~/TouchUI-autostart/touchui.default /etc/default/touchui
      sudo update-rc.d touchui defaults
  • Test Kernel
    • chromium-browser
  • If browser doesn't launch we need to upgrade the Kernel and the Chromium Install
    • Only Do this if Launching Browser didn't work
    • Update Chromium
      • sudo apt-get update
        wget -qO - http://bintray.com/user/downloadSubjectPublicKey?username=bintray | sudo apt-key add -
        echo "deb http://dl.bintray.com/kusti8/chromium-rpi jessie main" | sudo tee -a /etc/apt/sources.list
        sudo apt-get update

        sudo apt-get install chromium-browser
    • Update Kernel
      • sudo apt-get upgrade
        sudo apt-get install rpi-update
        sudo rpi-update
        sudo reboot
  • You may have to run the steps before updating Chromium and Kernel again for TouchUI to AutoBoot
  • System should now  boot automatically to the TouchUI web interface of OctoPrint


Part 4: Setup Remote Print Access
  • Reserve (These steps are for my ASUS Router, but should be similar for most brands)
    • From Router UI go to LAN > DHCP Server
      • Reserve the desired Local IP address for the Raspberry Pi
        • 192.168.1.123
    • Head to WAN > Virtual Server / Port Forwarding
      • Enable port forwarding for both OctoPrint and SSH
        • Octoprint Port: 80
        • SSH Port: 22
        • Both will use the OctoPi's IP Address


  • No-IP
    • Set up your Dynamic DDNS
      • ZaneXXXXXXXX.ddns.net
      • 97.117.XXX.XXX
    • Open the Console or SSH and type the following
      • mkdir /home/pi/noip
        cd /home/pi/noip
    • AfterAfter creating the folders for the DUC it is time to download the software.
    • Within the Terminal window type the following. After each entry you will press “Enter”.
      • wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz
        tar vzxf noip-duc-linux.tar.gz
    • Next navigate to the directory you created to locate the downloaded files.
      • cd noip-2.1.9-1
    • Now install the program
      • sudo make
        sudo make install
    • After typing “sudo make install” you will be prompted to login with your No-IP account username and password.
      • UserName
      • Password
    • After logging into the DUC answer the questions to proceed. When asked how often you want the update to happen you must choose 5 or more. The interval is listed in minutes, if you choose 5 the update interval will be 5 minutes. If you choose 30 the interval will be 30 minutes.
      • sudo /usr/local/bin/noip2
    • To confirm that the service is working properly you can run the following command.
      • sudo noip2 -S
        • Must be a Capital "S"


    • To ensure that it will run on Start Up
      • sudo noip2 -S
      • Add the following below the "fi" line and above "exit 0"
        • /usr/local/bin/noip2

      • Save and exit the file
      • Now check to see if the process is already running or not
        • sudo /usr/local/bin/noip2 -S
      • Upon reboot, it should run the service
  • Setup /  Upkeep
    • Make sure passwords on all devices and routers are secure
    • If you don't want to update the NoIP every month, pay $25 for an annual setup



Here is a video I put together showing the TouchUI in action along with a companion app for Android called "Printoid" that has a nicer UI, but still works off of OctoPrint. 


5 comments:

  1. Do you have the link to the enclosure you have used?

    ReplyDelete
  2. Well done, sir. I have used Octoprint for over a year and love it. Wished this blog entry was around when I was learning to set up. I had to do it the hard way. Great tutorial.

    ReplyDelete
  3. Thanks for this tutorial, thanks to you, I managed to install my 7 inches screen.
    Nice work and good work.

    ReplyDelete