MQTT datafeed

The dataloggers provide a new reading approximately once every minute. It is consolidated into RRD databases on this website and used to provide graphs.

If you want the raw data you can subscribe to the MQTT message queue. Messages are of the form:

TopicValue
sensor/loddon1/temp/air24.4375
sensor/loddon1/temp/river24.6875
sensor/loddon1/level/river{ "count": 10, "max": 213, "mean": 213, "min": 213, "time": 1438856184 }

Temperature readings are in text, in Celcius.

Level readings are JSON structures. Levels are in centimetres above an arbitrary datum (e.g. a riverbank). Negative numbers indicate a level below datum.

You can use the Mosquitto command-line tools to try this out:

mosquitto_sub -h dl1.findlays.net -v -t 'sensor/#'

Here is a sample client written in Python using the Paho libraries:

#!/usr/bin/env python

import paho.mqtt.client as mqtt

# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, rc):
    if debug: print("Connected with result code "+str(rc))
    # Subscribing in on_connect() means that if we lose the connection and
    # reconnect then subscriptions will be renewed.
    #
    # You can subscribe to a specific sensor or to the whole datafeed here:
    #     client.subscribe("sensor/thames1/level/river")
    #     client.subscribe("sensor/#")
    client.subscribe("sensor/#")

# The callback for when a message is received from the server.
def on_message(client, userdata, msg):
    # This is where you put your own code to process the data
    print(msg.topic+" "+str(msg.payload))

# Connect to the message queue
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message

client.connect("dl1.findlays.net", 1883, 60)

# Blocking call that processes network traffic, dispatches callbacks and
# handles reconnecting.
# Other loop*() functions are available that give a threaded interface and a
# manual interface.
client.loop_forever()

Datalogger homepage