Raja kullayappa E
Raja kullayappa E

Reputation: 1

Unable to send data to ThingsBoard gateway through MQTT

I have installed ThingsBoard server on one PC (UBUNTU16.04) and ThingsBoard Gateway on another PC(UBUNTU18.04) ,In order to send data to ThingsBoard Gateway I installed Mosquitto MQTT broker on another PC.I followed configuration guides to connect broker to Gateway as well as server (using access token and host ip).

I connected temperature sensor to ESP32. While I am trying to send the data to gateway through MQTT the data is not getting to the gateway.The topic I used here is "v1/gateway/telemetry" in order to publish the data.

Can we use Gateway Device ID to send data? How can I send data either by using topic or by using device id or by using device access token?(from device)

All the PC 's are connected to the same network(Private network).

I am facing this issue can Someone please sort it out...

Upvotes: 0

Views: 1205

Answers (1)

Arpit Jain
Arpit Jain

Reputation: 1315

You need to create a Proxy Layer Between MQTT Broker and your server.

var mqtt = require('mqtt'), url = require('url');
var client = mqtt.connect('mqtt://localhost:1883',
{
username: '<username>',
password: '<password>'
});

console.log("Connected to MQTT Broker:- localhost” + client.toString());
var awsIot = require('aws-iot-device-sdk');
var device = awsIot.device({

keyPath:  Certificate key file path,
certPath: Certificate file path,
caPath:   Certificate root file path,
clientId: AWS Thing Name,
region:   AWS IoT Broker region,
});

device.on('connect', function ()
{
console.log("Connected to AWS IoT Broker:- " + device.toString());
});

client.on('connect', function()
{
//subscribe to a topic (#)
client.subscribe('#', function ()
{
client.on('message', function (topic, message, packet) {
console.log("Received :-" + message + " on " + topic);
device.publish(topic, message);
console.log("Sent :-" + message + " on " + topic);
});
});
});

Something like this might help you.

Upvotes: 0

Related Questions