Skip to content

Commit

Permalink
replace the use of calculate buffer by a constant buffer size for jso…
Browse files Browse the repository at this point in the history
…n size
  • Loading branch information
1technophile committed Jun 29, 2019
1 parent 618f8d6 commit 2ee1832
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions ZsensorBH1750.ino
Expand Up @@ -55,8 +55,7 @@ void MeasureLightIntensity()
{ {
if (millis() > (timebh1750 + TimeBetweenReadingBH1750)) {//retriving value of Lux, FtCd and Wattsm2 from BH1750 if (millis() > (timebh1750 + TimeBetweenReadingBH1750)) {//retriving value of Lux, FtCd and Wattsm2 from BH1750
trc(F("Creating BH1750 buffer")); trc(F("Creating BH1750 buffer"));
const int JSON_MSG_CALC_BUFFER = JSON_OBJECT_SIZE(3); StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;
JsonObject& BH1750data = jsonBuffer.createObject(); JsonObject& BH1750data = jsonBuffer.createObject();


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


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


sensors_event_t event; sensors_event_t event;
Expand Down

0 comments on commit 2ee1832

Please sign in to comment.