Pages: [1]   Go Down
Author Topic: Some question about i2c, smb, wire.h and twi ... all together.  (Read 763 times)
0 Members and 1 Guest are viewing this topic.
Rouen, France
Offline Offline
Newbie
*
Karma: 0
Posts: 44
Arduino beggiiiiinnneeerrr !
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

   Hello dear community,


I hope I looked enough in the forum history and internet in order to make an "interresting" post. If it's not the case, could you please point me to the right direction, google-keywords, forum-post, etc.

My question is : what is the difference between those ways to interface with sensors, why use different ones, how to do that ?!

I have found an interresting project for which I bought the parts/sensors and whilst waiting for them I tried to read and understand the code.
http://www.cheap-thermocam.tk/   (also available at : http://cheap-thermocam.bplaced.net/)
It involves the sensor MLX90614 (in particular: the version MLX90614ESF-DCI, 3volts power supply, medical accuracy on body temperature range, very small focus (FOV) of 5degrees).

Looking at the files, the configuration uses i2cmaster.h and has many i2c_write, i2c_start_wait, i2s_stop, etc.
However the sketch uses compat/twi.h and has many TWDR, TWDC, TW_MT_SLA_NACK, etc.

My understanding so far :
the sensor is SMB capable.
SMB is part of i2c
i2c is included in wire.h but here, the developper used i2cmaster.h ... in the configuration phase
then for the usage phase, the developper used twi.h


So I think I'm a bit lost and I don't have enough programation/electronic background to understand. If you have a few minutes, your wisdom would be very welcome !!


« Last Edit: January 08, 2013, 03:14:16 am by Chrisprols » Logged

Smithfield, Rhode Island
Offline Offline
God Member
*****
Karma: 2
Posts: 843
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I confess, I am not sure exactly what you're asking. If you want to learn about interface technologies like I2C/TWI, SPI and so on, have a look here:

http://www.gammon.com.au/forum/?id=10896

That's maintained by Nick Gammon (a participant here) an is a fantastic resource.

Logged

Rouen, France
Offline Offline
Newbie
*
Karma: 0
Posts: 44
Arduino beggiiiiinnneeerrr !
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi skyjumper !
thanks for your repply. The link is good and I bookmarked it !

As you said I'm not very clear ... actually because I'm not clear myself. Not having enough electronic/coding background, I cannot (yet) sort out all the words I see : i2c, wire.h, twi, etc.

My question should be :
- what are the libraries available ?
- is there any compatibility to look at ? (on the IDE side and on the board side (uno, due, leonardo, mega, etc.)
- for each library what does it cover ? will my component be compatible with it ?

If you look back at the cheap thermocam project, he uses different libraries : i2cmaster.h and compat/twi.h
... and actually i2cmaster.h might be a modified one
And then, on the component side it is SMB compatible. So where does SMB fit in the i2c language or the twi thingy ?
Logged

Palermo
Offline Offline
Full Member
***
Karma: 0
Posts: 168
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As you said I'm not very clear ... actually because I'm not clear myself. Not having enough electronic/coding background, I cannot (yet) sort out all the words I see : i2c, wire.h, twi, etc.

Wire.h is the library Arduino provides for Two Wire Interface communications, which is generally called i2c.
Read here: http://arduino.cc/en/Reference/Wire

Quote
My question should be :
- what are the libraries available ?
- is there any compatibility to look at ? (on the IDE side and on the board side (uno, due, leonardo, mega, etc.)
- for each library what does it cover ? will my component be compatible with it ?
- ?!?
- Some libraries may not be compatible with a specific Arduino IDE (e.g. the Wire library changed with Arduino ver.1). But the i2c library (which is called Wire.h in Arduino) comes with it anyway. You don't have to manually install it alongside. It comes with the package.
- The i2c protocol is generic enough to deal with any component talking this "language" on the wire. Consider it as a tool to "talk" to other devices on the wire. It's up to the various devices to listen to that data coming in, and acting accordingly. You program the Arduino in order to make it "talk" to them, send them "orders" or "requests for data". i2c provides only an interface for this talking to happen; but it's up to you to make all those devices listen and talk meaningfull "sentences".

I bet everything will be much clearer as soon as you start coding some basic example with a few i2c devices.

Quote
And then, on the component side it is SMB compatible. So where does SMB fit in the i2c language or the twi thingy?
SMB is a subset of i2c. Check wikipedia for some more: http://en.wikipedia.org/wiki/I%C2%B2C

You should really spend some time reading the i2c basics first though. That will save you lots of time (and troubles) in the immediate future :-)
Logged

Rouen, France
Offline Offline
Newbie
*
Karma: 0
Posts: 44
Arduino beggiiiiinnneeerrr !
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot for your answer.
I'm indeed waiting on parts (and available spare time) then I'll spend a bit of time coding/practicing.

I guess I was a bit confused with the cheap-thermocam website because he uses I2Cmaster.h (why not wire.h ?) and also a blog post on bildr.org (http://bildr.org/2011/02/mlx90614-arduino/) where he does the same.
In the first case he uses it to configure (and then twi.h in the main sketch to get temperatures).
In the second case he uses it in his main sketch to get temperature.

As you advise : I'll get to it and if confident enough, I'll try to make a new main program with i2cmaster (as per bildr.org example)
Logged

Pages: [1]   Go Up
Jump to: