cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Sending data from Raspberry Pi to Thingworx using MQTT

kt1
3-Newcomer
3-Newcomer

Sending data from Raspberry Pi to Thingworx using MQTT

I want to connect raspberry pi to thingworx via mqtt. I am using Mosquitto broker and Paho mqtt as a client on raspberry pi to send data to thingworx. But i am not able to see the message on thingworx can anyone help. The steps I followed are given below.

 

Raspberry Pi

  • Installed Mosquitto broker
  • Installed Paho mqtt client
  • python script for publishing messgae is attached below. where in broker IP address of raspberry pi is written.
  • when tried to publish on the topic from raspberry pi it works fine but when tried the same for Thingworx it doesnt work.

Steps for Thingworx

  • All the steps are attached below where the server name is the Ip adress of the raspberry pi
  • After this when a any mesaage is published on broker there is no change in the property of thingworx. can anyone please tell me why?

Thanks in advance.

1 REPLY 1
CRArko
17-Peridot
(To:kt1)

Hello,

 

There is an article that might be applicable to your use case.

 

In summary, the AutoMapping functionality of the MQTT and MQTTSubscriber Thing Templates automatically establishes a subscription and a publishing arrangement with the MQTT broker for all properties defined on the Thing.

  • MQTT messages sent to the broker with topics corresponding to an auto-mapped property are automatically subscribed and will update the property values on the Thing when received.
  • Property value changes on the Thing will be sent out as Publish messages to the MQTT broker, which are sent back to ThingWorx as a subscribed topic update.
  • A ThingWorx subscription that is configured to change a property value on an MQTT Thing in response to a data change on that same MQTT Thing can result in a blocked thread.

The article provides also a possible workaround:

Define publish/subscribe subscriptions for properties manually on the Thing in question.

    • For properties that must be updating from MQTT, make sure to set the subscribe flag on the mapping that is created.
    • For properties that should not be sending out updates to MQTT, do not set the publish flag on the mapping.
    • Avoid setting up mappings that do both publish and subscribe, especially where the property is likely to be modified during an MQTT triggered event.

 

Please let me know if this gets you pointed in the right direction,

 

-- Craig A.

Announcements


Top Tags