Sending and Recieving Data

I am in a middle of an IOT project. I have to design the dashboard. I am facing difficulties in setting up the dashboard. I am using I want to know how to send data from thingsboard server through a knob widget(numeric data) to arduino using esp8266 and mqtt and to send that data back to thingsboard gauge widget. Like I want to send and receive data. I have some issues in arduino codes. If anyone can help. That would be appreciated. Thanks

I have code in java script for doing the same task but that is working on command prompt. Can someone convert this code to C for arduino and esp8266.

var mqtt = require(‘mqtt’);
const ACCESS_TOKEN = process.argv[2];

var client = mqtt.connect(‘mqtt://’,{
username: ACCESS_TOKEN

var controlValue,
realValue = 25;

client.on(‘connect’, function () {
console.log(‘Uploading temperature data once per second…’);
setInterval(publishTelemetry, 1000);

client.on(‘message’, function (topic, message) {
console.log('request.topic: ’ + topic);
console.log('request.body: ’ + message.toString());
var requestId = topic.slice(‘v1/devices/me/rpc/request/’.length),
messageData = JSON.parse(message.toString());
if (messageData.method === ‘getValue’) {
if(controlValue === undefined) {
client.publish(‘v1/devices/me/rpc/response/’ + requestId, JSON.stringify(realValue));
} else {
client.publish(‘v1/devices/me/rpc/response/’ + requestId, JSON.stringify(controlValue));
} else if (messageData.method === ‘setValue’) {
controlValue = messageData.params;
console.log('Going to set new control value: ’ + controlValue);
} else {
client.publish(‘v1/devices/me/rpc/response/’ + requestId, message);

function publishTelemetry() {
client.publish(‘v1/devices/me/telemetry’, JSON.stringify({temperature: realValue}));

function emulateTemperatureChanging() {
if(controlValue !== undefined) {
if(controlValue >= realValue) {
realValue += (Math.random() + (Math.abs(controlValue - realValue)/30));
} else {
realValue -= (Math.random() + (Math.abs(controlValue - realValue)/30));

Did you manage to subscribe to the rpc topic i also have same problem. PLease share the solution