Has anyone had success using this breakout board, and the Sparkfun-created library for it, on the Photon? I’ve used it in the past on the Photon, but now that I’m trying a new project I’m getting familiar errors and can’t remember (or find any notes) on how I got it work in the past.
I’m including the SparkFun_AK9750_Arduino_Library.h library and getting the error:
This resolved the No such file or directory error for WProgram.h but then I got the same error for Wire.h, which I then commented out since I’ve read that it’s included elsewhere.
Now I’m getting a whole slew of errors such as:
It’s killing me because I know I’ve gotten this to work in the past!
WIth some fairly new Device OS version you should be able to also add #include "Arduino.h" which will set the ARDUINO version value in a way that the TwoWire (aka Wire or I2C) functions should be compatible.
WProgram.h is even outdated on the Arduino side and was replaced with Arduino.h (years ago) - hence this standard block in many Arduino libraries
#if (ARDUINO >= 100)
#include "Arduino.h" // <-- new versions
#else
#include "WProgram.h" // <-- ancient versions
#endif
For your errors, setClock() is called setSpeed() nowadays.
And this block is syntactically wrong in the library
if bitRead(currentSettings,0) return 5;
if bitRead(currentSettings,1) return 1;
if bitRead(currentSettings,2) return 2;
if bitRead(currentSettings,3) return 3;
if bitRead(currentSettings,4) return 4;
if statements compulsory require the condition to be wrapped in parenthesis hence it should rather be
if ( bitRead(currentSettings,0) ) return 5;
if ( bitRead(currentSettings,1) ) return 1;
if ( bitRead(currentSettings,2) ) return 2;
if ( bitRead(currentSettings,3) ) return 3;
if ( bitRead(currentSettings,4) ) return 4;
Maybe the Arduino compiler is less picky, but that would mean not obeying the C/C++ syntax, which should be considered bad practice.
So for the latter errors, the error message: “expected '(' before 'bitRead'”, was perfectly clear about what’s wrong and how to solve it IMO.
Thanks @ScruffR. Yes, the last error was pretty obvious - I was fixated on the former error.
I was able to get it to compile by making these changes, but first I had to add some #defines to the library .h file because I was getting errors stating that bitRead was not defined. I got the answer for that error from the following post:
Adding those defines allowed the code to compile. Now I just have to see if it works.
You really need the custom plastic lenses to go over the sensor for decent performance from this chip from my testing. Problem is that the company that makes the chip does not have any of their new lenses for this sensor and can’t tell me when they will be available or how much the they will cost in low quantities.
I ended up using the Panasonic Eye Grid sensor that does not need a lenses and provides a 8x8 grid of readings vs the 4 points of this sensor.