As the topic states, I have a simple (to soon be more complex) need to consume MQTT data from sensors into node-red. I have successfully used mosquito and paho in a python script to create 2 separate MQTT messages from the sensor. I have successfully consumed these MQTT messages into node-red and built corresponding gauges/graphs. However my end goal is to write the data to a mysql DB, which I have also successfully set up getting insert to the DB for a single message. What I need is a single line insert into the table which will contain all the measurements/messages rather than just one measurement at a time.
Now for the ask...the BMP108 outputs temp and humidity, I have concatenated these two values into a string and can output that as a message containing both measurements. But when I get to node-red, I am unable to take the single topic with 2 messages and split out the data. I have tried the json convert and switch, but cannot seem to get the incoming two data point message to be split. I suspect it is in the structure of the data being sent via MQTT.
From python MQTT publish of temperature (working):
client = mqtt.Client()**
Same for python MQTT publish of pressure (working):
However with the string created in python script to send both temperature and pressure by using in python:
msgs = temperature, pressure and client.publish ("bmp180_all", msgs), my raspberry pi terminal print(msgs) now shows (the correct temp, the current pressure) I cannot seem to parse this out via node red.
Any assistance would be greatly appreciated