Ideally I would get I2C working :-) I am using 4K7 pullups to 5V and analog pins 4 & 5. The code below (written by another helpful soul)returns a result but the bytes returned are all 8's with a PPM: 2056 !!!
IE:
CO PPM: 2056
Data received:8,8,8,8,8,8,8,
#include <Wire.h>
//wire library
#define address 0x31
//address of the sensor
#define delayC 5000
//delay count in ms
#define baudrate 9600
//baudrate for communication
void setup()
{
Wire.begin();
Serial.begin(baudrate);
}
void loop()
{
//Serial.print("CO PPM: ");
int co=0;
Wire.beginTransmission(address);
// start the transmission
Wire.send('R');
Wire.endTransmission();
//end the transmission
/// Wire.requestFrom(address, 7);
// format
// 1) Configuration 0x08
// 2) CO (high byte?)
// 3) CO (low byte?)
// 4) reserved
// 5) reserved
// 6) reserved
// 7) reserved
Serial.print ("Data received:");
for (int i=0;i<7;i++)
{
byte c;
c = getI2Cchar();
Serial.print(c,HEX);
Serial.print(',');
if (i==1) co = c;
if (i==2) co = (co << 8) | c;
}
Serial.println("");
Serial.print("CO PPM: ");
Serial.println(co);
delay(delayC);
}
byte getI2Cchar()
{
delay(2); // delay 2mS
Wire.requestFrom(address, 1);
return (Wire.receive());
}