bluerobotics / BlueRobotics_MS5837_Library

Arduino library for the MS5837 pressure sensor.
MIT License
54 stars 60 forks source link

Library does not compile for certain newer Arduino targets #20

Open NeilBaner opened 3 years ago

NeilBaner commented 3 years ago

When I include the library in Arduino IDE, and compile for the Arduino Nano 33 BLE/BLE Sense boards, I get some errors due to D1 and D2 being #define-d in pins_arduino.h, from the built-in Arduino libraries, causing a conflict with the D1 and D2 variables declared in the library.

The exact error is as follows:

In file included from C:\Users\neilbaner\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.0\cores\arduino/Arduino.h:90:0,
                 from sketch\MS5837_Example.ino.cpp:1:
C:\Users\neilbaner\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.0\variants\ARDUINO_NANO33BLE/pins_arduino.h:82:14: error: expected unqualified-id before numeric constant
 #define D1   1
              ^
C:\Users\neilbaner\Documents\Arduino\libraries\BlueRobotics_MS5837_Library/MS5837.h:88:11: note: in expansion of macro 'D1'
  uint32_t D1, D2;
           ^
exit status 1
Error compiling for board Arduino Nano 33 BLE.
Subseaking commented 1 year ago

Had the exact same issue on Portenta H7 - applied the changes suggested by @NeilBaner for merge and the code compiles now. Physical testing of sensor remains.