User Manual

You can work around this '1 print = 1 publication' restriction by using the printf function, as shown in the example below:
For a full list of printf modifiers (the special '%' character sequences that get replaced with variables after the main
string) see printf here (https://adafru.it/lFm).
The most common modifiers are described below though (all preceded by '%' so '%d' for a signed decimal value, etc.) :
d or i: Signed decimal value ('int', 'int16_t', etc.)
u: unsigned decimal value ('uint32_t', etc.)
x: lower-case hexadecimal integer (ex. 'a12b' for 0xA12B)
X: upper-case hexadecimal integer (ex. 'A12B' for 0xA12B)
f: floating point value ('float', etc.)
s: null-terminated string of characters (ex. "sample")
c: A single characters (ex. 'a')
Example
The following sketch shows how you might use AdafruitMQTTTopic in the real world. The latest source can be found
in the MQTT/MqttTopicClass folder in 'examples'.
int number_of_days = 7;
char* place = "somewhere";
pub.print(number_of_days);
pub.print(" days since something happened ");
pub.print(place);
int number_of_days = 7;
char* place = "somewhere";
pub.printf("%d days since something happened %s", number_of_days, place);
/*********************************************************************
This is an example for our Feather WIFI modules
Pick one up today in the adafruit shop!
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
MIT license, check LICENSE for more information
All text above, and the splash screen below must be included in
any redistribution
*********************************************************************/
#include <adafruit_feather.h>
#include <adafruit_mqtt.h>
#include "certificate_mosquitto.h"
/* This sketch connects to a public MQTT server (with/without TLS)
* and publishes a message to a topic every 5 seconds.
*
* For server details see http://test.mosquitto.org/
* - Port 1883 : MQTT, unencrypted
© Adafruit Industries https://learn.adafruit.com/introducing-the-adafruit-wiced-feather-wifi Page 125 of 202