Raspberry Pi – Software – Mosquitto MQTT Broker
Mosquitto MQTT Broker
MQTT (Message Queue Telemetry Transport) is een lichtgewicht machine-naar-machine berichtenprotocol voor gebruik bovenop het TCP/IP protocol. Het is ontwikkeld om eenvoudige communicatie tussen “Internet of Things”-apparaten mogelijk te maken. Het wordt bijvoorbeeld gebruikt voor geo-tracking van wagenparken, home automation, sensornetwerken en het op grote schaal verzamelen van data door bijvoorbeeld nutsbedrijven.
Mosquitto is een populaire MQTT server (‘broker’) gesteund door een actieve community en is eenvoudig te installeren en configureren.
Mosqitto installeren
1) Installeer de mosquitto pgp sleutel:
wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
1 2 3 4 5 6 7 8 9 10 |
--2017-11-18 10:54:52-- http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key Resolving repo.mosquitto.org (repo.mosquitto.org)... 85.119.83.194, 2001:ba8:1f1:f271::2 Connecting to repo.mosquitto.org (repo.mosquitto.org)|85.119.83.194|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 3137 (3.1K) [application/octet-stream] Saving to: ‘mosquitto-repo.gpg.key’ mosquitto-repo.gpg.key 100%[============================================================================>] 3.06K --.-KB/s in 0s 2017-11-18 10:54:52 (60.2 MB/s) - ‘mosquitto-repo.gpg.key’ saved [3137/3137] |
2) Voeg de pgp sleutel to aan apt-key en verwijder deze ernaa:
sudo apt-key add mosquitto-repo.gpg.key && rm mosquitto-repo.gpg.key
3) Installeer / Download de listing
Stretch
LET OP: WERKT NOG NIET Gebruik JESSIE:
sudo wget http://repo.mosquitto.org/debian/mosquitto-stretch.list -O /etc/apt/sources.list.d/mosquitto-stretch.list
1 2 3 4 5 6 7 8 9 10 |
--2017-11-18 11:14:36-- http://repo.mosquitto.org/debian/mosquitto-stretch.list Resolving repo.mosquitto.org (repo.mosquitto.org)... 85.119.83.194, 2001:ba8:1f1:f271::2 Connecting to repo.mosquitto.org (repo.mosquitto.org)|85.119.83.194|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 50 [application/octet-stream] Saving to: ‘/etc/apt/sources.list.d/mosquitto-stretch.list’ /etc/apt/sources.list.d/mosquitto-stret 100%[============================================================================>] 50 --.-KB/s in 0s 2017-11-18 11:14:36 (2.22 MB/s) - ‘/etc/apt/sources.list.d/mosquitto-stretch.list’ saved [50/50] |
Jessie:
sudo wget http://repo.mosquitto.org/debian/mosquitto-jessie.list -O /etc/apt/sources.list.d/mosquitto-jessie.list
1 2 3 4 5 6 7 8 9 10 |
--2017-11-18 11:13:17-- http://repo.mosquitto.org/debian/mosquitto-jessie.list Resolving repo.mosquitto.org (repo.mosquitto.org)... 85.119.83.194, 2001:ba8:1f1:f271::2 Connecting to repo.mosquitto.org (repo.mosquitto.org)|85.119.83.194|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 49 [application/octet-stream] Saving to: ‘/etc/apt/sources.list.d/mosquitto-jessie.list’ /etc/apt/sources.list.d/mosquitto-jessi 100%[============================================================================>] 49 --.-KB/s in 0s 2017-11-18 11:13:17 (2.17 MB/s) - ‘/etc/apt/sources.list.d/mosquitto-jessie.list’ saved [49/49] |
Wheezy:
sudo wget http://repo.mosquitto.org/debian/mosquitto-wheezy.list -O /etc/apt/sources.list.d/mosquitto-wheezy.list
1 2 3 4 5 6 7 8 9 10 |
--2017-11-18 11:13:17-- http://repo.mosquitto.org/debian/mosquitto-jessie.list Resolving repo.mosquitto.org (repo.mosquitto.org)... 85.119.83.194, 2001:ba8:1f1:f271::2 Connecting to repo.mosquitto.org (repo.mosquitto.org)|85.119.83.194|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 49 [application/octet-stream] Saving to: ‘/etc/apt/sources.list.d/mosquitto-jessie.list’ /etc/apt/sources.list.d/mosquitto-jessi 100%[============================================================================>] 49 --.-KB/s in 0s 2017-11-18 11:13:17 (2.17 MB/s) - ‘/etc/apt/sources.list.d/mosquitto-jessie.list’ saved [49/49] |
Wheezy:
4) Update en upgrade apt-get repository listing
sudo apt-get update
Ps. krijg je een foutmelding / timeout van ppa.launchpad.net verwijder dan de java listing:
sudo rm /etc/apt/sources.list.d/webupd8team-java.list
5) Installeer Mosquitto
sudo apt-get install -y mosquitto mosquitto-clients
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libc-ares2 libev4 libmosquitto1 libwebsockets8 Suggested packages: apparmor The following NEW packages will be installed: libc-ares2 libev4 libmosquitto1 libwebsockets8 mosquitto mosquitto-clients 0 upgraded, 6 newly installed, 0 to remove and 1 not upgraded. Need to get 412 kB of archives. After this operation, 886 kB of additional disk space will be used. Get:1 http://mirror.nl.leaseweb.net/raspbian/raspbian stretch/main armhf libev4 armhf 1:4.22-1 [34.0 kB] Get:2 http://mirror.nl.leaseweb.net/raspbian/raspbian stretch/main armhf libc-ares2 armhf 1.12.0-1+deb9u1 [76.0 kB] Get:3 http://mirror.nl.leaseweb.net/raspbian/raspbian stretch/main armhf libmosquitto1 armhf 1.4.10-3 [46.2 kB] Get:4 http://mirror.nl.leaseweb.net/raspbian/raspbian stretch/main armhf libwebsockets8 armhf 2.0.3-2 [85.1 kB] Get:5 http://mirror.nl.leaseweb.net/raspbian/raspbian stretch/main armhf mosquitto armhf 1.4.10-3 [119 kB] Get:6 http://mirror.nl.leaseweb.net/raspbian/raspbian stretch/main armhf mosquitto-clients armhf 1.4.10-3 [51.2 kB] Fetched 412 kB in 2s (147 kB/s) Selecting previously unselected package libev4. (Reading database ... 123648 files and directories currently installed.) Preparing to unpack .../0-libev4_1%3a4.22-1_armhf.deb ... Unpacking libev4 (1:4.22-1) ... Selecting previously unselected package libc-ares2:armhf. Preparing to unpack .../1-libc-ares2_1.12.0-1+deb9u1_armhf.deb ... Unpacking libc-ares2:armhf (1.12.0-1+deb9u1) ... Selecting previously unselected package libmosquitto1:armhf. Preparing to unpack .../2-libmosquitto1_1.4.10-3_armhf.deb ... Unpacking libmosquitto1:armhf (1.4.10-3) ... Selecting previously unselected package libwebsockets8:armhf. Preparing to unpack .../3-libwebsockets8_2.0.3-2_armhf.deb ... Unpacking libwebsockets8:armhf (2.0.3-2) ... Selecting previously unselected package mosquitto. Preparing to unpack .../4-mosquitto_1.4.10-3_armhf.deb ... Unpacking mosquitto (1.4.10-3) ... Selecting previously unselected package mosquitto-clients. Preparing to unpack .../5-mosquitto-clients_1.4.10-3_armhf.deb ... Unpacking mosquitto-clients (1.4.10-3) ... Setting up libev4 (1:4.22-1) ... Setting up libwebsockets8:armhf (2.0.3-2) ... Processing triggers for libc-bin (2.24-11+deb9u1) ... Setting up mosquitto (1.4.10-3) ... Processing triggers for systemd (232-25+deb9u1) ... Processing triggers for man-db (2.7.6.1-2) ... Setting up libc-ares2:armhf (1.12.0-1+deb9u1) ... Setting up libmosquitto1:armhf (1.4.10-3) ... Setting up mosquitto-clients (1.4.10-3) ... Processing triggers for libc-bin (2.24-11+deb9u1) ... |
Ps. krijg je deze foutmelding?:
1 2 3 4 5 6 7 8 9 10 11 |
Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: mosquitto : Depends: libssl1.0.0 (>= 1.0.1) but it is not installable Depends: libwebsockets3 (>= 1.2) but it is not installable mosquitto-clients : Depends: libmosquitto1 (= 1.4.12-0mosquitto1) but it is not going to be installed E: Unable to correct problems, you have held broken packages. |
Dan een andere listing pakken (Jessie?) en oude verwijderen.
Mosqitto testen
Mosqitto is te testen doormiddel van 2 terminals (op hetzelfde systeem):
In terminal #1: mosquitto_sub -d -t hello/world
Dan in terminal #2: mosquitto_pub -d -t hello/world -m "Hello from terminal window 2!"
Het resultaat:
Bronnen:
instructables.com #1
instructables.com #2
Download Mosquitto @ mosquitto.org
[#/software/mosquitto” ]