Ubidots Community

Siple Switch no working

Hello, i´m trying to get the subscriptions working. I just created a variable called sw1 in ubidots and add a switch widget in the dashboard and upload a simple example code to the ESP8266 board for MQTT subscription.

I can not get anything on the boar side … here is de serial monitor:

It seems it never callsback … do you have any idea why there is a “/lv” added to the topic at the end ?

I think this could be the problem but I hardcoded de “device label” and de “variable label´” … i dont know why subscribed to that topic.

here is the code also:

#include “UbidotsESPMQTT.h”

#define TOKEN “MY_TOKEN” // Your Ubidots TOKEN
#define WIFINAME “LG_K10” //Your SSID
#define WIFIPASS “MY_PASS” // Your Wifi Pass

Ubidots client(TOKEN);

void callback(char* topic, byte* payload, unsigned int length) {
Serial.print(“Message arrived [”);
Serial.print("] ");
for (int i=0;i<length;i++) {

void setup() {
// put your setup code here, to run once:
client.setDebug(true); // Pass a true or false bool value to activate debug messages
client.wifiConnection(WIFINAME, WIFIPASS);
client.ubidotsSubscribe(“secadero_1”,“sw1”); //Insert the dataSource and Variable’s Labels

void loop() {
// put your main code here, to run repeatedly:
client.ubidotsSubscribe(“secadero_1”,“sw1”); //Insert the dataSource and Variable’s Labels

Hi @patriciollovera,

I hope all is well,

Regarding your question, lv is added at the end of the topic, to return the last value received by the variable. Additionally, can you please add in the void setup() the following line to make sure you are subscribing using the correct URL

client.ubidotsSetBroker("industrial.api.ubidots.com"); // Sets the broker properly for the Industrial account

At last note, you can refer to our Hardware documentation or Connect a NodeMCU ESP8266 to Ubidots over MQTT guide for further examples.

All the best,