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.
Photo

Multiple i2c -bmp085 and lcd shield


  • Please log in to reply
3 replies to this topic

#1 JimmyNet

JimmyNet

    Member

  • Members
  • PipPip
  • 12 posts

Posted 13 January 2013 - 01:39 AM

Hallo All,

I have two devices the bmp085 sensor and the rgb lcd shield kit from adafruit. Both are using the i2c connection. But i can't get both to work.

 

i tried multiple threads without luck. the source code of bmp086 uses the i2c class. the lcd shield uses a muli2c class.

 

any tips?

 

Gr. jim



#2 carb

carb

    Advanced Member

  • Members
  • PipPipPip
  • 352 posts
  • LocationCrystal River, Florida

Posted 13 January 2013 - 02:02 AM

Jim,

 

I don't know if I can help but I need a little more information.

 

Which board are you using, Netduino Plus or the Plus 2?

 

You have both devices on I2C, which addresses are you using? The I2C can normally be 1 - 8 (in binary). The 2 devices need to be on different address.

 

Do the LCD and the BMP085 work separately?

 

Which firmware are you using?

 

Also if you can provide some source code that would help to locate a problem.

 

Are you using Stefan's Toolbox?

 

Will help if I can, but without additional information it is like asking the question "how many marbles are in this jar, true or false?"

 

Chuck



#3 JimmyNet

JimmyNet

    Member

  • Members
  • PipPip
  • 12 posts

Posted 13 January 2013 - 07:01 AM

Hi chuck,

sorry thats true. i will get end check required information.

 

Gr. jim.



#4 JimmyNet

JimmyNet

    Member

  • Members
  • PipPip
  • 12 posts

Posted 13 January 2013 - 07:43 AM

Firmware: 4.2.0.0

Board: Netduino plus

The rgb schield work on 5 voltage

The temperature sensor works on 3,3 voltage

 

I am using Stefan's Toolbox for the rgb lcd schield. the example code works fine for the display.

I am using the BMP085 class for the sensor this class calls this constructor which makes a new instance of I2CDevice.Configuration

 

public BMP085(byte address, DeviceMode deviceMode)
{
 Address = address;
 _slaveConfig = new I2CDevice.Configuration(address, ClockRateKHz);
 _oversamplingSetting = (byte)deviceMode;

 // Get calibration data that will be used for future measurement taking.
 GetCalibrationData();

 // Take initial measurements.
 TakeMeasurements();

 // Take new measurements every 30 seconds.
 _sensorTimer = new Timer(TakeMeasurements, null, 200, 30000);
}

 

The constructor of the pin extender on the shield is this constuctor calls a instance of Multi2C:

 

public Mcp23017(ushort Address = 0x20, int ClockRateKhz = 200)
{
 // Initialises the device
 this._Device = new MultiI2C(Address, ClockRateKhz);
 // Set all pins to input by default
 this._Device.Write(new byte[] { _IODIRA, 0xff }); // All pins on port A
 this._Device.Write(new byte[] { _IODIRB, 0xff }); // All pins on port B

 // Prepares all pins
 this.Pins = new Mcp23017Port[16];
 for (int PinNo = 0; PinNo < this.Pins.Length; ++PinNo)
 this.Pins[PinNo] = new Mcp23017Port(this, PinNo);
}
 

The bmp085 sensor is called by (this code address is 0x77):

// Create instance of temp and pressure sensor
BMP085 tempAndPressureSensor = new BMP085(0x77, BMP085.DeviceMode.UltraLowPower);

 

The rgb lcd schield contrusctor is called by (this code address is 0x20)

public Mcp23017(ushort Address = 0x20, int ClockRateKhz = 200)

 

What i was trying to do is read the temperature and pressure from the bmp085 and write it to the rgb lcd shield. so both must work independantly.

 

in my main code i declared both devices as following:

 

[font="arial, helvetica, sans-serif;"]BMP085 tempAndPressureSensor = new BMP085(0x77, BMP085.DeviceMode.UltraLowPower);
string temperature = tempAndPressureSensor.Celsius.ToString("F2");
string pressure = tempAndPressureSensor.Pascal.ToString();
Debug.Print("'The temperature is: " + temperature + " degrees and pressure is " + pressure +" Pascal.'");

// The Adafruit LCD Shield uses a MCP23017 IC as multiplex chip
Mcp23017 Mux = new Mcp23017();

// Pins 0 to 4 on the Mux-chip are connected to the buttons
IGPIPort ButtonSelect = Mux.Pins[0];
IGPIPort ButtonRight = Mux.Pins[1];[/font]

etc...

 

When i debug/execute this code it makes a instance of the sensor and prints the debug text. When it makes a instance of the mcp23017 i get an exception in the Multi2C class in the constructor:

public MultiI2C(ushort Address, int ClockRateKhz = 100)
{
 // Sets the configuration in a local value
 this._Configuration = new I2CDevice.Configuration(Address, ClockRateKhz);

 // Sets the default timeout
 this.Timeout = 100;

 // If no I2C Device exists yet, we create it's first instance
 if (_I2CDevice == null)
 {
 // Creates the SPI Device
 _I2CDevice = new I2CDevice(this._Configuration); <-- error message
 }
}

 

Error message is:

A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.SPOT.Hardware.dll
An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.SPOT.Hardware.dll

 

My guess is that Multi2C class and the BMP085 class both try to make a new instance of the I2CDevice configuration.

 

i am not a expert on i2c how can i make this work? refactor the bmp085 class in specific how to instance of i2c? saw a few examples on this forum but did not worked for me.

 

Thanks for the help






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.