MICS-VZ-89T - I2C Write Command

Hey,

could anybody please look at the I2C Datasheet (attached) and my resulting Code to write?

`
const SET_WRITE = "\\x08";

function calibrate(){
vz89.write(vz89Addr, SET_WRITE + "\\x01\\x00");
server.log("i2c error: "+vz89.readerror());
imp.sleep(1.0);
}
`

The Datasheet reads:

Request: Set ppmC02: Address byte = 0b11100000 Command = 0b00001000 Data byte 1 = ppmCO2 MSB Data byte 2 = ppmCO2 LSB

I’am not sure if “\x08\x01\x00” is the right syntax. I also dont know if i should set 13-242 as
value or what value the sensor expects.

Hope that someone can help…

Assuming vz89Addr is 0xe0, that seems right. You’re sending it 256 as the ppmCO2 value (is that what you wanted?)

Are you seeing an i2c error? I’d log the result of the write command too.

The Address is

vz89Addr <- 0x70 << 1; //Datasheet: (VZ89 address (7 bits) = 0b1110000)
They used another Address in the example…

I think that i only can send values between 13-242.

Will server.log(vz89.write(vz89Addr, SET_WRITE + "\\x01\\x00"));work to log the result?

I changed my function to this:

function calibrate(data){ local value = format("\\\\x%02X", data); server.log("Calibration Value: "+data+" | "+value); server.log(vz89.write(vz89Addr, SET_WRITE + value + value)); server.log("i2c error: "+vz89.readerror()); imp.sleep(1.0); }

Log:
2016-05-14 11:23:29 UTC+2 [Status] Downloading new code; 1.94% program storage used 2016-05-14 11:23:29 UTC+2 [Device] Calibration Value: 0 | \\x00 2016-05-14 11:23:29 UTC+2 [Device] 0 2016-05-14 11:23:29 UTC+2 [Device] i2c error: 0

I mean, this is saying that yes, the write happened - ie the transaction succeeded. There’s no data read from the device so you won’t see anything apart from zero returned.

On the upside, this confirms that you do have the right i2c address. I guess you should maybe read a register to see if the sensor is returning useful data?