More specifically, when I tried using the simple I2C scanner sketch below to see if the SHT30 would even show up on the I2C bus, the Moteino hangs at the indicated line. If I disconnect the SHT-30, the sketch runs correctly and reports no devices.
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
while (!Serial); // Leonardo: wait for serial monitor
Serial.println("\nI2C Scanner");
}
void loop() {
int nDevices = 0;
Serial.println("Scanning...");
for (byte address = 1; address < 127; ++address) {
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
byte error = Wire.endTransmission(); // With SHT-30 connected, sketch hangs here on the very first iteration of the loop
if (error == 0) {
Serial.print("I2C device found at address 0x");
if (address < 16) {
Serial.print("0");
}
Serial.print(address, HEX);
Serial.println(" !");
++nDevices;
} else if (error == 4) {
Serial.print("Unknown error at address 0x");
if (address < 16) {
Serial.print("0");
}
Serial.println(address, HEX);
}
}
if (nDevices == 0) {
Serial.println("No I2C devices found\n");
} else {
Serial.println("done\n");
}
delay(5000); // Wait 5 seconds for next scan
}
I know the SHT30 works in general, because I connected it to my Raspberry Pi Zero's I2C interface, and it worked fine.
Does anyone have any ideas on what might be preventing the I2C bus/SHT-30 from working correctly on the Moteino 8MHz? If I could even figure out how to make that simple scanning sketch above work, I'm sure I could take it from there. Thanks in advance!
P.S. I'm cross-posting this on the Moteino and Adafruit forums since I realize this isn't really an Arduino-specific problem. I just thought I'd try here too in case somebody here has encountered a similar problem.
It might be because the Moteino doesn't have pullup resistors on the SCL and SDA lines. It seems that values around 4K7 (for 5V systems) and 2K7 (for 3V3 systems) are about right but I'm no expert on this.
This particular package of the SHT-30-D comes with 10KΩ pullups from both SCA and SDL to VCC on its PCB, and the Moteino's logic is 3.3V. Could it be that 10KΩ is too big?
10k pullup is okay, 8MHz or 16MHz is no problem.
The Wire.endTransmission() hangs if SDA or SCL is shortcut to GND or SDA is shortcut to SCL or the I2C module is not powered.
Do you have a multimeter and a magnifier ? Use the magnifier to check the print for solder blobs and shortcuts.
Then measure the voltages, SDA, SCL and 3.3V (SDA and SCL should be near 3.3V).
Then measure the shortcut current from SDA to GND and from SCL to GND (about 0.3 to 3mA is okay).
For anyone who encounters this problem in the future, here's the answer:
It turns out the 10KΩ pull-up resistors that came with this package weren't sufficient. I had to add additional 1KΩ pullups from both SCA and SDL to VCC to get things to work.
(FWIW I also tried 4.7KΩ pull up resistors, and that made some commands to the SHT 31 work, but not all.)
I agree that something weird is going on, and I'm not sure what to make of it. I did the experiment you described in post #4 of this thread without adding any pull-up resistors of my own (i.e. just direct connections between the Moteino board and the SHT 30-D package, with only my breadboard in between to make the connections), and the results were:
SDA to ground and SCL to ground were both 2.3V. VCC to ground was 3.294V
The shortcut current between from SDA to ground and SCL to ground were both 0.14mA.
I'm not sure what to make of it. All I know is that in desperation I kept trying smaller pull-up resistors of my own. When I tried 2.2KΩ pull-ups from SDA/SCL to VCC it didn't work. When I came down to 1KΩ, things suddenly worked like magic.
The SDA and SCL should be near the 3.294V, for example 3.293V.
Suppose you have 10k pullup to 3.294V, then the current should be 0.33mA.
Is there is a GND or VCC not well connected ? Something soldered upside down ? I have no clue, but I think you have to find the cause. The sensor could be broken.