• Piatra Engineering, Erskineville NSW, AUSTRALIA

post-image

Pythonic Solar Position Sensor in MQTT System

Project Overview

This is a small project to implement and test a MQTT SparkPlug formatted virtual sensor and integrate it into 3rd party systems supporting the SparkPlug protocol.

Implementation

In this project we utilise Python PySolar libraries to accurately calculate the elevation and azimuth of the suns position for a given latitude, longitude and elevation of an observer. This information is generated for a specific location and time on the Earth's surface.

This entire script runs as a stand alone Docker container, with sensitive variables passed in as environment variables. The process also authenticates to a separate Mosquitto MQTT broker. The broker authentication details are passed into the Python process using a simple JSON configuration file. The solar position is calculated every 15 seconds and updated to the MQTT server.

The data format and topic structure that the sensor presents to the MQTT broker follows the SparkPlug protocol. This formalises the topic and message format on the MQTT broker so that the information can be digested by SparkPlug compliant services on the same MQTT broker.

Notes

Sparkplug is an open-source software specification that provides MQTT clients the framework to seamlessly integrate data from their applications, sensors, devices, and gateways within the MQTT infrastructure in a bi-directional and interoperable way.