MQTT.FX Thingspeak

I try to do this project, but with DHT sensors, and i've got this error. Any help?
https://flows.nodered.org/flow/00e8c4223c3a4e6539b75a7541abfef2

Function

I use MQTT.fx broker (With thingspeak) and all settings (pub/sub) in the broker are ok.Now i want to use node-red, to obtain sensor data and send it to thingspeak via mqtt protocol, using MQTT.fx broker. What i have to add to my flow, in order to do the job?

It looks like you are passing the message from the DHT node to the MQTT Function. Can you show the Debug output for the message coming out of the DHT node?

The error is because either msg.payload.object or msg.payload.ambient doesn't exist. If you can share what the message coming out of the DHT node looks like, we can narrow down which is causing the issue.

msg.payload.object andmsg.payload.ambient exist in the MQTT Function node.
I pass the message from the DHT node through MQTT Function node to the mqtt out node.

This pic shows dht debug

This pic shows the mqtt debug

In the first post, your screenshot showed an error of Cannot read property toString of undefined coming from the MQTT Function node that would have been caused by either msg.payload.object or msg.payload.ambient not existing.

In your more recent post, you've shared a completely different error - "Invalid topic" coming from the MQTT publish node, and the MQTT function node no longer appears in your flow at all.

So at this point, I'm not sure what issue you want help with.

If its the Invalid topic specified error, then that will be because the MQTT node hasn't been configured with a valid topic to publish to, or you are passing in an invalid value for msg.topic.

Your screenshot shows the output of the DHT node - but given you've changed the flow, that's irrelevant now. It looks like its the output of the Temp node that you are passing to the MQTT node - so that would be the message we'd need to see to understand better what you are doing.

Sorry for the error

Your msg.payload seems to be just "26.00", so it does not have msg.payload.object or msg.payload.ambient. (Sorry if I misunderstood the discussion on a quick read).

msg.payload.object and msg.payload.ambient exist in the MQTT Function node.

No they don't exist. The debug shows your message doesn't contain those properties.

In the first pic i show the Function node content, may be they are not write properly ?

You might have written them in a function node but they don't exist in the message.

Look at your debug output. There NO msg.payload.object or msg.payload.ambient in the msg

That's why you get an error in the function (as Nick said)

How t fix it?

Feed the correct data into the function OR change the function to match whats going in.

Look at your debug node contents

There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item. https://nodered.org/docs/user-guide/messages

Closing this thread because it has be continued here: MQTT. Thingspeak