The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
Netduino 2 and the Adafruit BMP085 Barometer (I2C)
I can confirm the exact same behavior using Adafruit i2c OLED. I have to disconnect / reconnect the SDA pin for it to work properly. I've been fighting this for over an hour now until I ran across this post.
Actually, to work around it, I just do the following as the first part of Main():
OutputPort p = new OutputPort(Pins.GPIO_PIN_SDA, true); p.Write(false); p.Dispose( );
Yes, I'm a noob. Man, I'm glad I got that off my chest.
This is the first time I've attempted to hook up a sensor using I2C and I decided to start with this barometer from Adafruit.com: http://www.adafruit.com/products/391
Anyway (11 hours later), what I thought would be simple turned out to be not so simple. Here is what I am facing.
byte[] Addr = new byte[2]; Addr[0] = 0xF4; Addr[1] = 0x34; byte[] TxBuff = new byte[4]; byte[] RxBuff = new byte[4]; I2CDevice.Configuration I2C_Configuration = new I2CDevice.Configuration(0x77, 400); I2CDevice I2C1 = new I2CDevice(I2C_Configuration); I2CDevice.I2CTransaction[] WriteTran = new I2CDevice.I2CTransaction[] { I2CDevice.CreateWriteTransaction(Addr), I2CDevice.CreateWriteTransaction(TxBuff) }; I2CDevice.I2CTransaction[] ReadTran = new I2CDevice.I2CTransaction[] { I2CDevice.CreateWriteTransaction(Addr), I2CDevice.CreateReadTransaction(RxBuff) }; while (true) { int iWriteCount = I2C1.Execute(WriteTran, 1000); Debug.Print("Write Count: " + iWriteCount.ToString()); Thread.Sleep(200); int iReadCount = I2C1.Execute(ReadTran, 1000); Debug.Print("Read Count: " + iReadCount.ToString()); string ReadOut = new string(System.Text.Encoding.UTF8.GetChars(RxBuff)); Debug.Print("EEPROM CONTENT:" + ReadOut); Thread.Sleep(200); }
This is one version of a routine of a whole bunch that I've tried, but all result in the same thing. "0" gets returned from the "Execute()" method whether I try to read or write. If I set the timeout value on the execute method to Timeout.Infinite, it will just hang there forever, which explains why I'm getting nothing back. (because it's timing out after 1000ms)
The sample Arduino libraries write to the address "0x77" to talk to this chip. Sparkfun puts out a breakout board just like this one, also using the BMP085 which also refers to 0x77. Having said that, the data sheet (from the link above) talks about a "Device and register address" on page 17, which admittedly, I don't understand how it fits in to all of this or if I even need to worry about it. They talk about addresses 0xEE and 0xEF for reading and writing? I'm lost here. Forgive me if this is a irrelevant/wasted paragraph.
Okay, so... as far as pins go. Here's what I did:
Sensor Pin VIn --> Netduino Pin 5V
Sensor Pin GND --> Netduino Pin GND
Sensor Pin SDA --> Netduino Pin SDA
Sensor Pin SCL --> Netduino Pin SCL
Seems logical, but did I mess this up? Arduino has analog pins for I2C, right? Netduino is not the same way, is it?
Sorry for the rant. Just trying to get it all out there.
If anyone can see any red flags or anything that doesn't look right, I am all ears.
I am starting to wonder if anyone has ever gotten the Netduino 2 and the BMP085 to work over i2c. Seems to be a weird combination out there on the web. Hmm.
Okay, I have updated to Windows 7, NETMF 4.3, Visual Studio 2012 and the Netduino Firmware 4.3 Beta. It didn't make a difference by itself, but then I stumbled upon something that makes no sense. I'm hoping someone can explain this to me.
Using the code that NooM was nice enough to provide, Visual Studio spit out this in the output window upon the Netduino booting up:
So, I put everything back the way it was, only updated the firmware to 4.2.2.2. It actually behaves the same say. All values report 0 until I disconnect and then reconnect the SDA pin while it's running.
So my last question still stands, I suppose. Has anyone ever run into this problem? Any thoughts on what might cause this?
I'm at a total loss, and almost ready to scrap this Netduino.
Hahaha. You mean an open source platform has other bugs, too??
I do have a Netduino Mini sitting on my shelf that I was going to tackle once I got my feet wet with this, but... Maybe I need to hook up this barometer to the mini to isolate the problem being with the Netduino 2. At least then I would know.
NooM, do you have or have you ever used a Netduino 2 or +2 with i2c? I may end up getting another one, but I don't want to go through this again. I mean, it does work, right?
I've read some posts here regarding ic2 problems and I have earmarked this particular sensor for use in my first project, so I'm very much interested in following this post.
Will this sensor work for me using ic2? Sensor problem? firmware problem? Platform problem?
@Danger -- could I ask you to be sure to post whether or not you get this problem resolved?
but i was active a lot and saw a lot of that i2c stuff, but from what i know it got fixed in 4.2.2.2, well doesent look like
I can confirm the exact same behavior using Adafruit i2c OLED. I have to disconnect / reconnect the SDA pin for it to work properly. I've been fighting this for over an hour now until I ran across this post.
I can confirm the exact same behavior using Adafruit i2c OLED. I have to disconnect / reconnect the SDA pin for it to work properly. I've been fighting this for over an hour now until I ran across this post.
Actually, to work around it, I just do the following as the first part of Main():
OutputPort p = new OutputPort(Pins.GPIO_PIN_SDA, true); p.Write(false); p.Dispose( );