Installare Mosquitto: broker MQTT per domotica

게시일 20/04/2026 IoT
The Firmware Factory
광고
The Firmware Factory — 임베디드 기기를 위한 맞춤형 펌웨어 개발
자세히 보기

Installazione

sudo apt install mosquitto mosquitto-clients
sudo systemctl enable --now mosquitto

Creare un utente

sudo mosquitto_passwd -c /etc/mosquitto/passwd utente_mqtt

Inserisci la password quando richiesta.

Configurazione

Crea /etc/mosquitto/conf.d/default.conf:

listener 1883
allow_anonymous false
password_file /etc/mosquitto/passwd

Riavvia: sudo systemctl restart mosquitto.

Test

mosquitto_sub -h localhost -u utente_mqtt -P password -t test/#

In un'altra shell: mosquitto_pub -h localhost -u utente_mqtt -P password -t test/ciao -m "Hello"