Introduction: Octoprint Setup on Raspberry Pi + Some Relays and Plugins

About: Sometimes i english very well, sometimes ne.

Hi kids, today we are going to setup Octoprint on Raspberry Pi for your 3D printer. Sometimes i english very well, sometimes no, so please bear with me. Up here you can see my enclosure, its inner wiring and mainly how it should not look like. I'm an electrician and i am ashamed of it. But its hidden, like my shame. Jokes aside, what do we need? Here's a list and furhter some explanation on why these components.

I wont go into much detail on AC wiring, you can google how to. Just unplug it from mains, if you are messing with it. This instructable is to show people the way, not to hold their hand and explain everything.

.

Supplies

  • Raspberry Pi (further refered only as RPi) - preferably RPi4 4GB version, but it works on RPi3 too (but slower); both model B
  • MicroSD card - at least 16GB, preferably Sandisk V30
  • power supply for our RPi - 5V 3A USB-C for RPi4, microUSB for RPi3
  • RPi compatible USB webcam - some USB webcams shutdown or loose connection (dont ask me why), i bought XYGStudy 5MP USB Camera Module
  • Relay module - so we can switch stuff on and off
  • some wires
  • maybe some buttons and capacitors - if you like pushing buttons, like i do; capacitors are not needed, but i like to debounce my buttons
  • download and install Raspberry Pi imager
  • download Octoprint image (latest stable, 0.18.0 at the time i write this)

Step 1: Why This, Why That?

Why did i choose RPi4b 4GB? Its 4 core 64bit ARM with base clock of 1,5GHz. It can be overclocked to 2.1GHz with some cooling, because it gets hot realy fast if oveclocked. The small heatsink and fan can keep it under 40°C under load. RPi3b can be used. It too is a 4-core 64-bit, but the base clock is only 1.2GHz, it can be overclocked, but only something over RPi4 base clock. Both have WiFi and bluetooth, ethernet (RPi3 - 100Mb/s, RPi4 - 1Gb/s). Both have the same GPIO pinout. 4 USB ports, RPi4 has two upgraded to USB3.1. Also RPi3 only has 1GB of RAM, RPi4 can have 2/4/8GB, the choise is yours.

Thats why i chose RPi4, its more powerfull. When rendering your last print timelapse, it takes much less time, so you can start next print sooner.

I have tested Octoprint on RPi Zero 2 W and it works, you have to dissable incompatibility warnings, but it just works like on RPi3. If you choose this model beware: W stands for wi-fi, its important because its so small, it has no LAN. AND choose the second model (RPi Zero 2 W), because its 4 core, first model wont do. AND it has only one microUSB B, the second one is for power supply.

Why a webcam with USB cable and not RPi cam on ribbon cable? Ribbon cable is short. Thats all. You cant hang the whole RPi and cam anywhere you want. I'm working on an arm that will be mounted to Y axis cover and the cam will be looking under my nozzle as it prints to detect if im not making pasta (Spagetti Detective plugin). And webcam on cable is significantly lighter than RPi + cam.

Relays - Sold in 1/2/4/6/8 relay module variants. I use 8 and 4 relay 5V modules, because thats what i had at the time i build the enclosure. 5V variant of something like this

SD Card - faster = better, because RPi uses the card as a hard drive. I use Sandisk 32GB class 10 V30, because they are fast and work. Some cards dont work with RPi, but newer models are less picky than the old ones (oh my, the strugle with my firts RPi model B...).

Step 2: Installation

Open Raspberry Pi Imager and follow the attached pictures. Its step by step, just follow and you will be fine.

Step 3: WiFi Setup Before First Boot

You can setup WiFi before you plug the card into RPi or from Octoprint menu, but in this case you need to plug it in your network first and access it thru LAN.

YOU CAN SKIPP THIS STEP IF YOU PLUG IT INTO LAN.

We are going to setup WiFi before first boot now. This it how:

    1. open Notepad (do NOT use WordPad)
    2. write this into it (instead X comes your country, ssid and password, see pics as reference on how it should look):


      country=XX # Your 2-digit country code
      ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
      network={
      ssid="XXXX" #your SSID (wifi name)
      psk="XXXX" #your wifi password
      key_mgmt=WPA-PSK
      }

    3. save file as: wpa_supplicant.conf
    4. (unplug and) plug your sd card back to your pc
    5. Two windows and a dialogue will pop out, close the dialogue and the blank window. The other window is full of files (see pics), this is where we put our wpa_supplicant.conf file.

    Unplug the card and plug it into RPi. The file will be read and saved into wifi config on first boot, so now power up the RPi to make it happen. It will take some time to boot up.

    Step 4: Finding Our Rpi in the Waves

    If everything worked as expected, RPi should be connected to your wifi. Now we need to find it. Usualy you just have to open your browser and write octopi.local as an address and press enter. But sometime its does nothing. Like the times when you don't have mDNS support or two Octopis with the same name (yes i know...). Then we have to find its address. Use your preffered way. I just opened my MicroTik router console and took a look into the DHCP tables.

    Step 5: Initial Octoprint Setup

    One image is worth thousand words, so i made lots of them.

    Step 6: Welcome to Octoprint

    Now we have Octoprint up and running. Hopefully. If not, repeat and ask.

    Plug in webcam and printer USB cable. Reboot for webcam will be needed. Don't worry, it's all there.Follow the pictures.

    Step 7: How Do I Print?

    Printer switched on and connected? Good. now i quick guide to printing with octoprint. Upload your gcode file, its drag and drop. under the file press load and print.

    Step 8: Plugins

    Octoprint has a lot of fans and programers that contribute to it with their plugins. And here we are back to sharing data. Please share the logs with them, so they can learn from their failures of their work.

    Let's install one or two. Like ecnlosure plugin. Press that little wrench on top, settings open. Install ecnlosure plugin (more later). If you have sensor, then install Bed Visualiser plugin. It's all in the pictures again.

    .

    Step 9: Setting Up Eclosure Plugin

    Every plugin is fairly documented, its all there, just read it. so there is not much to say. Install Enclosure plugin, reboot. I just added arrows for importance, and because i like the color. But before ve start to connect wires, we power RPi off and unplug RPi from PSU.

    PLEASE BE CAREFULL AROUND ELECTRICITY.

    Relay wiring:

    RPi pin (see pinout pic.) = relay pin (i use 4 relay module for example)

    • 5V (pin 2 or 4) = VCC
    • GND (6, 9, 14...)= GND
    • green pins, choose yours

    Remember that pin number is different from GPIO number. Pin number 12 is GPIO17, 13 is GPIO27, etc.


    RPi pins are 3.3V tollerant, so watch out. Everything above that will burn that pin or the whole RPi. Input button have to be connected from pin to ground. Connect the small capacitor in paralel to button (between input pin and ground) for input signal debouncing. Input wired like this has pins signal pulled to ground (0V) on press. Thats why it has to be set as "input pullup, to tell the RPi that it shoud be at 3.3V when not pressed. See schematic.

    I chose pins 11 (GPIO17), 13 (GPIO27) and 15 (GPIO22) as input (buttons). And pins 29(GPIO5), 31(GPIO6), 33(GPIO13) and 35(GPIO19) as output (relay).

    GPIO number are those you put into enclosure settings.

    My relays controll lights, filtration and printers PSU. What will yours do is up to you.

    Step 10: And Deeper the Rabbit Hole Goes...

    Here's some more pictures, to wound this up. I wont go over more plugins because i could go on and on. Instead i mentioned their names and how to install plugins generally. Go read some more wikis for settings info and how-tos...

    Step 11: See That Was Not That Hard

    Job well done. Go and play with it, you can always start from the beginning if somethig's going wrong. But don't forget to back-up your prints (yes, it's built in).

    I'm not here that often, so it might take a while before you get your answer, but don't be afraid to ask or comment.

    Happy printing.

    And about the webcam, just plug it in and go to timalapse/webcam settings... Maybe reboot will be needed to load camera.