Repository navigation
3.1 Raspberry Pi setup using IOTStack
The benefit of using IOTStack to install ClassicMQTT is that you can include other docker images like InfluxDB and Grafana etc.
-
Flash the Raspberry Pi OS (32-bit) onto SD card using the Raspberry Pi Imager found at www.raspberrypi.org/software.
-
For headless setup, SSH can be enabled by placing a file named ssh onto the boot partition of the SD card (see www.raspberrypi.org/documentation/remote-access/ssh)
-
install sd card into rpi and power it up.
-
Find raspberry pi's IP address on your router and reserve address. (example used in this document is 192.168.0.25, yours will be different)
-
log in using ssh pi@192.168.0.25 (default password is raspberry)
-
run sudo raspi-config
-
select update then **Finish **when done
-
Change the default password using: passwd or use passwordless SSH access by copying your public key to rPi (see www.raspberrypi.org/documentation/remote-access/ssh/). Using powershell on Windows 10, execute: cat ~/.ssh/id_rsa.pub | ssh pi@192.168.0.25 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys'
-
sudo apt update
-
sudo apt full-upgrade (available on new versions of Pi)
-
sudo reboot
-
login again with ssh pi@192.168.0.25
-
Install git: sudo apt install -y git curl
-
cd ~
-
Get IOTStack from github using git: git clone https://github.com/SensorsIot/IOTstack.git IOTstack
-
cd ~/IOTstack
-
Run IOTStack: ./menu.sh
-
IOTStack should install Python, Docker and Docker compose, if it doesn't, select "Native Installs" then select "Install Docker and Docker-Compose".
( Note - There are a few bugs with IOTstack install . The prompted update shown below sort of messed up my pi.Choose no. │ "Docker version is currently 20.10.5+dfsg1 which is less than 18.2.0 consider upgrading or you may experience issues. You will not be prompted again......│" So don't do that prompted update , for some reason it made my router choose a different IP address for the pi - took me awhile to figure out. Maybe they will get it fixed someday and you won't see that message . note by Larry 11/28/2021 )
- Reboot the pi when done.
-
cd ~/IOTstack
-
Copy the compose-override.yml file from ClassicDIY/ClassicMQTT/code/Python to the IOTStack directory on the pi.
-
edit the compose-override.yml file using ** nano compose-override.yml**
-
Change the IP address for CLASSIC= to your classic's IP address along with the name of your classic by updating CLASSIC_NAME=.
-
If you have more than one classic you will need to uncomment the second classic_mqtt block and set your second classic's IP and Name as in the example below.
-
*indentation is important with yaml files, make sure both classic_mqtt and classic_mqtt2 blocks have the same indentation.
-
If you have an external or cloud based MQTT broker, set the MQTT_HOST and PORT to it's IP address or Name along with it's username and password as in the example below.
-
-
run ./menu.sh and select Build Stack
-
Select: Portainer-ce, Eclipse-Mosquito and whatever else you plan on using (InfluxDB, Grafana...) using the space bar
-
Hit Enter when done.
-
Select Docker Commands and then Start stack.
-
You should see the following logs
-
exit menu.sh and run docker ps
-
You should see the following docker containers
( updated screen shot may be needed because of changes )
(IOTStack documentation https://sensorsiot.github.io/IOTstack/Containers/Portainer-ce/)
-
Browse 192.168.0.25:9000
-
Create an admin User & Password
-
Select: Docker (Manage the local Docker environment)
-
Connect
-
Select Containers from the Portainer Dashboard and click the logs Quick Actions Icon
-
If everything works the ClassicMQTT logs should look like the following;
(IOTStack documentation https://sensorsiot.github.io/IOTstack/Containers/Mosquitto/)
-
The above installs the mosquito broker with no user credentials, if you want to add the user defined in the .env file above, execute the following
-
docker exec -it mosquitto sh
-
mosquitto_passwd -c /mosquitto/pwfile/pwfile ClassicPublisher
( info about mosquitto password from Paraphraser 6/25/2021 at 9:26 PM The mosquitto_passwd -c /mosquitto/pwfile/pwfile ClassicPublisher is not "incorrect", as such, but it is slightly misleading. The -c says "create the file". With the new self-healing Mosquitto, you'll get an empty password file by default so the "create" isn't necessary. It actually functions as a "replace". So, the question to ask is, "will you need more than one password?" If the answer is "no, never" then this command is OK but if the answer is "maybe…yes" then you might be better off following https://sensorsiot.github.io/IOTstack/Containers/Mosquitto.html#password-file-managemen)
pw ClassicPub123
re-enter pw ClassicPub123
exit
-
Download and install MQTT.fx
-
Connect to the MQTT broker using the Pi's IP and port 1883
-
Subscribe to ClassicMQTT/#
-
Publish a wake command to the broker
-
You should see the following messages from ClassicMQTT