DFRobot / DFRobot_MLX90614

DFRobot IR Thermometer Sensor MLX90614
MIT License
8 stars 16 forks source link

Compile error when using the Arduino Nano 33 BLE #1

Closed pedronf65 closed 1 year ago

pedronf65 commented 1 year ago

When compiling for the Arduino Nano 33 BLE: c:\dev\dev-Arduino\libraries\DFRobot_MLX90614\DFRobot_MLX90614.cpp: In member function 'void DFRobot_MLX90614_I2C::enterSleepMode(bool)': c:\dev\dev-Arduino\libraries\DFRobot_MLX90614\DFRobot_MLX90614.cpp:157:13: error: 'SDA' was not declared in this scope pinMode(SDA, OUTPUT); ^~~ c:\dev\dev-Arduino\libraries\DFRobot_MLX90614\DFRobot_MLX90614.cpp:158:13: error: 'SCL' was not declared in this scope pinMode(SCL, OUTPUT); ^~~ c:\dev\dev-Arduino\libraries\DFRobot_MLX90614\DFRobot_MLX90614.cpp:158:13: note: suggested alternative: 'SCK' pinMode(SCL, OUTPUT); ^~~ SCK For this Arduino they are defined like this: // Wire #define PIN_WIRE_SDA (18u) #define PIN_WIRE_SCL (19u)

pedronf65 commented 1 year ago

just made a pull request with the fix, this issue can be closed if pull request accepted

qsjhyy commented 1 year ago

Currently we are not actively compatible with Arduino Nano 33 BLE, you can solve this problem by pre-compiling macros:

#if define()   // Fill in the macro corresponding to Arduino Nano 33 BLE
    // wake up command, refer to the chip datasheet
    pinMode(PIN_WIRE_SDA, OUTPUT);
    pinMode(PIN_WIRE_SCL, OUTPUT);
    digitalWrite(PIN_WIRE_SCL, LOW);
    digitalWrite(PIN_WIRE_SDA, HIGH);
    delay(50);
    digitalWrite(PIN_WIRE_SCL, HIGH);
    digitalWrite(PIN_WIRE_SDA, LOW);
    delay(50);
#else
    // wake up command, refer to the chip datasheet
    pinMode(SDA, OUTPUT);
    pinMode(SCL, OUTPUT);
    digitalWrite(SCL, LOW);
    digitalWrite(SDA, HIGH);
    delay(50);
    digitalWrite(SCL, HIGH);
    digitalWrite(SDA, LOW);
    delay(50);
#endif