I'm calling an adafruit Flora LSM9DS0 magnetometer using the Adafruit library with the following sketch:

        #include <Wire.h>
        #include <SPI.h>
        #include <Adafruit_LSM9DS0.h>
        #include <Adafruit_Sensor.h>  // not used in this demo but required!

        unsigned long timeNow = 0;
        unsigned long mSecInHour = 3600000;
        unsigned long TimeNow =0;
        int millisecs =0;
        int seconds = 0;
        byte minutes = 0;
        byte hours = 0;

        int mag_raw_x;
        int mag_raw_y;
        int mag_raw_z;

        // i2c
        Adafruit_LSM9DS0 lsm = Adafruit_LSM9DS0();

        // You can also use software SPI
        //Adafruit_LSM9DS0 lsm = Adafruit_LSM9DS0(13, 12, 11, 10, 9);
        // Or hardware SPI! In this case, only CS pins are passed in
        //Adafruit_LSM9DS0 lsm = Adafruit_LSM9DS0(10, 9);

        void setupSensor()
          // 2.) Set the magnetometer sensitivity 

        void setup() 
        #ifndef ESP8266
          while (!Serial);     // will pause Zero, Leonardo, etc

          // Try to initialise and warn if we couldn't detect the chip
          if (!lsm.begin())

            while (1);
          Serial.println(F("Found LSM9DS0 9DOF, measurements in Gauss"));
         void loop() 
          TimeNow = millis(); 
          mag_raw_x = lsm.magData.x;
          mag_raw_y = lsm.magData.y;
          mag_raw_z = lsm.magData.z;

Which compiles and runs fine on the Arduino Uno, but I don't understand why the same sketch causes this compile error in the LSM9DS0 library when I compile for the LinkitOne?

    C:\Users\elbg\Arduino\libraries\arduino_373648\Adafruit_LSM9DS0.cpp: In member function 'bool Adafruit_LSM9DS0::begin()':

    C:\Users\elbg\Arduino\libraries\arduino_373648\Adafruit_LSM9DS0.cpp:77:16: error: 'SPCR' was not declared in this scope

         SPCRback = SPCR;


    C:\Users\elbg\Arduino\libraries\arduino_373648\Adafruit_LSM9DS0.cpp: In member function 'void Adafruit_LSM9DS0::write8(boolean, byte, byte)':

    C:\Users\elbg\Arduino\libraries\arduino_373648\Adafruit_LSM9DS0.cpp:365:18: error: 'SPCR' was not declared in this scope

           SPCRback = SPCR;


    C:\Users\elbg\Arduino\libraries\arduino_373648\Adafruit_LSM9DS0.cpp:374:7: error: 'SPCR' was not declared in this scope

           SPCR = SPCRback;


    C:\Users\elbg\Arduino\libraries\arduino_373648\Adafruit_LSM9DS0.cpp: In member function 'byte Adafruit_LSM9DS0::readBuffer(boolean, byte, byte, uint8_t*)':

    C:\Users\elbg\Arduino\libraries\arduino_373648\Adafruit_LSM9DS0.cpp:415:18: error: 'SPCR' was not declared in this scope

           SPCRback = SPCR;


    C:\Users\elbg\Arduino\libraries\arduino_373648\Adafruit_LSM9DS0.cpp:426:7: error: 'SPCR' was not declared in this scope

           SPCR = SPCRback;


Any suggestions welcome !

  • The SPCR register is low level programming for SPI on a Arduino Uno.
    – Jot
    Commented Mar 20, 2018 at 16:33

1 Answer 1


The Adafruit library for the LSM9DS0 is written to run on an 8-bit Arduino. The LinkitOne isn't - it's an ARM board.

Either get a different library that is written to work on ARM, write your own library to work on ARM, or don't use that combination of components.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.