Send variables with mqtt publish

Forgive a noob like me, but I can't find out how to solve this:

I got 15 values that I need to send to MQTT (all cell voltages of the pack), and I want to send them in a loop:

    for (byte i = 1; i <= packCellInfo.NumOfCells; i++)
    {
      dtostrf(packCellInfo.CellVolt[i -1], 5, 0, STRpackCellInfoCellVolt);
      client.publish("SmartBMS/Cell",NUMBER OF CELL (i) TO BE INSERTED, STRpackCellInfoCellVolt);
    }

How would I need to format the publish command to add the index to the published text?
I want it to look something like: "SmartBMS/Cell 1" ... "SmartBMS/Cell 15"
Thanks!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.