MCP23008 2 channel relay controller and Grove I2C sensor

I want to attach the Grove Digital_Light_TSL2561 sensor to the MCP23008 Relay Shield for Particle Photon. The library for it doesn't exist in the Particle Web IDE. I created the .cpp and .h file for the library and copy and pasted the contents into it but they include arduino.h and wire.h files.  How can I get this to work with this shield or other I²C sensors as well that have their own libraries that don't exist in the Particle IDE?




Just remove the include lines for Wire.h and Arduino.h  Most library syntax for Wire is the same between Arduino and Particle.  You can read more about the Wire library on Particle's doc site here;

You do not need to add any include lines on the Particle app for Wire unless it is an external .h and .cpp file.  If that is the case then add:

#include 'spark_wiring_i2c.h'

If you have any other questions please let us know.  Also if you have more questions please post the code you are using so we can take a look.

Thank you,

Travis Elliott


Thanks Travis. That fixed the Wire.h and related errors issue (although I had to change the ' ' to <> around the file name.  I'm still getting some basic type errors. For example:


Digital_Light_TSL2561.h:110:3: error: 'uint8_t' does not name a type.

The same for uint16_t. 

There are a bunch of errors that seem to be related to those.  Then there is an additional error

Digital_Light_TSL2561.cpp:78:12: error: 'delay' was not declared in this scope

which could be related because I believe it's being called in a function that isn't getting compiled due to the data types.

Any ideas for those?





It appears I need to include in place of arduino.h:


#include <application.h>



Hi Bryan,

Yes, if you include application.h it will include everything the application has, you can use that and remove the spark_wiring_i2c.h include.  What it is pulling in that corrected that issue is spark_wiring_constants.h


Thanks! That works.


No Problem.  Let us know if you run into anything else!