Smart Cities - Setting up Raspberry Pi for Mosquitto
Credits
- Joe Gonzales - School Amateur Radio Club Network - VK3RSC
Raspberry Pi OS
- Starting with a fresh install of the Raspberry Pi Debian Bookworm OS with desktop (64 bit).
- Use the Raspberry Pi Imager to install the OS on a 16MB micro SD card.
- Open a terminal window and run the following commands (you can copy and past them into a terminal window)
Install the real Python IDE (not thonny) and the MQTT broker
- Open the Terminal and enter these commands
sudo apt update
sudo apt -y full-upgrade idle3 mosquitto mosquitto-clients
Install Virtual Environment
- These days Python must run in a virtual environment so that each user gets their own Python
- The virtual environment has to be activated before each use
- The linux prompt then changes from:
- <username>@home:~ $ to (env) <username>@home:~ $
- Create a virtual environment for Python called env in your /home/<username> directory.
- Enter the commands in the Terminal.
cd ~
python3 -m venv env
- Activate the virtual environment
cd ~/env
source bin/activate