This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

mqtt with logic machine
#1
how to subscribe to mqtt data using logic machine
Reply
#2
https://kb.logicmachine.net/integration/mqtt-client/
Reply
#3
Hello sir i want to publish these data 

mosquitto_pub -h mqtt.intingy.com -u entelechy_gateway -p 1883 -P "wr6NOng8HzFC2KpB5cPoxXXgCSYBHXbGgRG9b3R39ok"  -t "entelechy/" -m "mqtt_connection_test"

bit in lm when I publish  it in the log it shows empty and nothing shows in it .
Reply
#4
Use the first example from our knowledge base. Change variables in the first 6 lines as needed.
Reply
#5
thank you sir it got connected but the data from the another side is not coming I am having an error

Attached Files Thumbnail(s)
       
Reply
#6
"not authorized" error means wrong username and/or password.

This works for me:
Code:
broker = 'mqtt.intingy.com'
port = 1883
username = 'entelechy_gateway'
password = 'wr6NOng8HzFC2KpB5cPoxXXgCSYBHXbGgRG9b3R39ok'
topic = 'entelechy/'
payload = 'mqtt_connection_test'

mqtt = require('mosquitto')
client = mqtt.new()

client.ON_CONNECT = function(status, rc, msg)
  if status then
    log('mqtt connected')
    client:publish(topic, tostring(payload))
  else
    log('mqtt connect failed ' .. tostring(msg))
    client:disconnect()
  end
end

client.ON_PUBLISH = function()
  log('publish ok')
  client:disconnect()
end

client:login_set(username, password)
status, rc, msg = client:connect(broker, port)

if status then
  client:loop_forever()
else
  log('connect failed: ' .. tostring(msg))
end
Reply
#7
thankyou sir it is working .now I want to receive data what should I do to receive data .

Attached Files Thumbnail(s)
   
Reply
#8
Second example here (Object value exchange via MQTT): https://kb.logicmachine.net/integration/mqtt-client/
Reply
#9
I have tried this code but it is showing some error

Attached Files Thumbnail(s)
   
Reply
#10
Check this: https://forum.logicmachine.net/showthrea...3#pid33643
Reply


Forum Jump: