I’ve been playing with using MQTT to send messages between computers around the house and I’ve now built in the capability of using it in ScratchGPIO for the Raspberry Pi
Setting Up
You have to install MQTT python support before launching ScratchGPIO
Launch a Terminal window and enter
sudo pip install paho-mqtt
Once installed you can close the terminal window and launch ScratchGPIO
Simply create a variable called MQTTBroker and enter the name of the broker you want to use.
e.g set MQTTBroker to test.mosquitto.org
or in my case
set MQTTBroker to win8.local (my own broker running 24/7 on main windows PC)
Then setup one Pi to receive msgs
broadcast MQTTSubscribe topic
and then on the sending Pi
broadcast SendMQTT topic,payload
You should now see a sensor variable on the receiving Pi called topic and its value should be payload
If you simply want to just test getting some external test data into you Pi – I recommend just doing the script on the left and then displaying the current cheerlights sensor value.
Then tweet a colour to @cheerlights
e.g. @cheerlights red
and watch the sensor value update within a minute
Recent Comments