• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Connect ESP32 to Watson IoT platform using AsyncMqttClient

Q&A Forum › Category: ESP32 › Connect ESP32 to Watson IoT platform using AsyncMqttClient
0 Vote Up Vote Down
mirko.jokic asked 6 years ago

Hi Rui,

First of all, thanks for your great tutorials. I am really enjoying passing through it.

I have found interesting tutorial about connecting ESP32 to Watson IoT platform via MQTT.

iotdesignpro.com/projects/how-to-connect-esp32-with-ibm-watson-cloud-platform

However, it uses PubSubClient Library. I am trying to make it by using AsyncMqttClient cause I already used to it, but cant figure out how to set credentials to make successful connection.

May someone please assist here?

Question Tags: AsyncMqttClient, ESP32, Watson IoT
1 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 6 years ago

Hi.
Are you talking about these credentials they refer in the tutorial?

#define ORG "******"
#define DEVICE_TYPE "ESP32"
#define DEVICE_ID "***********"
#define TOKEN "********"

I’ve taken a quick look at the code as these seem to be used on the payload messages.
example:

String payload = "{\"d\":{\"Name\":\"" DEVICE_ID "\"";
payload += ",\"temperature\":";
payload += temperature;
payload += "}}";

So, I think you just need to send this payload to the right topic. You can use the following snipet as a reference (using the AsyncMQTT)

// Publish an MQTT message on topic 
    uint16_t packetIdPub2 = mqttClient.publish("TOPIC", 2, true, payload.c_str());
    Serial.print("Publishing on topic TOPIC at QoS 2, packetId: ");
    Serial.println(packetIdPub2);

Replace the “TOPIC” with the topic you want to send that payload to.

Repeat this for the other topics you need to send information to.

I’m not familiar with that platform, so I’m nor sure what’s really needed.

Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.