LIS3DH Library Can't Compile on UNO R4 WiFi

I’m trying to use the SparkFun LIS3DH library with my Arduino Uno R4 Wifi.

However, I can’t get it to compile. For instance, even in isolation the library won’t build. This sketch won’t compile:

#include "SparkFunLIS3DH.h" // Accelerometer/IMU
void setup() {}
void loop() {}

It yields this error, among other similar ones:

...Arduino\libraries\SparkFun_LIS3DH_Arduino_Library\src\SparkFunLIS3DH.cpp:115:7:
 error: 'class arduino::ArduinoSPI' has no member named 'setClockDivider'

It seems like the wrong compiler constants are defined and the wrong code is being compiled.

I’ve tried this on 3 computers, with 2 versions of the IDE: 2.3.2 and 2.2.1, as well as with the Web-based Arduino Cloud IDE. Results are the same everywhere.

Anyone have any idea what’s going on here?

Attached is a screen shot, with the correct board selected:

https://1drv.ms/i/s!Aiu2GSJB3SQehN9gAi5 … g?e=kuMHTP

It looks like a problem with that older library pointing to a deprecated function; you can do one of the following:

A. Install an older version of Arduino IDE (such as 1.8x) and try it instead

B. Modify the SparkFunLIS3DH.cpp file in the library folder to remove the ‘setClockDivider’ function call. Open the file at “Arduino\libraries\SparkFun_LIS3DH_Arduino_Library\src\SparkFunLIS3DH.cpp” and find line 115. It should look like this:

_arduinoSPI->setClockDivider(LIS3DH_SPI_CLOCK_DIV); // Set SPI clock speed (comment out or remove this line)

Change it to:

//_arduinoSPI->setClockDivider(LIS3DH_SPI_CLOCK_DIV); // Set SPI clock speed (commented out)

C. Try updating Open the Boards Manager by going to Tools > Board > Boards Manager…

Search for “samd” and install the latest version of the “Arduino SAMD Boards (32-bits ARM Cortex-M0+)” package. After installation, select your board from Tools > Board menu and try compiling again.

D. try a different microcontroller

The only thing that got me past the compiler trouble was commenting out several calls to the SPI object at startup that were failing.

However, while this hack may work locally, it doesn’t work trying to build and deploy with OTA deployment from the Arduino cloud, since I can’t hack the libraries up there.

Is there a more-modern version of the LIS3DH library that I might use, that’ll compile from the Cloud IDE?

Might give the adafruit library a try.

https://www.arduino.cc/reference/en/lib … it-lis3dh/