Netduino home hardware projects downloads community

Jump to content


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.

Danger

Member Since 31 Jul 2013
Offline Last Active Feb 23 2014 05:59 PM
-----

Topics I've Started

Netduino 2 and the Adafruit BMP085 Barometer (I2C)

30 August 2013 - 06:01 PM

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.

 

I have:

- A Netduino 2 running Firmware 4.2.2.1

- A Barometric Pressure sensor from Adafruit (BMP085)  http://www.adafruit.com/products/391  (datasheet: http://www.adafruit....85-DS000-06.pdf)

- A headache

- And the following code:

 

            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.
 
Thanks so much!
 

 

 


home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.