I2C with MAX14662

Folks, I’m a bit new to this…
I’m playing with a Maxim MAX14662 I2C controlled 8-way SPST switch.
I thought it would be brain-dead simple as:

#include <Wire.h>
void setup() 
{
  Serial.begin(9600);
  Wire.begin();
  Wire.beginTransmission(0x4C);  //addr of device
  Wire.write(0x00);              //point to loc
  Wire.write(0x77);              //write data to loc
  Wire.endTransmission();        //give up line


  delay(1000);

  Wire.beginTransmission(0x4C);  //addr of device
  Wire.write(0x00);              //point to loc
  Wire.requestFrom(0x4C, 1);     //set up read
  byte regVal = Wire.read();     //read
  Wire.endTransmission();        //give up line

  Serial.println(regVal);        //print 
}

void loop()
{
}

But all I get as output is 0.

I’m fairly certain about the hardware since I was able to get a TMP112 temp sensor working.
The datasheet table 3 has me a confused with read/write addrs of 0x99 and 0x98. Not sure what
to do with these.

Thoughts/Comments/Flames?

Have you run the i2cbus scanner sketch? It will show you what is on the bus.

The 0x99/0x98 are the 8 bit address of the chip which includes the R/~W bit. The Wire library uses "7 bit addressing" so if you shift those by 1 bit, you get the address 0x4C. Reading always has the LSB set so when reading, the 8 bit address is always one more than the write address.

This all assumes you have AD0 and AD1 tied low (Pin 23 & 28). You also need pin 1 low to put it into I2C mode and pin 22 HIGH so it is not in shut-down.

scanner does say it’s out there:

Scanning…
I2C device found at address 0x4A !
I2C device found at address 0x4C !
done

4A is the TMP112
4C is the MAX14662

I think this is all about timing.
When I put the same code in a loop with a 1000ms delay, I get all 0’s
0
0

0
0

If I decrease the delay to 10ms I get (mostly) all 119’s
119
119
119
0
119
119

It appears that the register is resetting. By placing the write in the loop with a very short delay,
it doesn’t have time to reset. Time to re-read the data sheet.

#include <Wire.h>

void setup() 
{
  Serial.begin(9600);
  Wire.begin();
}

void loop() 
{
  Wire.beginTransmission(0x4C);  //addr of device
  Wire.write(0x00);              //point to loc
  Wire.write(0x77);              //write data to loc
  Wire.endTransmission();        //give up line
   
  delay(10);

  Wire.requestFrom(0x4C, 1);     //set up read
  byte regVal = Wire.read();     //read
  Wire.endTransmission();        //give up line
   
  Serial.println(regVal);        //print 
}

Manufacturer’s page of the MAX14622: https://www.maximintegrated.com/en/products/analog/analog-switches-multiplexers/MAX14662.html.

Setting the register address to 0 before a Wire.requestFrom() is optional, so just a Wire.requestFrom() is enough. That is what you already do.
You could try to add the optional setting of the register address with a repeated start.

The majority of the I2C chips have the I2C section in hardware independent of the rest of its functionality. Then a delay is never needed. There are also I2C chips that can do only one thing, either communicate with the I2C bus or do there their thing that they are made for. I doubt if such a simple interface would need a delay.

Perhaps something is wrong on the bus, you can add a test:

int n = Wire.requestFrom( 0x4C, 1);
if( n == 1)         // received the same amount of bytes as requested ?
{
  byte regVal = Wire.read();
  Serial.print( "0x");
  if( regVal < 0x10)
    Serial.print( "0");
  Serial.println( regVal, HEX);
}
else
{
  Serial.println( "requestFrom failed");
}

Which Arduino board do you use ?
The MAX14622 can work at 3.3V and 5V, so it should work with every Arduino board.
The TMP112 is only for 3.3V.
Can you give links to the MAX14622 and TMP112 modules (preferably links to where you bought them).
Do you use pullup resistors ?
Can you make a photo of your wiring ?

The Wire.endTransmission() is not to give up the line. Can you remove the one after the Wire.requestFrom(). See also my alternative explanation.

The test code did say there was data available - but only if I wrapped it in a very tight loop.
This seemed wrong to me. I shouldn’t need a loop at all. Time to simplify…
I’m actually running these devices at 1.8v with the use of a level shifter (SparkFun BOB-12009).
If I eliminate the shifter and just run the two I2C devices at the 3.3v supplied by the UNO,
all works as expected - no loop needed. Thx.

There are many things that I don't understand.

This is not a tight loop and you don't know if the data was available:

Wire.requestFrom(0x4C, 1);     //set up read
  byte regVal = Wire.read();     //read

I don't understand what seems wrong to you and I don't know what you mean with a very tight loop.

I don't know if you have removed the Wire.endTransmission() after the Wire.requestFrom().

You may not connect the Uno SDA and SCL to the TMP112. It might work if you carefully calculate the voltages with the pullup resistors, but then it will probably not be within the specifications in the datasheets (for both the Atmega328P and the TMP112).

Do you use the bare chips for the MAX14622 and the TMP112 ? So there are no modules with extra components ?

The Arduino Uno is a 5V board. When using a level shifter you must power the "HV" with 5V, or else the level shifter shifts the signals up to 3.3V which is not much use to the Arduino Uno because it needs 5V signals.

Without level shifter (which is wrong anyway) there are no pullup resistors.
Sparkfun level shifter: https://www.sparkfun.com/products/12009.
It has 10k pullup resistors on both the high side and the low side. That is enough pullup for most situations.

Is there a reason to use the MAX14622 with 1.8V. It will work with 5V as well. You can connect it to the Arduino Uno without level shifter and power it with 5V.
When you use a level shifter for something else, then you should still connect the MAX14622 directly to the Uno (not via the level shifter).
Powering the MAX14622 with 3.3V is not okay, because the SDA and SCL for the Uno board use 5V levels, it is a 5V I2C bus.

Powering the TMP112 with 3.3V is okay, but the SDA and SCL need the level shifters.

Can you show your new sketch and new schematic ? There are too many things that are not okay.