• 카테고리

    질문 & 답변
  • 세부 분야

    임베디드 · IoT

  • 해결 여부

    미해결

원격 mqtt broker 연결

20.11.12 21:42 작성 조회수 440

0

제가 mqtt broker를 친구 집에 있는 라즈베리 파이에 설치했어요.

그리고 우리 집에서 아두이노와 컴퓨터로 친구 집에 있는 라즈베리 파이에 putty로 접속해서 mqtt broker를 원격으로 둬서 통신을 하고 싶어요. 그래서 아두이노 프로젝트에서  const char* mqtt_server 이 부분을 putty로 연결한 mqtt broker의 ip  주소를 연결했고

web app을 돌릴 컴퓨터에는 const client = mqtt.connect("mqtt://mqtt broker ip주소"); 로 연결을 했어요. 근데 둘 다 접속을 못 했는데 어떻게 해결을 하면 좋을까요?

답변 2

·

답변을 작성해보세요.

2

- 라즈베리파이에 mqtt 설치 및 TEST -

Step 1: 시스템 업데이트

#sudo apt-get update

#sudo apt-get upgrade

Step 2: 모스키토 설치

#sudo apt-get install mosquitto

#sudo apt-get install mosquitto-clients

Step 3: 콘피그파일 수정

#sudo nano /etc/mosquitto/mosquitto.conf

The File Should Look as follows

# Place your local configuration in /etc/mosquitto/conf.d/

#

# A full description of the configuration file is at

# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

pid_file /var/run/mosquitto.pid

persistence true

persistence_location /var/lib/mosquitto/

log_dest topic

log_type error

log_type warning

log_type notice

log_type information

connection_messages true

log_timestamp true

include_dir /etc/mosquitto/conf.d

Step 4: 서버동작 시작

#sudo /etc/init.d/mosquitto start

Step 5: 두개의 터미널로 통신 테스트

Terminal 1: Type the following:

#mosquitto_sub -d -t hello/world

Terminal 2: Type the Following:

mosquitto_pub -d -t hello/world -m "Hello from Terminal window 2!"

위처럼 테스트를 해보고 아두이노에서 mosquitto 서버 부분에 라즈베리파이 ip주소를 적어주시면
통신이 됩니다. 특히 Step 3: 콘피그파일 수정을 해주시기 바랍니다.

0

정홍준님의 프로필

정홍준

질문자

2020.11.14

감사합니다 도움이 많이 됬습니다!