Where did SPI.h go?

Hey all, I’ve been using #include <SPI.h> for the past few months on an electron without any issues.

Today all of a sudden i started getting the following error: SPI.h: No such file or directory

Anyone else have this issue?

@PeaTearDial, you don’t need that include since SPI is part of the system firmware. All you need to do is include “Particle.h”.

Thanks peekay,

Hey, I’m getting the error ‘SPISettings’ does not name a type

from my code here :slight_smile:

private:
  SPISettings _spiSettings;
  int _ss;
  int _reset;
  int _dio0;
  int _frequency;
  int _packetIndex;
  int _implicitHeaderMode;
  void (*_onReceive)(int); 

Works fine on the arduino, and was working OK on the electron up until the other day.

@PeaTearDial, there are actually a couple of firmware issues being discussed on this:

If you add #include "Arduino.h"; as part of your includes, it should work.

1 Like

Thanks for that good to know I’m not going crazy!
still have a problem though. when I add the arduino header I get this:

Arduino.h: No such file or directory

@PeaTearDial, can you show that part of your code?

Hey I got the arduino library added OK but I’m still getting the following error.

LoRa.h:81:3: ‘SPISettings’ does not name a type

Hey, I added the arduino.h file by choosing it in Libraries in particle build.
However the file is quite short. Is this the right file?

    #ifndef _ARDUINO_H_
#define _ARDUINO_H_

/*
 * Arduino compatability shim for Particle applications and libraries
 *
 * 2015, John Plocher
 * Released to the public domain
 *
 * Leverage the normal include <Arduino.h> mechanism to do the right thing.
 *
 * The "right thing" means
 *  assume the caller wants an Arduino/wiring-like environment,
 *  define the things that are defined for 'duino users in the official IDE env
 *  don't require libs and apps to sprinkle  ifdef PARTICLE or SPARK directives 
 */

#include <application.h>

/*
 * You can use conditional define checks if needed:
 *
 *    #if defined(SPARK_CORE)	// only defined for .ino files, not .cpp
 *
 * and
 *
 *    #if defined(SPARK)
 *      #if defined(PLATFORM_ID)
 *        #if (PLATFORM_ID == 0)
 *    	  //Core
 *        #elif (PLATFORM_ID == 6)
 *             //Photon
 *        #endif
 *      #endif  //PLATFORM_ID
 *    #endif  //SPARK
 */

#define PI              3.1415926535897932384626433832795
#define HALF_PI         1.5707963267948966192313216916398
#define TWO_PI          6.283185307179586476925286766559
#define DEG_TO_RAD      0.017453292519943295769236907684886
#define RAD_TO_DEG      57.295779513082320876798154814105
#define EULER           2.718281828459045235360287471352

#define abs(x)       ((x)>0?(x):-(x))
#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
#define radians(deg) ((deg)*DEG_TO_RAD)
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x)        ((x)*(x))

#define lowByte(w)   ((uint8_t) ((w) & 0xff))
#define highByte(w)  ((uint8_t) ((w) >> 8))

#define bitRead(value, bit)            (((value) >> (bit)) & 0x01)
#define bitSet(value, bit)             ((value) |= (1UL << (bit)))
#define bitClear(value, bit)           ((value) &= ~(1UL << (bit)))
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))

#endif

@PeaTearDial, that’s definitely not what you need! Remove that library and the associated #include and replace it with the following at the top of your file:

#include "Particle.h"
#include "Arduino.h"
1 Like

Hey, I tried that but I'm getting the following error..

Arduino.h: No such file or directory

not sure whats going on..

I'm not sure if this is related but I have another APP that stopped compiling also..

For this line of code

success = Particle.publish("eR", output, PRIVATE, WITH_ACK);

I get the error

'WITH_ACK' was not declared in this scope

once again this was working previously.

@PeaTearDial, you may need to share your code. Are you targeting the right device (Electron)?

What system version are you targeting?

You may also either drop #include "Particle.h" or put it after #include "Arduino.h"

1 Like

Hey All,

Looks like you were right I was targeting the wrong version. I don’t know how it changed, but anyway everything is working now.

Now targeting v 0.6.2

Thanks all for your help!

2 Likes