Skip to content
Permalink
Browse files

replace the use of calculate buffer by a constant buffer size for jso…

…n size
  • Loading branch information...
1technophile committed Jun 29, 2019
1 parent 618f8d6 commit 2ee18320beb0325f0cdded1dc0a7ce518d54377d
Showing with 5 additions and 10 deletions.
  1. +1 −2 ZsensorBH1750.ino
  2. +1 −2 ZsensorBME280.ino
  3. +1 −2 ZsensorDHT.ino
  4. +1 −2 ZsensorINA226.ino
  5. +1 −2 ZsensorTSL2561.ino
@@ -55,8 +55,7 @@ void MeasureLightIntensity()
{
if (millis() > (timebh1750 + TimeBetweenReadingBH1750)) {//retriving value of Lux, FtCd and Wattsm2 from BH1750
trc(F("Creating BH1750 buffer"));
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(3);
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
JsonObject& BH1750data = jsonBuffer.createObject();

timebh1750 = millis();
@@ -129,8 +129,7 @@ void MeasureTempHumAndPressure()
trc(F("Failed to read from Weather Sensor BME280!"));
}else{
trc(F("Creating BME280 buffer"));
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(6);
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
JsonObject& BME280data = jsonBuffer.createObject();
// Generate Temperature in degrees C
if(BmeTempC != persisted_bme_tempc || bme280_always){
@@ -49,8 +49,7 @@ void MeasureTempAndHum(){
trc(F("Failed to read from DHT sensor!"));
}else{
trc(F("Creating DHT buffer"));
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(2);
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
JsonObject& DHTdata = jsonBuffer.createObject();
if(h != persistedh || dht_always){
DHTdata.set("hum", (float)h);
@@ -52,8 +52,7 @@ void MeasureINA226(){
if (millis() > (timeINA226 + TimeBetweenReadingINA226)) {//retriving value of temperature and humidity of the box from DHT every xUL
timeINA226 = millis();
trc(F("Creating INA226 buffer"));
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(3);
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
JsonObject& INA226data = jsonBuffer.createObject();
// Topic on which we will send data
trc(F("Retrieving electrical data"));
@@ -92,8 +92,7 @@ void MeasureLightIntensityTSL2561()
timetsl2561 = millis();

trc(F("Creating TSL2561 buffer"));
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(3);
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
JsonObject& TSL2561data = jsonBuffer.createObject();

sensors_event_t event;

0 comments on commit 2ee1832

Please sign in to comment.
You can’t perform that action at this time.