xively/xively_arduino

Possible compatibility issue with Wire library

errordeveloper opened this issue · 6 comments

_Originally reported as cosm/cosm-arduino#9 by @mcdonaldajr._

I have downloaded the MultipleDatastreamsUpload.ino example.
I change the mac address, the cosmKey, streamId and run it. It works beautifully.
I added this after all other headers:

#include <Wire.h>

Now it doesn't work. I get error code -400 a few times, then -411.

I have a standard Arduino Uno with standard Ethernet Shield, so this should be easily reproducible. I have re-downloaded stuff to ensure I'm running the latest versions of everything, including the libraries.

If I comment out the line:

// datastreams[2].setString(stringValue);

it starts working again. COSM returns 200 OK.
I'm no expert, and can't debug the COSM or the Wire library, but I suspect we have a problem with something incorrectly addressing memory somewhere.

Help gratefully received, as I (and I suspect many others) need the Wire library to access my sensors.

Thanks, Anthony

Any progress on this? I retested using the latest xively library and the problem is still there.

Thanks, Anthony

@mcdonaldajr can you provide a simple test to verify whether this is actually an issue with Xively library and Wire or it's simply an issue with Wire+Ethernet? What I want to see is an example code where everything works with Ethernet and Wire libraries in use with a TCP socket connection and sensors etc.

Once I add #include <Wire.h> into the example MultipleDatastreamsUpload.ino, I then get a return error of 400 just as the gentleman before stated:

#include <SPI.h>
#include <Ethernet.h>
#include <HttpClient.h>
#include <Xively.h>

//Existing add 1
#include <Wire.h> //add from OLED - Hello World ***This is the include that produced the 400 error
//Existing end 1

Otherwise I get a 200 and all is gravy.

@GodPaidItForward Ok, so when you add the Wire library to the sketch it errors with 400 right?
Currently you are using Ethernet, SPI and I2C in your sketch; So you could have pins which are used by those protocols that are conflicting with each other. Ethernet shield needs SPI (MOSI)11, (MISO)12, (SCK)13, (SS)10 on a Uno to talk to the Arduino chip. The wire library which is used to control two wire devices I2C needs these two pins A4 SDA, A5 SCL (Uno) and the other end of these connections need to be attached to you OLED device's I2C pins. Check your data-sheet for details. So Are there another devices/connections which are using those pins mentioned above? As this could be the cause of your error. As you are getting 200 when the wire library is NOT a comment i.e. has // in front of it; that's shows to me that problem could be with the wire library and the other libraries. Please check hard-wired connections and post back.

I am closing this as it's not related to library code, please refer to StackOverflow or Arduino Forums.

I'm afraid I cannot speak intelligently as to which pin connects where. The configuration that I have is:

Arduino Uno Rev 3 - running the Ardunio 1.0.5 IDE
Seeed/Grove shield - lays in directly on top of the Uno (allows me to connect all sensors by way of 4 pin connectors
Seeed/Grove Ethernet shield - lays in directly on top of Seeed/Grove Shield

I have a picture of it here:
http://www.godpaiditforward.net/s/cc_images/cache_933868169.jpg

To answer your questions here:
Ok, so when you add the Wire library to the sketch it errors with 400 right? Correct. I upload the example as is and it updates the page I have on Xively of course returning a 200 code. The moment I add in the wire.h library and upload it to the Uno, I start getting the 400 error. Adding in any other libraries, that I will need, work just fine and I continue to get the 200.

So Are there another devices/connections which are using those pins mentioned above? I have only utilized plugs, so there wouldn't be the opportunity for me to hotwire in an incorrect manner as far as I see it. Again, I am a relative newb to all this, basically know enough to be able to work out "some" code, come up with patterns and move forward. With this, the evidence is pretty clear that the two libraries step on one another in some fashion - which is to say, it's likely they call for the same hardware reference - wire.h evidently doesn't play nicely with Xively.h, because it no longer allows Xively to do it's thing.

As you are getting 200 when the wire library is NOT a comment i.e. has // in front of it; that's shows to me that problem could be with the wire library and the other libraries. Please check hard-wired connections and post back.
-when I comment out the wire.h library "// #include <Wire.h>", I get a 200. It is entirely possible that Wire.h may be causing conflict with the SPI, Ethernet or HttpClient libraries. Wire.h however is clearly the culprit.