티스토리 뷰

반응형

이번에 하이퍼큐브 에볼루션을 제작하면서 그 동안 3D 프린터를 사용하면서 불편했던 점 중에 하나가

원격으로 확인할 수 있는 방법이 없다는 것이다. PC에 Repetier를 설치하여 사용하더라도 일일이 원격포트를

열어주고 접속해서 확인해야하기 때문에 보안상의 이유로 다소 불안한 부분이 있었으며, 무엇보다 PC가 하루종일

켜있어야 한다는 점이다. 안그래도 전기세 때문에 좀 걱정이었는데 구글에 검색해보니 라즈베리파이에 설치하는

octoprint라는 툴이 있었다. 웹으로 접속하여 프린터가 작동되는 모습을 볼 수도 있고 프린터를 직접 연결하여

제어도 할 수 있었다. 혹시 모르는 상황에 대비하여 원격으로 전기를 차단할 수도 있다는 것이다.


설치하는동안 굉장히 많은 삽질을 했었다. 단순히 Octoprint만 사용한다면 Octoprint 이미지를 다운받아서

사용하길 권장....

https://octoprint.org -> 여기서 이미지 다운로드


1. Raspbian 설치

NOOBS로 설치해도 되고 Raspbian이미지를 받아서 직접 설치해도 된다.

나는 맥을 사용하기 때문에 Apple Pi Baker라는 앱으로 설치했다.


2. octoprint 설치

octoprint는 venv기반으로 설치를 진행하는것같다.

octoprint는 root계정이 아니라 pi로 하는것을 권장한다.


pi@raspberrypi : ~ $ cd ~

pi@raspberrypi : ~ $ sudo apt-get update

pi@raspberrypi : ~ $ sudo apt-get install python-pip python-dev python-setuptools python-virtualenv git libyaml-dev build-essential


설치하겠냐고 물어보면 y를 입력한다.


pi@raspberrypi : ~ $ mkdir OctoPrint && cd OctoPrint

pi@raspberrypi : ~/OctoPrint$ virtualenv venv

pi@raspberrypi : ~/OctoPrint$ source venv/bin/activate

pi@raspberrypi : ~/OctoPrint$ pip install pip --upgrade

pi@raspberrypi : ~/OctoPrint$ pip install https://get.octoprint.org/latest


위 순서까지 진행하면 octoprint가 자동으로 설치된다.

설치가 마무리되면 아래 명령어를 입력한다.


pi@raspberrypi : ~ $ sudo usermod -a -G tty pi

pi@raspberrypi : ~ $ sudo usermod -a -G dialout pi


여기까지 마무리하면 설치가 완료된 것이다.

이제 테스트를 해보장


pi@raspberrypi : ~ $ ~/OctoPrint/venv/bin/octoprint serve


위 명령어를 입력하면 무언가 주르르르르ㅡㄱ 뜨다가 마지막에

* Running on http://0.0.0.0:5000/

위 메세지가 뜬다. 위 메세지가 뜨면 정상적으로 실행이 완료된 것이다.

여기까지 완료하면 octoprint 설치는 정상적으로 완료된 것이다. 이제 해줘야 할 작업은

부팅 시 자동실행 되도록 하는 방법이다. 멍청하게 .bashrc나 /etc/rc.local에다가 작업하지 말자


pi@raspberrypi : ~ $ wget https://github.com/foosel/OctoPrint/raw/master/scripts/octoprint.init && sudo mv octoprint.init /etc/init.d/octoprint pi@raspberrypi : ~ $ wget https://github.com/foosel/OctoPrint/raw/master/scripts/octoprint.default && sudo mv octoprint.default /etc/default/octoprint pi@raspberrypi : ~ $ sudo chmod +x /etc/init.d/octoprint


위 작업까지 완료하면 자동실행 스크립트까지 완료된 것이다.

이제 마지막으로 파일 하나만 수정하면 된다.

pi@raspberrypi : ~ $ sudo vi /etc/default/octoprint

위 파일을 열면

# Configuration for /etc/init.d/octoprint


# The init.d script will only run if this variable non-empty.

OCTOPRINT_USER=pi

# base directory to use

#BASEDIR=/home/pi/.octoprint


# configuration file to use

#CONFIGFILE=/home/pi/.octoprint/config.yaml


# On what port to run daemon, default is 5000

PORT=5000


# Path to the OctoPrint executable, you need to set this to match your installation!

#DAEMON=/home/pi/OctoPrint/venv/bin/octoprint


# What arguments to pass to octoprint, usually no need to touch this

DAEMON_ARGS="--port=$PORT"


# Umask of files octoprint generates, Change this to 000 if running octoprint as its own, separate user

UMASK=022


# Process priority, 0 here will result in a priority 20 process.

# -2 ensures Octoprint has a slight priority over user processes.

NICELEVEL=-2


# Should we run at startup?

START=yes

위와 같이 되어있을 것이다. 아무데나 한줄 띄고

DAEMON=/home/pi/OctoPrint/venv/bin/octoprint를 적어준 다음 저장하고 나오면 된다.


이제 정상적으로 실행되는지 확인해보자.


pi@raspberrypi : ~ $ sudo reboot

pi@raspberrypi : ~ $ ps-ef | grep octo


위와 같이 입력하면 

pi         392     1  4 07:59 ?        00:00:50 /home/pi/OctoPrint/venv/bin/python2 /home/pi/OctoPrint/venv/bin/octoprint serve --port=5000

octoprint가 실행되는 것을 알 수 있다.

ifconfig를 입력해서 ip주소를 확인한 다음 웹브라우저에

ip주소:5000

위와 같이 입력하면 octoprint 웹을 확인할 수 있다.

다음 포스팅에선 octoprint 초기설정에 대해 알아보장...


빠잉!

반응형
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함