BGS5T I2C communication and temperature sensors | Thales IoT Developer Community
November 11, 2014 - 9:40am, 8467 views
Hello,
first I would like to ask if anyone tryed to use temperature sensor (IT TMP100, TC74, ...) that uses I2C communication? Does anyone have any recomendation which sensor to use and instructions or code example?
Second thing, is there any tutorial or code example for I2C communication with other devices in Java?
Regards
Jure
Hi,
I think this example a direction (not temperture but analaog).
https://iot-developer.thalesgroup.com/tutorial/conceptboard-java-multiadc
I am not sure if that is really what I need. But thank you for your help.
I have found TC65i example but I can't find class for i2cConnection:
But the problem is because there are I2CDAT and I2CCLK. For my sensor I need both, DAT and CCLK. From example I can see how to transmit some data, but how do you change state on DAT and CLK from high to low or the other way?
Here is the protocol of communication:
1. a high-to-low transition of SDA while SCLK is high
How do I set I2CDAT to high?
2. the host must transmit the address byte to the TC74
I can do this step with the example from TC65i
3.Acknowledge (ACK) provides a positive handshake between the host and the TC74. The host releases SDA after transmitting 8 bits. The host then generates a ninth clock cycle to allow the TC74 to pull the SDA line low.
4.After a successful ACK of the address byte, the host must transmit the data byte to be written, or clock-in the data to be read. ACK will be generated upon a successful write of a data byte into the TC74.
5.Communications must be terminated by a STOP condition (a low-to-high transition of SDA while SCLK is high).
Hello Jure,
You don't change the lines states manually. The i2c protocol is implemented inside. You can only send and receive data.
TC65i module has i2c interface while the TC74 sensor claims to have SMBus/I2C - SMBus is not exactly the same as i2c and the may not be compatible.
Regards,
Bartłomiej
Hello Bartłomiej,
thank you for your response. I allready ordered the sensor, so I hope that I can get it to work. Can you maybe recomend any other sensor, that was allready used with BGS5T, if I will have problem with this?
Regards
Jure
I connected sensor to module and I don't get any response from module. I also found out that if I don't specify data length midlet hangs without error at outstream.write();
Here is working code from PIC microconroller: http://embedded-lab.com/blog/?p=3146
I2C1_Start(); // Issue start signal
I2C1_Wr(TC74A0); // Address + Write bit /TC74A0 = 0x90
I2C1_Wr(0x00); //
Read Temp I2C1_Repeated_Start(); // Issue start signal
I2C1_Wr(TC74A0+1); // Address + Read bit
Here is my code:
In TC65 example data is shaped like this:
// Write Transfer Frame, where a = message ID, AE = Slave Address and write
Hello Jure,
first of all I would check the HW and measure the I2C lines with an oscilloscope.
The BGS5T *****: Vin = 1,3 - 1,85V and Vout has to be set by VCCref
Check that AT^SCFG is configured correctly.
Whe the HW is verified I would dig deeper on SW level.
Regards
Markus
....
I started out with nothing... I still have most of it.
Hello Jure,
Each message you send must contain the start character "<" and stop character ">".
The second element of each message is the Message ID (1 character). The Message ID serves the user to distinguish
between different messages. It is not sent to the I²C slave device.
So the format of write transfer message should be: < ID SlaveAddress Data >
Maximum length: 2048 bytes for I²C Slave Address and written data.
I can see in your code that you send "0x" - you should remove it. For example send "90" instead of "0x90".
I think you should read about structure of messages on the I²C bus in the AT commands specification. There's also an example.
You may find there a little bit more than in Java API description.
Maybe it would be better to test the communication with the AT commands interface first to separate i2c communications problems from Java problems. And when it will work then you can try with Java.
Unfortunately I cannot recommend you any particular sensor.
Best regards,
Bartłomiej
Protocol is like this:
1.Start condition
3.Recive ACK
4.Send which register you want to read
5.Recive ACK
7.Send adress + read bit
8.Recive ACK
9.Revice temperature data
My at commands:
at^sspi=0000,0000,0000
response:connect
1+
Could be this because I don't send Start condition (a high-to-low transition of
SDA while SCLK is high)? I couldn't find any option for that in the documentation. I tryed to simulate this with stoping connection with '#' and starting it again, but it didn't work.
Regards
Jure
I also disscoverd that if I enter <080>,<070>... while third byte is zero anything goes trough and I get {0+}.
Hi Jure,
I don't know the communication protocol with your device but I think that you might have missed one thing - each hex value you send in the i2c frame must consist of 2 characters. So if for example your address is 0x09 and some write request is 0x00, some register 0x33, data you write 0x77 then your frame could look like this: <a09003377>.
You don't drive the lines manually, when you send "<" character the transmission start should be signalled on the interface. If your device meets the i2c standard the signalling should be working. You can only set the data transfer rate while establishing the connection.
Regards,
Bartłomiej
Pages