Thanks for the reply...
I tried your suggestion and have posted the code and results for two different scenarios.
- Reading from the I2C with the address offsets.
- Reading from the I2C per your suggestion.
I had to leave the writing to set the power up as I had it otherwise the power would not switch on and off as I intend for it to do...
1. Reading from the I2C with the address offsets.
Serial.flush(); // flush the serial buffer
delay (300);
Serial.println("---");
// ------------ turn on ext power ------------------
Wire.beginTransmission(0x22); // write to I2c Address 44h to set power condition
// Wire.beginTransmission(0x44); // writing to I2c Address 44h to set power condition - DOES NOT WORK
Wire.write(0xAF); // write command to turn off ext headbox power
timeout = Wire.endTransmission(); // Check status of data sent- did it get there?
delay(4500);
Serial.print(" Power IS ON- timeout= "); // Check status of data sent- did it get there?
Serial.print(timeout);
Wire.beginTransmission(0x21); // write to I2c Address 42h to check if ext device is available
Wire.write(0x00); // write command to test to see if device exists
timeout = Wire.endTransmission(); // Check status of data sent- did it get there?
Serial.print(" check power on- timeout= ");
Serial.print(timeout);
v44on= 0; // initialize v44off to zero
Wire.requestFrom(0x21, 1); // request 1 byte from 0x42h - revision
while(Wire.available()) // slave may send less than requested
{
v44on = Wire.read(); // receive a byte as character
}
Serial.print(" v44onf= ");
Serial.println(v44on);
// ------------ turn off ext power ------------------
Wire.beginTransmission(0x22); // write to I2c Address 44h to set power condition
// Wire.beginTransmission(0x44); // writing to I2c Address 44h to set power condition - DOES NOT WORK
Wire.write(0xFA); // write command to turn off power
timeout = Wire.endTransmission(); // Check status of data sent- did it get there?
delay(4500);
Serial.print(" Power IS OFF- timeout= ");
Serial.print(timeout);
Wire.beginTransmission(0x21); // write to I2c Address 42h to check if ext device is available
Wire.write(0x00); // write command to test to see if device exists
timeout = Wire.endTransmission(); // Check status of data sent- did it get there?
Serial.print(" check power off- timeout= ");
Serial.print(timeout);
v44off= 0; // initialize v44off to zero
Wire.requestFrom(0x21, 1); // request 1 byte from 0x42h - revision
while(Wire.available()) // slave may send less than requested
{
v44off = Wire.read(); // receive a byte as character
}
Serial.print(" v44on= ");
Serial.println(v44on);
// ------------ turn on ext power ------------------
Wire.beginTransmission(0x22); // write to I2c Address 44h to set power condition
// Wire.beginTransmission(0x44); // writing to I2c Address 44h to set power condition - DOES NOT WORK
Wire.write(0xAF); // write command to turn off ext headbox power
timeout = Wire.endTransmission(); // Check status of data sent- did it get there?
delay(4500);
Serial.print(" Power IS Turned Back ON- timeout= "); // Check status of data sent- did it get there?
Serial.println(timeout);
===============================================================================
With the device connected:
(I2C addr 42h = 1 when power is on
No data is displayed when power is off)
When testing to see if the device is there, Wire.endTransmission returned "0"
I tried writing to 0x44 instead of 0x22 but then my power would not switch on and off.
(the library does not accomodate how the I2C parts are wired on the device that I am communcating with...)
Here is a sample of the output seen (device connected):
ð---
Power IS ON- timeout= 0 check power on- timeout= 0 v44onf= 1
ø---
Power IS ON- timeout= 0 check power on- timeout= 0 v44onf= 1
With the device disconnected:
(all data is seen- power doesn't matter as device is not connected)
Power IS ON- timeout= 0 check power on- timeout= 2 v44onf= 0
Power IS OFF- timeout= 0 check power off- timeout= 2 v44on= 0
Power IS Turned Back ON- timeout= 0
2. Reading from the I2C per your suggestion.
Serial.flush(); // flush the serial buffer
delay (300);
Serial.println("---");
// ------------ turn on ext power ------------------
Wire.beginTransmission(0x22); // write to I2c Address 44h to set power condition
// Wire.beginTransmission(0x44); // writing to I2c Address 44h to set power condition - DOES NOT WORK
Wire.write(0xAF); // write command to turn off ext headbox power
timeout = Wire.endTransmission(); // Check status of data sent- did it get there?
delay(4500);
Serial.print(" Power IS ON- timeout= "); // Check status of data sent- did it get there?
Serial.print(timeout);
Wire.beginTransmission(0x42); // write to I2c Address 42h to check if ext device is available
Wire.write(0x00); // write command to test to see if device exists
timeout = Wire.endTransmission(); // Check status of data sent- did it get there?
Serial.print(" check power on- timeout= ");
Serial.print(timeout);
v44on= 0; // initialize v44off to zero
Wire.requestFrom(0x42, 1); // request 1 byte from 0x42h - revision
while(Wire.available()) // slave may send less than requested
{
v44on = Wire.read(); // receive a byte as character
}
Serial.print(" v44onf= ");
Serial.println(v44on);
// ------------ turn off ext power ------------------
Wire.beginTransmission(0x22); // write to I2c Address 44h to set power condition
// Wire.beginTransmission(0x44); // writing to I2c Address 44h to set power condition - DOES NOT WORK
Wire.write(0xFA); // write command to turn off power
timeout = Wire.endTransmission(); // Check status of data sent- did it get there?
delay(4500);
Serial.print(" Power IS OFF- timeout= ");
Serial.print(timeout);
Wire.beginTransmission(0x42); // write to I2c Address 42h to check if ext device is available
Wire.write(0x00); // write command to test to see if device exists
timeout = Wire.endTransmission(); // Check status of data sent- did it get there?
Serial.print(" check power off- timeout= ");
Serial.print(timeout);
v44off= 0; // initialize v44off to zero
Wire.requestFrom(0x42, 1); // request 1 byte from 0x42h - revision
while(Wire.available()) // slave may send less than requested
{
v44off = Wire.read(); // receive a byte as character
}
Serial.print(" v44on= ");
Serial.println(v44on);
// ------------ turn on ext power ------------------
Wire.beginTransmission(0x22); // write to I2c Address 44h to set power condition
// Wire.beginTransmission(0x44); // writing to I2c Address 44h to set power condition - DOES NOT WORK
Wire.write(0xAF); // write command to turn off ext headbox power
timeout = Wire.endTransmission(); // Check status of data sent- did it get there?
delay(4500);
Serial.print(" Power IS Turned Back ON- timeout= "); // Check status of data sent- did it get there?
Serial.println(timeout);
Per your suggestion, I wrote to and read from 0x42 instead of 0x21-
I tried writing to 0x44 instead of 0x22 but then my power would not switch on and off.
(the library does not accomodate how the I2C parts are wired on the device that I am communcating with...)
With the device connected:
(I2C addr 42h = 0
When testing to see if the device is there, Wire.endTransmission returned "4"
When power is on and no data is displayed when power is off)
Here is a sample of the output seen (device connected):
ð---
Power IS ON- timeout= 0 check power on- timeout= 4 v44onf= 0
ð---
Power IS ON- timeout= 0 check power on- timeout= 4 v44onf= 0
With the device disconnected: (timeout is now 2 but data did not change).
Here is a sample of the output seen (device not connected):
Power IS ON- timeout= 0 check power on- timeout= 2 v44onf= 0
Power IS OFF- timeout= 0 check power off- timeout= 2 v44on= 0
Power IS Turned Back ON- timeout= 0