After installing Mosquitto on Omega2+ in the blog post Using MQTT on Onion Omega2+ the subscription of messages was shown. Here I will send data to the MQTT broker to subscribe and access them from anywhere in the world.
For data generation I use the script wunderweather.phy again. The script mqtt.sh reads the requested data (temperature & humidity) and publishes these to my MQTT broker. Look for the files at Github.
mqtt.sh:
#!/bin/sh #MQTT BROKER="m20.cloudmqtt.com" BRUSER="rawyjpid" BRPASSW="ah52k3gjd8JS" BRPORT=12394 TEMPTOP="OMEGA2/WU/temperature" HUMITOP="OMEGA2/WU/humidity" echo "Send data to MQTT Broker" DATE="$(date +"%d-%m-%Y")" read TEMP < /home/TEMP echo "Temperature = $TEMP *C" read HUMI < /home/HUMI echo "Rel. Humidity = $HUMI %" mosquitto_pub -h $BROKER -u $BRUSER -P $BRPASSW -p $BRPORT -t $TEMPTOP -m $TEMP mosquitto_pub -h $BROKER -u $BRUSER -P $BRPASSW -p $BRPORT -t $HUMITOP -m $HUMI
The screenshot of my MQTT client MyMQTT shows messages from two publishers. WU labels the data received from Weather Underground requestet here and ASH2200 is a sensor placed outside of my house. The difference between the measured values is due to different measuring locations.