Skip to content

Need help: MQTT Client with Sparkfun AssetTracker (SARA-R5) APIs #34

@Davefries1966

Description

@Davefries1966

Hi all,
I purchased a Sparkfun AssetTracker development kit with MicroMod ESP32 add-on, GNSS antenna and so on.

I’m wondering how to find examples about using MQTT (I would use the onboard LTE modem instead of the Wi-Fi connection, so no "PubSubClient" library ....).

I’ve looked at AssetTracker APIs and tested some examples, all working with my environment (Arduino IDE on Windows 11), but I didn’t find how to correctly use the “MQTT” APIs.

I mean, I’ve written some code which seems to be able to connect (i.e., the connectMQTT() method returns OK) to some public MQTT brokers (e.g., MOSQUITTO, EQMX, etc) but:

  • Publish and subscribe methods return errors.
  • I didn’t actually understand how/where to use the readMQTT() method.
  • I set the command callback, but I don’t understand its purpose (I would use readMQTT() instead to read topic contents).
  • How to set a callback to read incoming topics which I’ve subscribed to ?

Please find attached below the code I've written, just to understand where I’m doing wrong...

Thanks in advance for your support! :-)

Best regards
David

MQTT_example.txt

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions