I am trying to create a MQTT message with Sprintf, but I am not seeing any value for Level when it prints to the serial monitor. Am I doing something wrong with the data types?
char JSON_buf[100];
char float_buf[5];
String level = "high";
float volume = resistanceToVolume(resistance, ZERO_VOLUME_RESISTANCE, CALIBRATION_RESISTANCE, CALIBRATION_VOLUME);
Serial.print("Calculated volume: ");
Serial.println(volume, 5);
if (volume < 2000){
level = "Low";
Serial.print("Level: ");
Serial.println(level);
}
dtostrf(volume, 4, 1, float_buf);
float_buf[4] = '\0';
sprintf(JSON_buf, "{"state":{"reported":{"Volume":%s:{"Level":%s}}}}", float_buf, level);
print_log("shadow update", myClient.shadow_update(AWS_IOT_MY_THING_NAME, JSON_buf, strlen(JSON_buf), NULL, 5));
Serial.println(JSON_buf);