Once you discover the simplicity and power of the MQTT protocol, you will immediately start to think of all kinds of use cases for your digital picture frame.
I prefer to install the MQTT broker directly on the Raspberry that drives my digital picture frame rather than using a Cloud Service. I found this setup to be much more reliable.
In this article, I will show you how to install Mosquitto, a lightweight MQTT broker available for the Raspberry Pi. It is so undemanding, it even works on a Pi zero!
If you want to know more about MQTT, enter “MQTT” in the search bar of my website and browse through my articles. This will help to get an idea of the many use cases that MQTT offers.
Tested with: Raspberry Pi OS March 2021 version, Raspberry Pi 2, 3, and 4, Pi3D 2.43, PictureFrame 2021.03.20, 1080p and 4K displays.
Before installing a new software package, make sure that your Raspberry Pi is up to date by entering
sudo apt update && sudo apt upgrade -y
Now install Mosquitto
sudo apt install -y mosquitto mosquitto-clients
Using this command, Mosquitto will automatically launch after the installation. It will also automatically start at boot without having to enter any further startup commands.
You can test if the Mosquitto server is running by entering
sudo service mosquitto status
Hit CTRL-C to exit the result window.
Now let’s see how it works. Enter this command to make your Raspberry Pi listen to the “frame_channel”:
mosquitto_sub -h localhost -v -t frame_channel
Now open a second Terminal window connected to your Raspberry Pi and send a message to yourself:
mosquitto_pub -h localhost -t frame_channel -m "Hello Digital Picture Frame"
In your first Terminal window, you should now see “”Hello Digital Picture Frame”. If that is the case, you’re already done!
Mosquitto configuration in Pi3D PictureFrame image viewer
The Pi3D PictureFrame image viewer has a number of MQTT controlled commands to drive everything from stopping or skipping your photo playback or showing certain image information like the date of the location.
In the configuration.yaml file, in the “mqtt” section, look for these lines:
mqtt: use_mqtt: True server: "localhost" port: 1883 login: "" # your mqtt user password: "" # password for mqtt user tls: "" device_id: "picframe"
Make sure you enter “True” in the first line and “localhost” in the second. Unless you have created a user and a password or you are using a secure connection, there is nothing else to change.
For security purposes, you may want to define a user and a password though.
The additional CPU load after a local install of an MQTT broker via Mosquitto locally is negligible. I didn’t even notice an increase of a single percent on my picture frame. So it makes a lot of sense to install your MQTT broker locally on your Raspberry Pi.
MQTT allows you to connect your digital picture frame with other applications and devices in an effortless way, which opens the way for countless hours of geeky stuff around Home Automation.
So give it a try and let my know what you think!
- Voice control your Raspberry Pi digital photo frame with Amazon Echo, MQTT, and Node-RED
- The new way to turn your connected HDMI monitor on and off on a Raspberry Pi
- Show the CPU temperature of your Raspberry Pi digital picture frame in Home Assistant via MQTT
- How to quickly troubleshoot MQTT problems on your Raspberry Pi