I2C configuration | Telit Cinterion IoT Developer Community
February 18, 2017 - 11:36pm, 3904 views
I've been having problems communicating with an I2C sensor
for some time.
I think I've got the EHS6 configured correctly, but would appreciate
advice from the pros.
I'm using an HDC1000 sensor. It has a fixed (slave) address @ 0x40.
Using "AT" commands, I do the following:
+PBREADY
ati1
Cinterion
EHS6
REVISION 03.001
A-REVISION 00.000.49
OK
at^scfg?
^SCFG: "Audio/Loop","0"
^SCFG: "Call/ECC","0"
^SCFG: "Call/Speech/Codec","0"
^SCFG: "GPRS/AutoAttach","enabled"
^SCFG: "Gpio/mode/ASC1","rsv"
^SCFG: "Gpio/mode/DAI","gpio"
^SCFG: "Gpio/mode/DCD0","gpio"
^SCFG: "Gpio/mode/DSR0","rsv"
^SCFG: "Gpio/mode/DTR0","gpio"
^SCFG: "Gpio/mode/FSR","gpio"
^SCFG: "Gpio/mode/HSIC","rsv"
^SCFG: "Gpio/mode/PULSE","gpio"
^SCFG: "Gpio/mode/PWM","gpio"
^SCFG: "Gpio/mode/RING0","gpio"
^SCFG: "Gpio/mode/SPI","std"
^SCFG: "Gpio/mode/SYNC","gpio"
^SCFG: "Ident/Manufacturer","Cinterion"
^SCFG: "Ident/Product","EHS6"
^SCFG: "MEShutdown/Fso","0"
^SCFG: "MEShutdown/sVsup/threshold","0","0"
^SCFG: "MEopMode/CFUN","0","1"
^SCFG: "MEopMode/Comp1",""
^SCFG: "MEopMode/ExpectDTR","current"
^SCFG: "MEopMode/ExpectDTR","powerup"
^SCFG: "MEopMode/SoR","off"
^SCFG: "Radio/Band","511"
^SCFG: "Radio/Mtpl","0"
^SCFG: "Radio/OutputPowerReduction","4"
^SCFG: "Serial/Interface/Allocation","0","0"
^SCFG: "Serial/USB/DDD","0","0","0409","1E2D","0058","Cinterion Wireless Modules","EHx",""
^SCFG: "Tcp/IRT","3"
^SCFG: "Tcp/MR","10"
^SCFG: "Tcp/OT","6000"
^SCFG: "Tcp/WithURCs","on"
^SCFG: "Trace/Syslog/OTAP","0"
^SCFG: "URC/Ringline","local"
^SCFG: "URC/Ringline/ActiveTime","2"
^SCFG: "Userware/Autostart","1"
^SCFG: "Userware/Autostart/Delay","0"
^SCFG: "Userware/DebugInterface","0.0.0.0","0.0.0.0","0"
^SCFG: "Userware/DebugMode","on"
^SCFG: "Userware/Passwd",
^SCFG: "Userware/Stdout","usb4",,,,"off"
^SCFG: "Userware/Watchdog","1"
OK
AT^SSPI=0010,0000,0000
CONNECT
--I entered--
<M40>{return}
------------
EHS6:
{M+}
---I entered---
<M4000>
--------------
EHS6 return:
{M-0001}
It's odd because if I don't have a device connected to the
I2C interface, I get the same response.
In an odd coincidence, if I use the Java libraries for I2C
(with no I2C devices connected) I can issue the commands
"I2cBusConnection conn = (I2CBusConnection) Connector.open("i2c:0")"
(and get a "CONNECTED" response), then
"conn.OpenOutputStream().write("<M40>".getBytes());"
command, and a subsequent "read" to the inputstream delivers some
data.
I've connected a logic analyzer to the I2CCLK/I2CDAT lines, and at all
times I've gotten no transitions in line state<s>.
Some questions are:
Should a "Connector.open("i2c:0")" command say "CONNECT"
if there are no I2C devices connected (does this indicate a connection
to the bus and not to any particular slave)?
If you send a "write" command to I2C and an address for a
device that isn't connected to the I2C bus, should you get "data"
back from a DataInputStream.read(byte[] b) call?
Does the output of the ^SCFG? command look like I've configured
the EHS6 correctly for I2C comms?
(I'm pretty certan I've gotten the GPIO/config stuff messed up)
Thanks for any help/suggestions!
-U4-
Hello,
When you open the i2c you in fact open the interface not the particular connection so that's OK that you get CONNECT even when there's no device connected. Then when you send <M40> you just send the address and get positive reply form the i2c driver. Then the negative reply for <M4000> seems also OK while there was no reply from the slave device. Have you connected the sensor with respect to the manufacturer documentation and module's hardware documentation and you send valid i2c commands and get wrong replies? Are there still no activity on the lines? Can you paste the logs? Are you using your propriety hardware or any developer board or terminal?
Regards,
Bartłomiej
Thanks for the reply.
I have a DSB75 mounted to a DSB-Mini for testing/development.
I'll attach the logs, and three PNG files showing the sensor
I am using (HDC1000) driven by the EHS6 and by an Arduino.
I'm not sure why the addresses of the LA traces are different: the code
is dead simple (and I know I'm sending 0x40 for an address).
try {
conn = (I2cBusConnection) Connector.open("i2c:0");
DataInputStream ips = conn.openDataInputStream();
DataOutputStream ops = conn.openDataOutputStream();
System.out.println("I2C streams established");
byte[] b = new byte[128];
int ***** = 1;
while (***** < 10) {
ops.write("<D40>".getBytes());
Thread.sleep(200);
int c = ips.read(b);
for (int x=0; x < c; x++) {
System.out.println("byte #" + Integer.toString(x) + ": " + b[x]);
b[x] = 0x00;
}
Thread.sleep(200);
***** = ***** + 1;
System.out.println("Completed " + Integer.toString(*****) + " iterations");
}
ips.close();
ops.close();
conn.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I find it particularly strange that I'm reading from the
inputstream out of the EHS6 (and getting data) but don't
see any data on the wire (the Uno data is clear).
There's one error in the log (about a ******* devaddresses.xml
file). Not sure if it's related (kinda doubt it) but my
file here is 0-bytes long.
Also, could you check something for me: I was killing myself trying
to get this working by soldering some leads onto pins #11 and #70
of the 80 pin header on the DSB-mini. They're screened as "I2C CLK"
and "I2C DAT", but I could never get a signal out of 'em (both lines
would simply float high). I've since moved over to the 14 pin header
on the DSB75. Do you know if #11 and #70 are in fact I2C?
Thanks again!
Hello,
Could you please paste a photo of your hardware setup? It should then be easier to analyze it. Maybe there's something more you have to configure on the hardware if you can't even detect the clock.
And what's on the screenshots - is it the communication when you use Arduino? The screenshots look correct.
I have looked at the documentation of your sensor and it looks that you are using the wrong slave address. If the 7-bit address is 0b1000000 you should add the 8th LSB bit as read/write indicator. So after that it would be like:
0b10000000 = 0x80 - write
0b10000001 = 0x81 - read
And you try to send 0x40.
Regards,
Bartłomiej
Sorry for the fuzzy photo (my cell camera has never
worked well). Brown/Red are DAT/CLK, and Green/
Yellow are 3V/GND.
The HDC1000 datasheet uses 7-bit address. The
Arduino Wire library must shift left the 7-bit
address to accomodate the R/W bit (I believe the
Wire.read()/Wire.write() methods supply the
correct bit).
I've gotten a little confused. Some documentation
suggests the SLC/SDA lines have built-in pull-up
resistors, but other documents suggest the develop-
er must cut those in. Can you tell me which is correct?
The top two screen shots are the read/write with the
Arduino. The bottom shot (above) is the write/nack w/EHS6.
Thanks!
Hello,
Thank you for the picture. Maybe it is not the best quality but it gives the idea what HW you are using and what you connect where.
So the Arduino sends 0x80 which is correct and on the last digram there is 0x40 which is not correct.
According to the documentation for the adapter that you have the i2c lines are not connected to the long X135 connector which connects to DSB Mini. So you have to use the X171 14-pin connector where these lines are marked. As far as I know you should be using the pull-up resistors.
Regards,
Bartłomiej
Thanks!
I tried it with pull-up (2.7KOhm) resistors to 3V and that didn't
help.
I think the problem is incompatibility: The EHS6 I2C is running
at 1.8V as is the I2C master (the documentation is sometimes
unclear/contradictory as to whether or not the SDA/SLC lines
actually have pull-ups on the EHS6 or not). But the HDC1000
operating parameters say "VDD 3.0~5.0V" and I think I'm
getting jibberish because of the undervoltage.
(don't me wrong, I'm no hardware person - I'm a software
guy)
If you, too, think this might be the problem, any thoughts
how I could pull SLC/SDA up to 3V?
Thanks SO much for your help.
BTW: Still not getting any I2C waveforms from the
80 pin header @ 11&70. :(
Hello,
As I have written in my previous post you will not find i2c on the 80 pin header @ 11&70 - it is not connected there. You can only find it on the short connector near the USB socket.
Additionally I have found on the adapter schematic that there is an i2c EEPROM memory which you could connect for testing i2c (without your sensor) by inserting the jumpers on I2CDAT - I2CDAT_A and I2CCLK - I2CCLK_A pairs.
As for your sensor I have also consulted with my colleague who is more hardware oriented and he has confirmed that this will probably not work without additional bidirectional level shifters as there are no level shifters in the adapter board and there are connected the i2c lines directly from the module (1.8V).
Here are some links that might be helpful:
http://www.nxp.com/documents/application_note/AN10441.pdf
http://www.intersil.com/content/dam/Intersil/documents/an16/an1637.pdf
Regards,
Bartłomiej
Thank you.
Could you tell me the part # for the EEPROM? (I'll need the address
and registers to poke at it).
Thanks again.
Hello,
I have found the following on the schematic:
I'm sorry but it seems that I have mislead you - I have verified that this EEPROM is not present on my adapter and yours also (there's only a place for it in the top right corner between the two connectors - under the grey antenna cables on your picture) - it seems that it's only optional. I'm sorry again for this.
Regards,
Bartłomiej