Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1585

Python • MQTT on Raspberry Pi 3B+ - Subscribe two different topics with Python

$
0
0
Hallo

I have running Mosquitto on my old Rasp 3 B+ and I have a Python script (running as service unit) to write the values of my smart meter into a influxdb.
The values of the smart meter are published to Mosquitto with a Tasmota ESP32 each 10 seconds.
I use the values from the influxdb to show graphs with Grafana.

This worked well until I had the idea to add second Python script to save the values from my solar panels ("Balkonkraftwerk") to another influx db.
The values are coming from the OpenDTU (also some ESP microprocessor) to Mosquitto as well.
The second script works too, but I noticed that now I have around every 5 minutes an interruption of values of the smart meter values (first script). On and of each aprox. 5 minutes.
I stopped the OpenDTU service and the values are not interrupting anymore, so it is definetly the new script. Here is the grafana graph when I started the second script:
grafana_begin_second_script.jpg
I think I should subscribe in only one Python script both topics and save both separately in two dbs, but they have really different topic names, so if I want to catch them both with wildcards, I would subscribe nearly every MQTT publisher (Tasmota switches etc.) from my broker.

Is it possible that two simple MQTT subscibing Python scripts could not run along without blocking each other?
Or is it likely that that is not at all the cause for the interruptions of my first script?
I thought that MQTT subscribing is not such a heavy load at all.

Any idea how I could handle that easy?
Thanks, frank

Statistics: Posted by francwalter — Mon Jun 02, 2025 4:26 pm



Viewing all articles
Browse latest Browse all 1585

Trending Articles