Jump to content

I have a mosquitto MQTT broker up and running, now I have a few questions


G+_Jason Perry
 Share

Recommended Posts

I have a mosquitto MQTT broker up and running, now I have a few questions.

 

Are there any good tutorials on how it works? Not how to use it but something that will help me understand its quirks.

 

The previous question kinda leads into this next one.

 

Is there a way to see a list of topics? Is there a setting to keep a log of the topics?

Link to comment
Share on other sites

David Wiggins, I used the first half of this video to set up my MQTT Server. really it is just a few commands

 

sudo apt-get install mosquitto

sudo apt-get install mosquitto-clients

 

sudo nano /etc/mosquitto/mosquitto.conf

delete

include_dir /etc/mosquitto/conf.d

add

allow_anonymous false

password_file /etc/mosquitto/pwfile

(pwfile or whatever name you prefer)

listener 1883

 

sudo mosquitto_passwd -c /etc/mosquitto/pwfile username

(this will prompt you to make a password)

 

sudo reboot

Link to comment
Share on other sites

David Wiggins oddly enough that lights project is the exact reason I use mqtt. I have a few raspberry pis setup that control ws2812 light strips. I wanted them to work independently, but at the same time automate some actions with my phone. Example is at night I plug my phone in, it sends a message true to the bedtime topic, each pi has a Python script setup to read the topic and preform an action if it's true. In that case it turns off my house lights and sets a 90 second timer on my bedroom lights. I've been working on replacing them with arduino with esp8266, have the code working but got too busy to finish up the whole project.

 

As to the question asked. The command line mosquito_sub tool should allow you to see all topics and messages coming through. But if you haven't set anything up to send a message it probably won't display anything. For me I learned by trial and error, and work experience in SQL using service broker accounts which work somewhat similar.

Link to comment
Share on other sites

Jason Perry I set it up a long time ago so I'm not sure of the exact site I used. It's called paho.mqtt.client.

 

For mine I defined a list of topics for it to listen to in an array. Then have a folder on each pi that are named the same as the topics with True or False (or whatever message is sent) and then some Python logic to call each script upon the message in the queue.

Link to comment
Share on other sites

 Share

×
×
  • Create New...