Skip to content

Instantly share code, notes, and snippets.

@YongHuax
Last active February 10, 2018 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YongHuax/7bcc1ac94f668ace6e6dac6c3dc44575 to your computer and use it in GitHub Desktop.
Save YongHuax/7bcc1ac94f668ace6e6dac6c3dc44575 to your computer and use it in GitHub Desktop.
Shell script for testing mqtt with data sent from ESP32 LoRa to LG01-P
#!/bin/sh
#The following code demonstrates a sending mqtt messages with data variables
# publish to topic yhtest with message data from LoRa
#$1 refers to the first data sent from the arduino MCU to the Linux module in the LG01-P ( data sent from ESP32 LoRa )
DATA=$1
HOST=broker.hivemq.com
PORT=1883
MSG=yhtest
mosquitto_pub -h broker.hivemq.com -p 1883 -t yhtest -m $1
# to check aforementioned code using mosquitto cli , copy the following line of code
#mosquitto_sub -h broker.hivemq.com -p 1883 -t yhtest
# the following code shows portion of the code subsitied with shell varaibles to make it easier to modify cli command
# publish to topic yhtes1 with message data from ESP32 LoRa to mosquitto broker
#mosquitto_pub -h $HOST -p $PORT -t $MSG -m "$1"
# to check aforementioned code using mosquitto cli , copy the following line of code
#mosquitto_sub -h broker.hivemq.com -p 1883 -t yhtest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment