Communicating with a huge number of clients requires a simple, fast and reliable solution. Message queues seem to solve this problem in a very efficient way. There is a reason why many people treat MQTT as the "language of the Internet-of-Things".


There are no real preparations except these two:

  1. Update your OrangePi Zero
  2. Install PuTTy (or some substitue of it) on your PC

Step by Step

The first step is to install RabbitMQ on your hardware. Therefore you can use the official documentation. If everything is installed you can start the deamon with the following command:
invoke-rc.d rabbitmq-server start

A nice feature of RabbitMQ is it's WebUI. It is accessible under the port 15672. So you just need to call http://your-ip-adress:15672. If you just followed the installation instructions, your browser will tell you that it can not display the webpage. This is related to following circumstance: the plugin is disabled by default. To activate it you just need to type in the following line of code:
rabbitmq-plugins enable rabbitmq_management

So far you should be able to see the WebGUI. The documentation states that we should be able to login with the credentials guest:guest. It did not work for me, so I did some research and used the following lines of code to create my own administrator-account. (Angle brackets symbolize parts which need to be replaced by you.)

  1. Remove the default configured user: rabbitmqctl delete_user guest
  2. Create our own user: rabbitmqctl add_user <username> <password>
  3. Promote the newly created user to an administrator: rabbitmqctl set_user_tags <username> administrator
  4. Check if it worked via the CLI: rabbitmqctl list_users
  5. Check if it worked via the WebGUI.

Now we will need to grant our new user some permissions. RabbitMQ differentiates between "configure", "write" and "read". Because our admin-user (that is us) should be able to do everything, we need to set the following pattern for all three levels: .*
Since we now have our WebGUI we do not want to configure it by hand. To do this we need to navigate along the following path: Admin => Users => <your user>. You should see the fields in the section "permissions" prefilled. So all we need to do is to click on "Set permission".

RabbitMQ's default configuration works with the AMQP-protocol, which is pretty neat. But many device rely on the MQTT-protocol. Luckily there is a plugin for RabbitMQ. The installation of this additional protocol is very simple. You just need to type in the following line:
rabbitmq-plugins enable rabbitmq_mqtt
After the installation has finished you should restart your RabbitMQ with the this command:
sudo /etc/init.d/rabbitmq-server restart
If everything is ok, you should be able to see the new opened port (1883) in your WebGUI. Additionally we should check our logfile if the plugin really has been loaded. You can find the path of your file in the WebGUI. (Mine is: /var/log/rabbitmq/rabbit@orangepizero.log).

Previous Post Next Post