0

Mixing Adafruit and Sparkfun I2C products in a single projec
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Mixing Adafruit and Sparkfun I2C products in a single projec

by SkyRyder on Wed Oct 13, 2021 7:34 pm

Hi All,

I'm all hardwared up on a Metro Express-based I2C reliant project that has had to include ONE Sparkfun I2C relay module because such a beast is not available from Adafruit.

I have an I2C active terminator and a couple of I2C thermocouple boards (adafuit) along with the Sparkfun relay. An Adafruit capacitive touch display is also stacked up.

My question has to do with coding this...

When I load up example code for each of the individual modules... all works well...

But where I have tried to (in my considerable ignorance) shuffle the deck so-to-speak, and incorporate the working Sparkfun code with the working Adafruit code... it doesn't really want to work.

Before I pull the rest of my hair out... let's ask the most basic question:

Should it be perfectly reasonable to use all of this gear together? (I2C addresses do NOT conflict)

Next, are there known "gotchas" when mixing adafruit and sparkfun I2C modules?

Finally, if it comes down to code... where is the appropriate place to work on the specific code issues. (for example, Adafruit includes libraries to talk to its products quite often... the sparkfun module does not, and seems to rely on native code alone).

Thanks for your kind insights and encouragement!

SkyRyder
 
Posts: 29
Joined: Fri Mar 06, 2020 6:05 pm

Re: Mixing Adafruit and Sparkfun I2C products in a single pr

by adafruit_support_bill on Thu Oct 14, 2021 5:20 am

As long as all the devices have unique i2c address and run at the same voltage, there should not be any problem putting them on the same bus. If you have a mix of 5v and 3.3v devices, you may need to add some voltage level-shifting to get them to play well together.

adafruit_support_bill
 
Posts: 82102
Joined: Sat Feb 07, 2009 10:11 am

Re: Mixing Adafruit and Sparkfun I2C products in a single pr

by SkyRyder on Thu Oct 14, 2021 1:20 pm

Thanks, Bill.... everything seems happy at 3.3v.

One of the problems is that for some reason, the IDE is reporting it can't find some libraries.

I used the Library manager to grab all libraries that each example/demo required, but when I look into the library directory... the files are scattered about in many sub/sub/sub directories...

The IDE finds some... but not others... I'm assuming it works by the IDE searching through everything below the Libraries directory to satisfy the #include... but not working in all cases.

Also, why are some header files in quotes, and others in < > ???

Thank you!

SkyRyder
 
Posts: 29
Joined: Fri Mar 06, 2020 6:05 pm

Re: Mixing Adafruit and Sparkfun I2C products in a single pr

by adafruit_support_bill on Thu Oct 14, 2021 1:43 pm

What libraries are giving you problems?

Typically, angle brackets <> are used to search for standard system header files. Quotes "" are used to search for application-specific headers.
https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html

adafruit_support_bill
 
Posts: 82102
Joined: Sat Feb 07, 2009 10:11 am

Re: Mixing Adafruit and Sparkfun I2C products in a single pr

by SkyRyder on Thu Oct 14, 2021 3:10 pm

Hi Bill, yes, I kinda figured out the difference between quoted header file references and those in < >. apparently the only difference is that when used in quotes, the compiler also looks in the current directory.

So, I apologize for my ignorance on this... working on it... but this whole header vs library is confusing to me.

I mean, what's the point? If there is a library... well, include the library and code away.

But instead, there is this header thing, that isn't actually a library at all... and there is this unspoken thing where we all pretend that header files are actually libraries.

The odd part is... the header files are user editable... which sounds dangerous. Are users expected to create header files? If so... then why are the header files and actual libraries BOTH provided when installing a library?

Why not just toss this complex header thing... and just have libraries... then code away?

What I am doing is copy and pasting lines from the many example sketches that come with each of the modules that I've strung together with I2C.

I'm actually starting small and doing only TWO modules to start with... the 9601 thermocouple and the touch display.

My sketch starts thus:

#include "Adafruit_MCP9601.h"
#include "GFXcanvasSerialDemo.h"

By the second line, I'm already in trouble. It says "No such file or directory".

Now, if I run the two sketches separately, all is well. When I try to create my own hybrid... it's a no-go.

Now here's the next thing that *really* bothers me... what's this about a "demo" header?

What could that possibly mean? Why not a "regular" header that includes the appropriate library? Why is there a "demo" one... that one has to assume is somehow not normal, and has unstated issues/deficiencies/differences from what a GFXcanvasSerial.h would have. What's this "demo" thing all about?

I just want normal, useable libraries in my project.

Sorry if my frustration is showing through... and your help is so appreciated!

SkyRyder
 
Posts: 29
Joined: Fri Mar 06, 2020 6:05 pm

Re: Mixing Adafruit and Sparkfun I2C products in a single pr

by adafruit_support_bill on Thu Oct 14, 2021 3:23 pm

But instead, there is this header thing, that isn't actually a library at all... and there is this unspoken thing where we all pretend that header files are actually libraries.

In C++, the .h or header' file defines what is in the library. The .CPP file contains the implementation of the library. The compiler only needs to reference the header in order to make sure that your code is calling things properly.

#include "Adafruit_MCP9601.h"
#include "GFXcanvasSerialDemo.h"

By the second line, I'm already in trouble. It says "No such file or directory".

That is correct. GFXcanvasSerialDemo.h is not a library header. It is a header file for one of the code examples that accompany the library. The compiler does not look for library headers in the examples folder.

adafruit_support_bill
 
Posts: 82102
Joined: Sat Feb 07, 2009 10:11 am

Re: Mixing Adafruit and Sparkfun I2C products in a single pr

by SkyRyder on Thu Oct 14, 2021 11:25 pm

OK, so I've managed to plow past all that, got the right libraries in place, and onward!

I was able to get a display shield and thermocouple module running (on I2C).

Then I got ambitious and tried to code in a Relay module, further down the I2C chain.

As there isn't an I2C relay from Adafruit... I got one from Sparkfun, and it uses the Wire library.

Without any hardware changes at all, at any time... the example code works fine to run the relay.

However, when I integrate the example code into my larger project (with the display and thermocouple)... then the relay does not respond.

I notice that the Adafruit module doesn't use Wire (or it does, and it's hidden)... having it's own library.

Is there some likely conflict between the adafruit libraries and code, and the Wire implementation for the sparkfun module?

Thank you for your kind help!

SkyRyder
 
Posts: 29
Joined: Fri Mar 06, 2020 6:05 pm

Re: Mixing Adafruit and Sparkfun I2C products in a single pr

by adafruit_support_bill on Fri Oct 15, 2021 5:09 am

All of the i2c libraries use the Wire library. For most is included internal to the library. There should not be any conflict between the different libraries all using Wire.

adafruit_support_bill
 
Posts: 82102
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.


cron