### TinkerForge Brick MQTT Proxy

TINKERFORGE BRICK MQTT PROXY
Reference TinkerForge Brick MQTT Proxy:
http://www.tinkerforge.com/en/doc/Software/Brick_MQTT_Proxy.html#brick-mqtt-proxy-topics-And-payload-structure
Installation Steps
* sudo apt-get install python3-pip
* sudo apt-get install python-pip
* Next must be done as user Root - IMPORTANT to use upgrade if already installed!!!
* sudo pip install tinkerforge paho-mqtt --upgrade
* sudo apt-get install mosquitto mosquitto-clients python-mosquitto
* mkdir /home/pi/tinkerforge
* mkdir /home/pi/tinkerforge/mqtt
* cd /home/pi/tinkerforge/mqtt
* sudo apt-get install libusb-1.0-0 libudev0 pm-utils
* wget http://download.tinkerforge.com/tools/brickd/linux/brickd_linux_latest_armhf.deb
* sudo dpkg -i brickd_linux_latest_armhf.deb
* Copy the file brick-mqtt-proxy.py to this folder after download from the TinkerForge website https://github.com/Tinkerforge/brick-mqtt-proxy
* sudo python brick-mqtt-proxy.py&
Tests
Check the device information of the connected Bricks And Bricklets
mosquitto_sub -v -t tinkerforge/enumerate/available/#
Output:
tinkerforge/enumerate/available/bricklet/humidity [{"_timestamp":1445348164.10837,"uid":"kcz","hardware_version":[1,1,0],"device_identifier":27,"connected_uid":"5VGrDJ","position":"a","firmware_ version":[2,0,2]}]
tinkerforge/enumerate/available/bricklet/temperature [{"_timestamp":1445348164.11728,"uid":"nfu","hardware_version":[1,1,0],"device_identifier":216,"connected_uid":"5VGrDJ","position":"b","firmw are_version":[2,0,3]}]
tinkerforge/enumerate/available/bricklet/lcd_20x4 [{"_timestamp":1445348164.129469,"uid":"rTS","hardware_version":[1,2,0],"device_identifier":212,"connected_uid":"5VGrDJ","position":"c","firmwar e_version":[2,0,6]}]
tinkerforge/enumerate/available/bricklet/barometer [{"_timestamp":1445348164.151401,"uid":"jXZ","hardware_version":[1,0,0],"device_identifier":221,"connected_uid":"5VGrDJ","position":"d","firmwa re_version":[2,0,2]}]
Check the subscriber For a Temperature Bricklet with UID "nfu"
mosquitto_sub -v -t tinkerforge/bricklet/temperature/nfu/temperature
Output Is the temperature. New messages are received when the temperature has changed
tinkerforge/bricklet/temperature/nfu/temperature {"_timestamp":1445348164.124881,"temperature":1606}
tinkerforge/bricklet/temperature/nfu/temperature {"_timestamp":1445348284.390836,"temperature":1612}
tinkerforge/bricklet/temperature/nfu/temperature {"_timestamp":1445348302.433974,"temperature":1618}
Add the TinkerForge Brick MQTT Proxy to /etc/rc.local via sudo nano /etc/rc.local
#TinkerForge MQTT Broker
cd /home/pi/tinkerforge/mqtt
'python brick-mqtt-proxy.py&
#Default interval is 3 seconds, change to 1 min by setting value to 60
python brick-mqtt-proxy.py --update-interval 60 &
printf "TinkerForge MQTT Broker started"

Changed: 2017-11-26 14:09, Category: Raspberry Pi MQTT, File: T6C236M1728.htm, ID: 1728