Hi!
I just want to get data from a RGB sensor (MAX44005). Here is a link to its datasheet.
I tried to use the Wire library but it needs a Repeated Start condition which is not supported in the library. That or I just don’t know how to do it. So I found and used the SoftI2CMaster library.
Here is my test code:
#define SDA_PORT PORTD
#define SDA_PIN 4
#define SCL_PORT PORTD
#define SCL_PIN 5
#include <SoftI2CMaster.h>
#define I2C_FASTMODE 1
byte sense[]={0,0,0};
byte a=68;
byte o=6;
void setup() {
Serial.begin(9600);
Serial.print("Sensing...");
i2c_init;
}
void loop() {
for (int i=0; i<3;i++){
i2c_start(a|0);
i2c_write(o);
i2c_rep_start(a|1);
sense[i]=i2c_read(true);
i2c_stop();
o+=2;
}
Serial.print(sense[0]);
Serial.print("\t");
Serial.print(sense[1]);
Serial.print("\t");
Serial.println(sense[2]);
o=6;
delay (10);
}
It suppose to show me the bytes from specific registers. It just say “Sensing…” and then nothing.
I tried to see if connections and circuitry is at fault but when I used a I2C Scanner using the Wire library it can find it. But when I used the I2C Scanner example from the SoftI2CMaster it says:
“Initialization error. SDA or SCL are low”
I don’t get any errors when I compile so I don’t know what is wrong. I really don’t know how to use the SoftI2CMaster Library. I am really kinda new to this.
Any help would really be appreciated! Thanks!