ArduinoJson Error

Hi,

I'm getting the following error using the ArduinoJson library and NiclaSystem library together:

note:   candidate expects 1 argument, 2 provided
     return arithmeticCompare(lhs, rhs);
            ~~~~~~~~~~~~~~~~~^~~~~~~~~~

When all four libraries are included below, I get the above error, but not when Nicla_System.h and Arduino_BHY2.h are commented out. Any guidance would be greatly appreciated. Thank you.

#include "Nicla_System.h"
#include "Arduino_BHY2.h"
#include <ArduinoJson.h>
#include <ArduinoJson.hpp>

To the best of my knowledge, the return statement only allows returning one value. This link should help explain it further.

Please post your full sketch and links to all 3rd party libraries (so we don't have to hunt for them and possibly end up with the wrong ones).

That return statement only returns one value, the result of the function call.

There is a function call

So this will return whatever arithmeticCompare returns. It seems (but who knows without the code and libraries) that the compiler complains about having two parameters for arithmeticCompare.

Hi,

Thanks for the responses. Below is the code and link to the JSON library documentation.

#include "Nicla_System.h"
#include "Arduino_BHY2.h"
#include <ArduinoJson.h>
#include <ArduinoJson.hpp>

SensorXYZ magnetometer(SENSOR_ID_MAG_RAW);

float x = 0;
float xAvg = 0;
int i = 0;

unsigned long previousMillis = 0;
const long interval = 100;

void setup() {
  Serial.begin(115200);

  nicla::begin();
  nicla::leds.begin();

  BHY2.begin(NICLA_I2C);
  magnetometer.begin(); 
}

void loop() {
  JsonDocument jsonData;
  String output;

  BHY2.update();

  while (!Serial) continue;

  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;

    if (i < 3) {
      x += magnetometer.x();
      I++;
    } else  {
      xAvg = x / 3;

      jsonData["x"] = String(xAvg);

      serializeJson(jsonData, output);

      if (xAvg > 300) {
        nicla::leds.setColor(green);
      } else {
        nicla::leds.setColor(blue);
      }

      x = 0;
      xAvg = 0;
      i = 0;
    }
  }
}

ArduinoJson: https://arduinojson.org

Supply the entire error message(s) so it is clear what has generated the error.

You don’t need the 2 includes - keep just the first one