I2c non functional with any sensors after reset

Hello,

I have a spark core that is hooked up via i2c to an MCP9808 temp sensor and a HTU21D-F humidity and temp sensor. My code has been running stable for a few months now, and I haven’t made any recent changes. Yesterday, my core was showing values that were way off (-150s for temp, 999 for humidity), so I decided to reset the core via the button. Since then, the core cannot see either the temp sensor or the humidity sensor. I’ve tried changing the wires out, moving both the spark and the sensors to different parts of the board trying only one sensor at a time, changing the USB ports/checking with a multimeter that the power from USB was within spec (was fine), trying different power pins on the spark, and doing a hard reset, but nothing worked. I hooked up each sensor to an Arduino Leo that I have, and was able to get them working instantly, but when putting them back on the spark, nothing works.

@ccarducci I have to get some stupid questions out of the way.

  1. Do you have pull up resistors on the I2C lines?
  2. Did you recompile and reflash your code on the Core?
  3. How are you powering the sensors?

:smile:

1 Like

Sure, no problem. I’ll answer the best I can.

Do you have pull up resistors on the I2C lines?
The MCP9808 is on a breakout board which has a 10k pullup built in. I have not used a pullup with the HTU21D-F, but my issue is primarily with the MCP9808, as that chip is initialized first, and that’s the one I’ve tested on multiple microcontrollers.Both chips and breakout boards were purchased from adafruit, and both have run fine for a couple of months without issue.

Did you recompile and reflash your code on the Core?
Yes, I tried this a few times, both before and after I did a full factory reset of the spark core. I also Checked the code and tried removing anything unnecessary, and verified it against known working examples.

How are you powering the sensors?
I am powering the sensors via the 3.3v pin on the spark core. I verified that the voltage output is within reason; it showed up at about 3.299v. Both chips are also capable of running off of 3.3v or 5v, and I have have also tried using the VIN pin to power them, which is connected directly to my PC and is outputing voltages within reason.

Let me know if htere is anything else I can try.

Edit: both sensors are hooked up to D0 and D1 to use I2C. Aren’t there pullups already active on the i2c pins?

Honestly it just sounds like a wiring issue to me… or maybe a cold solder joint on the Spark Core. If it was working fine… and not now after just sitting there… that’s pretty strange. Could also be some serious ESD that killed something.

When you factory reset it, does Tinker work from the smart phone app? Can you toggle D0 as a digital output and read it with D1 and a digital input (assuming you connect them together… and vice versa? I’d suggest with a 1k ohm resistor for safety between the two pins).

3 Likes

@ccarducci, I agree with @BDub that some event most likely occurred to cause the problem like a power spike or an ESD or something! I would power off Vin with the pull-up going to either Vin or 3.3v for the I2C lines. Testing D0 and D1 as pure I/O lines is a good idea to see if anything is amiss there. :smile:

2 Likes

Very strange behavior. When testing w/ tinker for i/o on each pin, both pins function as digitalwrite and digital read just fine. When wiring up a pull-up to vin, D1 registers as high on tinker, but d0 will only register as low, regardless of wire, resistor, etc. I feel like I’m missing something painfully easy…

I’ve tried re-flashing the firmware via DFU mode, re-wiring everything with pull-ups, resoldering the joints on D0 and D1, resoldering the joints on the MCP9808, and I’ve tried using both the temperature and humidity sensors separately…The pins D0 and D1 are still working for input/output, but I still cannot get i2c to work with either. Do you think it sounds like something on the core is broken?

@ccarducci, let’s try something more basic. Disconnect and remove your I2C devices and put Tinker back on your core. Next, connect your pull-ups (what value are you using?) to the 3.3V line. Use Tinker to set (to digitalRead) and read both D0 and D1 - they should read HIGH. Next and using a separate wire to GND, ground the D0 and D1 pins one at a time, leaving the pull-up resistors in place. Read each pin using Tinker and you should see the grounded pin go LOW then HIGH as you remove the GND jumper. If you don’t see this behavior (HIGH, LOW, HIGH) as you ground the pins then that indicates a problem with the pin or pins. Let me know what your results are. :smile:

2 Likes

Thanks @peekay123. I had tried as you asked, but just tried again with a few different value resistors for good measure. I tried a 10k, a 4.7k, and a 1k on each pin. pin D1 operates as expected with the pullup registering as HIGH, and then LOW when I ground the pin. The D0 pin, however, only registers as LOW regardless of what it’s connected to, unless it’s connected directly to 3.3v, which is when it registers as HIGH.

I also whipped out the trusty multimeter and took voltages at the pin. With the pull up, D0 reads as 120ish mv. Without, it only reads as 3.288v. D1, on the other hand, reads around 3.288mv with the pull up, and at a perfect 3.3v without.

I did attempt to resolder the joint for D0 with no change. I can try again, but the joint visually looks ok. Do you think I’ve blown or half-blown the pin?

@ccarducci, it sounds like the pin electronics are damaged :frowning:

I was afraid you’d say that. Bummer.