I’m new to Spark Core, just started it using last week. Ok to the question, I’m trying to use the i2c pins of the Spark core. I did the set up with Arduino and it was perfect. I’ve been trying to replicate it in the Spark core but I failed, here’s the link to the exact set up I did in Arduino.
I have several HIH6130 breakout boards from Sparkfun that work fine with an Arduino Uno and 3.3v RFduino. I’ve blown a few days trying to get them to work with Spark Core and I’m not having any luck.
I see that there’s a HIH61xx library already contributed to the Web IDE and if I try the demo project there I just get Wire.endTransmission returning 4, the same as my own library.
As suggested above I’ve put 4.7k pull-ups from the 3.3v pin to D0 and D1. I’ve tried all sorts of variations and I just cannot get it to work. What else could I be missing? My understanding is that updating via Web IDE ensures the latest firmware, no need to do any other restore or updates?
Sorry if I’m asking stupid questions, but how do you power the Core and the module?
The example does power the module via the D3 pin.
If you’re powering the module via 5V Vin pin, it might be that the Core’s I2C HIGH signal of 3.3V is not interpreted correctly by the sensor.
This might be completely wrong, but at the moment I’ve no better idea.
But I know a guy who seems to have waaaay more insight into I2C than me - @pra, what are we missing?
@ScruffR and @chasc, the Sparkfun boards DO have 2.2K pull-ups so no others are necessary. However, using several sensors will create an issue since they all have the same address and, as the author of the IDE library points out in his readme file:
If you have multiple devices connected to the I2C bus, remember that this device screws up the bus when it is not powered. One solution is to keep the device powered all the time. Another possible solution is to add an analog switch to physically disconnect the GND line or the SDA line to the device.
So I would suggest you use a single sensor to start with. Also, you may also want to test with Sparkfun’s Arduino code which will need very minor modifications to run on the Spark (let me know if you need help with that). If a single sensor and the code work for you, you can go from there.
@peekay123, I never understood that @chasc is actually using more than one sensor. I just understood he’s got several in his pocket and only uses one a time.
Sure, that would have been a clever question to ask first too
All helpful suggestions but again unfortunately it doesn’t help. I do have multiple devices but I’m not currently trying to use more than one. I have tried powering it via the D3 pin (as per the demo sketch) and continuously from the 3.3v pin. I’ve customized the I2C addresses but have verified with an RFduino that I’m using the correct address. That Sparkfun codebase is what my own library is based off of and it doesn’t work either.
Is there any utility in refreshing the device via DFU or is that futile for this type of issue?
I don’t have a logic analyzer but I do have a multimeter. Is there anything else I can do to troubleshoot?
Let me add one last little bit of info: I had trouble with the HIH3160 in the past on RFduino’s I2C library too. The reason was that HIH3160 is triggered to initiate measurement by an empty transmission, but the I2C library was simply skipping further logic if the output buffer was empty at the time endTransmission() is called. I fixed it there by sending one random byte, which got around the issue.
I didn’t originally suspect I2C library issues because someone else had posted an HIH61xx library, making me suspect it was working fine. However, I’m out of other explanations so I thought I’d put it out there. Perhaps the slightly unusual I2C protocol of the HIH6130 is conflicting with the I2C library here?
According to the data sheet, the device has a VCC from 2.3V - 5.5V so I recommend power from the Spark’s 3.3V pin, or any Spark pin set to OUTPUT, HIGH , but not VIN. I2C pins are supposed to be connected Open Drain (i,e, pulled to VCC via resistors and the master and/or device pulls them to GND as required. No master or device pin should drive any voltage onto these lines).
as @ScruffR has pointed out, a 4 returned by Wire.endTransmission() is a Timeout, meaning either the SDA and SCL lines are not connected to the device properly, no VCC (trying connecting to Spark 3.3V pin rather than GPIO pin for now) or the address being send is incorrect (make sure you are using address 0x27). These are pretty much the only reason you will get this timeout, so it has to be one of these.
Yes, I tried my own library with and without that fix. I looked at GeertWille’s one for Spark Core and it doesn’t have it. I just opened an issue on his repo yesterday so perhaps he will have some additional info.