Changed to string safe sprintf.
This commit is contained in:
parent
2ca6ef7017
commit
ba502ea124
|
@ -40,8 +40,8 @@ const char* MQTT_PASSWORD = "Falcon(91)";
|
|||
WiFiClient client;
|
||||
PubSubClient mqtt(MQTT_SERVER, MQTT_PORT, client);
|
||||
const char* MQTT_TOPIC = "test/lux";
|
||||
|
||||
char mqtt_buf[256];
|
||||
#define MQTT_BUF_LEN (256u)
|
||||
char mqtt_buf[MQTT_BUF_LEN];
|
||||
|
||||
void poll_INA219(void);
|
||||
void init_OTA(void);
|
||||
|
@ -177,7 +177,8 @@ void loop()
|
|||
{
|
||||
slow_loop_millis = millis();
|
||||
|
||||
sprintf(mqtt_buf, "{\"lux\":%5.2f,\n\"bus_voltage\":%2.2f,\n\"current_ma\":%3.2f,\n\"temperature\":%2.2f}",
|
||||
snprintf(mqtt_buf, MQTT_BUF_LEN,
|
||||
"{\"lux\":%5.2f,\n\"bus_voltage\":%2.2f,\n\"current_ma\":%3.2f,\n\"temperature\":%2.2f}",
|
||||
veml.readLux(VEML_LUX_AUTO), ina219.getBusVoltage_V(), ina219.getCurrent_mA(), board_temp.readTemperatureF());
|
||||
mqtt.publish(MQTT_TOPIC, mqtt_buf);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user