Tested,
The chip is being detected correctly.
The outupts I receive from Serial.Print are:
Status=1 (B00000001)
Write Status= 255 (B11111111)
Which according to the datasheet, means writing has failed, and the only error is the invalid CRC. (which is however already a great improvement from my original code)
the code you gave me that calculates the CRC is this part:
packet[0] = WRITE_DATA_WITH_STOP; // Command ("Write Data With Stop")
packet[1] = i2cAddress; // I2C slave to address
packet[2] = 0x01; // Number of data bytes to write
packet[3] = i2cData; // The data to write
// Is this calculating the correct CRC16?
uint16_t CRC16 = oneWire.crc16(&packet[1], 3);
// Are the CRC16 bytes being stored in the correct order?
packet[4] = CRC16 >> 8; // Most significant byte of 16 bit CRC
packet[5] = CRC16 & 0x0F;
If I understands correctly it calculates the CRC of the three bytes [1] [2] and [3] of the packet array?
According to the datasheet, the CRC should be calculated from (command,Slave Address, writ length, write data), thus 4 bytes, including [0].) However as I changed the code with
uint16_t CRC16 = oneWire.crc16(&packet[1], 4);
or
uint16_t CRC16 = oneWire.crc16(&packet[0], 4);
Still gives me the same status outputs. (error on CRC)
Don't know if it is the CRC to be wrong or its storing in the packet, the data sheet says:
Formed 1-Wire Packet:
[Command 4Bh] [I2C Slave Address][Write Length][Write Data][CRC16][Delay or Busy Poll][Status][Write Status]
CRC16 of command, I2C slave address, write length, and write data.