The following example shows how to connect GUI-O application with Raspberry Pi in MQTT (IoT) mode. Secure connection using SSL/TLS is supported.
Raspberry Pi uses its own Linux-based operating system (Raspberry Pi OS), which significantly simplifies some tasks and enables using high-level (interpreted) programming languages such as Python.
This example uses Raspberry Pi 2 board, but any other Raspberry Pi board that has internet capabilities (Wired or Wireless) can be used.
MicroSD card (using an adapter or card reader for connection with PC)
Download Raspberry Pi Imager based on your operating system (Ubuntu, Windows or macOS)
Open Raspberry Pi Imager (see image below)
Select "Choose OS" and select Raspberry Pi OS (32-bit), which is the recommended option
Select "Choose storage" and select your microSD card
Press the settings button (lower-right corner)
Enable "Set username and password" and set both then press "Save"
Finally, select "Write" and wait for the operation to complete
Insert the microSD card into Raspberry Pi
Connect Raspberry Pi to external monitor (TV or PC) via HDMI output port
Connect USB keyboard and USB mouse to Raspberry Pi
Power on the Raspberry Pi and wait for the initial setup to complete (Raspberry Pi might reboot)
The following example shows basic interaction between GUI-O application and Raspberry Pi in MQTT (IoT) communication mode. Secure connection using SSL/TLS is enabled by default.
Connect the components as shown in the schematic below.
Open GUI-O application and select "Add" from the top-right corner of the home screen
Select "IoT (Create device)" and add a new device (specifying arbitrary name and optional user name)
After adding a device, note the In and Out tokens which are required in Step 4 (tokens can be shared via email by pressing the "Share" icon)
IMPORTANT: Your Raspberry Pi should be connected to the internet
Open the terminal on your Raspberry Pi and install Eclipse Paho MQTT Python client library by entering the following command:
$ pip install paho-mqtt
IMPORTANT: Your Raspberry Pi should be connected to the internet
Download the RPiMqtt.zip package to your PC and extract the archive
Open the RPiMqtt.py script and set the In and Out tokens generated in Step 2
Secure connection can be disabled by setting the useTls variable to False (at the beginning of the script)
Copy the modified RPiMqtt.py script and the ca.crt certificate (if useTls is enabled) to your Raspberry Pi (e.g., using a USB flash drive)
Open the terminal on your Raspberry Pi, navigate to script location and run the script by entering the following command:
$ python ./RPiMqtt.py
Open GUI-O application and select "Connect" from the top-left corner of the home screen
Tap on the device created in Step 2
Wait for successful connection and try the example
The RPiMqtt.py script can be terminated by pressing "Ctrl + C" keys
Raspberry Pi OS supports connecting via Serial port, SSH or VNC (this can be configured under "Preferences -> Raspberry Pi Configuration")
VNC is perfect for controlling your Raspberry Pi without requiring the use of external monitor, USB keyboard or USB mouse
Connect . Create . Control