Help with connection MQTT-ARGON

Some basic hints to make your code readable and maintainable

  1. Honestly consider each and every hint you already got at an earlier time - if you did, I wouldn’t have to reiterate some of the following points as I already pointed them out two weeks ago
  2. I would recommend you avoid using distinct variables xMag1, xMag2, … but rahter learn to use arrays.
  3. when dealing with multiple instances of the same kind of variables xMag, yMag, zMag, … you should consider using a struct.
  4. when using hardware like your sensors, there often are useful libraries that make working with these much simpler than having to deal with raw I2C communication
  5. don’t create tons of Particle.variable() instances. When you have a “compound” set of data, keep that set together in one Particle.variable()
  6. the same goes for Particle.publish() calls - a single string holding all data is much more effective and doesn’t require that many delay() calls
  7. DON’T copy/paste large blocks of code but use functions!
  8. when posting code in a forum try to have a minimal example that focuses on the issue at hand and don’t overload any reader with tons of redundant lines of code, otherwise they won’t actually read that code at all.

And finally to your MQTT question.
If you want to receive data from another MQTT client (i.e. your Argon as data source) your data sink client needs to subscribe to the topic the source publishes.

2 Likes