Correct.
In the meantime, I've written my own code for the barometer in which I've simply hooked up the SDA and SCL pins to a couple of random digital pins, and then bit-banged to get the registers I want using a repeated start. And it works! ... mostly.
My code for this is pretty ugly, but here it is:
#define RG03_sda 2
#define RG02_scl 1
uint8_t r = 0;
void setup() {
// Serial.begin(9600);
pinMode(RG03_sda, OUTPUT);
pinMode(RG02_scl, OUTPUT);
}
void loop() {
r = barometer();
// Serial.println(r, HEX);
delay(10);
}
uint8_t barometer() {
r = 0;
//Start condition
digitalWrite(RG02_scl, HIGH);
digitalWrite(RG03_sda, HIGH);
delay(1);
digitalWrite(RG03_sda, LOW);
delay(1);
digitalWrite(RG02_scl, LOW);
//Pick slave device to write to
int i = 0;
for(i = 0; i < 8; i++) {
digitalWrite(RG03_sda, ((0xC0 >> (7-i)) & 0x01)); //0xC0 is write, 0xC1 is read
digitalWrite(RG02_scl, HIGH);
delay(1);
digitalWrite(RG02_scl, LOW);
}
//pull data line low
digitalWrite(RG03_sda, LOW);
//extra clock pulse to get ack bit
digitalWrite(RG02_scl, HIGH);
delay(1);
digitalWrite(RG02_scl, LOW);
//Choose register
for(i = 0; i < 8; i++) {
digitalWrite(RG03_sda, ((0x0C >> (7-i)) & 0x01)); //0x0C is device identification register
digitalWrite(RG02_scl, HIGH);
delay(1);
digitalWrite(RG02_scl, LOW);
}
//pull data line low
digitalWrite(RG03_sda, LOW);
//extra clock pulse to get ack bit
digitalWrite(RG02_scl, HIGH);
delay(1);
digitalWrite(RG02_scl, LOW);
//repeat start
digitalWrite(RG03_sda, HIGH);
digitalWrite(RG02_scl, HIGH);
delay(1);
digitalWrite(RG03_sda, LOW);
digitalWrite(RG02_scl, LOW);
//Pick slave device to read from
for(i = 0; i < 8; i++) {
digitalWrite(RG03_sda, ((0xC1 >> (7-i)) & 0x01)); //0xC0 is write, 0xC1 is read
digitalWrite(RG02_scl, HIGH);
delay(1);
digitalWrite(RG02_scl, LOW);
}
//pull data line low
digitalWrite(RG03_sda, LOW);
//extra clock pulse to get ack bit
digitalWrite(RG02_scl, HIGH);
delay(1);
digitalWrite(RG02_scl, LOW);
//switch pinmode so I can read from sda pin rather than send
pinMode(RG03_sda, INPUT);
//Read the data in the device identification register
for(i = 0; i < 8; i++) {
r |= (digitalRead(RG03_sda) << (7-i));
digitalWrite(RG02_scl, HIGH);
delay(1);
digitalWrite(RG02_scl, LOW);
}
//switch pinmode back to output on sda pin
pinMode(RG03_sda, OUTPUT);
//extra clock pulse to get ack bit
digitalWrite(RG02_scl, HIGH);
delay(1);
digitalWrite(RG02_scl, LOW);
//stop
digitalWrite(RG03_sda, LOW);
digitalWrite(RG02_scl, HIGH);
digitalWrite(RG03_sda, HIGH);
return r;
}
The problem I run into is that when I begin the serial port, my SCL line doesn't work any longer and it stays HIGH no matter what. I know I'm getting the correct data since I can see exactly what's going on through the logic analyzer (pic attached). The device register should hold 0xC4 and that's exactly what I'm reading so that's good. But when I try to display that over the serial port it screws everything up..
Thoughts?
Edit: I should clarify that the code works as is with the Serial lines commented out. But as soon as I uncomment the "Serial.begin(9600)" line, the SCL line stays high no matter what and I get really weird stuff on the SDA line. The pic from the logic analyzer is with the Serial lines commented out so it works without the Serial stuff.
EDIT 2: Just found out that when using serial communication you can't use pins 0 and 1. Switched the pins to 2 and 3 and it works now! Thanks so much for your help in general chuck. I'll probably just ditch the wire library and do the bit-banging myself for all of the sensors.