Sorry for yet another post about getting i2c to work, but here goes. Since I was unable to get my Adafruit type i2c LCD display working on the Edison, I decided to try something simpler or so I thought... a Sparkfun SEN-11931 i2c tmp102 temperature sensor.
This sensor can be hard configured to use i2c addresses 0x48 or 0x49. Needless to say, it works fine on an Arduino UNO connected to A4/A5 using this sketch.
//Arduino 1.0+ Only
//Arduino 1.0+ Only
//////////////////////////////////////////////////////////////////
//©2011 bildr
//Released under the MIT License - Please reuse change and share
//Simple code for the TMP102, simply prints temperature via serial
//////////////////////////////////////////////////////////////////
#include <Wire.h>
int tmp102Address = 0x48;
void setup(){
Serial.begin(9600);
Wire.begin();
}
void loop(){
float celsius = getTemperature();
Serial.print("Celsius: ");
Serial.println(celsius);
float fahrenheit = (1.8 * celsius) + 32;
Serial.print("Fahrenheit: ");
Serial.println(fahrenheit);
delay(2000); //just here to slow down the output. You can remove this
}
float getTemperature(){
Wire.requestFrom(tmp102Address,2);
byte MSB = Wire.read();
byte LSB = Wire.read();
//it's a 12bit int, using two's compliment for negative
int TemperatureSum = ((MSB << 8) | LSB) >> 4;
float celsius = TemperatureSum*0.0625;
return celsius;
}
However, even though it compiles and uploads OK, nothing at all prints to Arduino's Serial Monitor screen when it's running on the Edison Arduino board. Using a scope, I confirmed the Edison-Arduino is sending out clock on A5 and data on A4, so I know the script is running and I have the right pins. BTW, I scoped it with the sensor disconnected.
I have to assume the issue lies in the Wire.h library as implemented in the Edison-Arduino IDE which has:
#define I2C2 0x4819c000
#define I2C1 0x00000000
#define WIRE_INTERFACES_COUNT 1
From other posts, I am led to believe 'I2C2 0x4819c000' equates to BUS ID 6. For one thing, I don't understand how this translates to ID 6?
In any case, how can I get the above script to run on an Edsion-Arduino? The sensor itself doesn't care what bus it is on, right? It only cares about the i2c address.