Skip to content

Instantly share code, notes, and snippets.

@e-minguez
Last active September 10, 2018 12:53
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 e-minguez/1872566565d9a3a1650b7053cc1508fa to your computer and use it in GitHub Desktop.
Save e-minguez/1872566565d9a3a1650b7053cc1508fa to your computer and use it in GitHub Desktop.
pcsensor2mqtt
#!/bin/bash
MQTT_HOST=${MQTT_HOST:-localhost}
MQTT_ID=${MQTT_ID:-n54l}
MQTT_TOPIC=${MQTT_TOPIC:-n54l/input/temp}
MQTT_OPTIONS=${MQTT_OPTIONS:-"-V mqttv311"}
# Raw message to MQTT
# https://github.com/shakemid/pcsensor-temper
TEMP=$(/home/edu/bin/pcsensor -c | awk '{ print $4 }')
/usr/bin/mosquitto_pub -h ${MQTT_HOST} -i ${MQTT_ID} -t ${MQTT_TOPIC} ${MQTT_OPTIONS} -m "${TEMP}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment