Real‐time updates with MQTT - uajqq/weewx-belchertown-new GitHub Wiki

MQTT is a publish / subscribe system. Mostly used for IoT devices, but it works great for a live weather website.

MQTT Websockets allows websites such as this to connect to the MQTT broker to subscribe to a topic and get updates.

You will need to use an MQTT broker (aka server) to publish your data to. You can install your own broker pretty easily, or use a public one (some free, some paid).

Your WeeWx server will publish it's weather data to a broker (using the weewx-mqtt extension) and visitors to your website will subscribe to those updates using MQTT Websockets built in to this skin. When data is published the subscribers get that data immediately by way of the website updating without reloading.

With the weewx-mqtt extension installed, everytime WeeWx generates a LOOP it'll automatically publish that data to MQTT which will update your website in real time. Once ARCHIVE is published, your website will reload the forecast data, earthquake data and graphs automatically.

A sample weewx-MQTT extension config is below. Update the server_url, topic, and unit_system to suit your needs. Keep binding as archive and loop. Remove the tls section if your broker is not using SSL/TLS. Update the unit_system if needed.

    [MQTT](/uajqq/weewx-belchertown-new/wiki/MQTT)
        server_url = mqtt://username:[email protected]:port/
        topic = weather
        unit_system = US
        binding = archive, loop
        aggregation = aggregate
        [[tls](/uajqq/weewx-belchertown-new/wiki/[tls)]
            tls_version = tlsv1
            ca_certs = /etc/ssl/certs/ca-certificates.crt

Note: I did not write the MQTT extension, so please direct any questions or problems about it to the user forums.

MQTT Brokers

Install your own MQTT Broker

If you want to run your own MQTT broker, you can set one up on your own server. A good online tutorial can be found here.

Use a Public Broker

These public brokers have been tested as working with MQTT and Websockets. If you have others to add the to the list, let me know.