Example application for receiving Quantified Self data via MQTT.
These Python scrips demonstrate how to receive data from Medando apps. The Android apps BloodPressureCompanion and WeightCompanion have experimental support for sending the latest entries as MQTT messages.
Read more about the MQ Telemetry Transport (MQTT) protocol at MQTT.org.
Install Python as described on python.org (if it's not installed on your system already). We recommend to install the Python distribution Anaconda.
Install the Paho MQTT client library for Python (https://pypi.python.org/pypi/paho-mqtt):
pip install -r requirements.txt
Within the scripts configure the host name of the MQTT broker that you use. You must use the same MQTT broker that you configured in the Android apps.
test.mosquitto.org is an public test server that you can use for testing.
MQTT_BROKER_HOSTNAME = 'test.mosquitto.org'
We recommend to setup your own MQTT broker which should be non-public and secured.
To receive your MQTT messages start the simple MQTT subscriber:
python mqtt_subscriber.py
After you configured MQTT in the Android app, you should see something like:
de/medando/weightcompanion {"unit":"kg","weight":73.1}
This very simple example runs as an infinite loop. To end execution, use Ctrl-C.
Continue from here with more serious examples and applications. For example, evaluate the received MQTT payload with your data by extending the Python script.
You should also change the MQTT topic to something more specific than the default topic.
MQTT_TOPIC = 'de/medando/#'