Trouble sending i2c from TX2 to slave

I have a computer science background and a little embedded systems programming with an ST MicroElectronics STM32 board, but I am new to the Jetson TX2 board and i2c communication with Linux. I am trying to send i2c information from the tx2 to the Adafruit 16 - channel servo controller, but am getting Remote I/O errors.
Here is my code:

My terminal output:
My output when I search i2cdetect:
I am also connected to the bus with sdl and sca pins on the j21 pinout here:

I have been following the Linux Wiki for interacting with i2c devices, but have had no luck. I open the file descriptor and then use ioctl with the i2c address of 0x40. However, when I try to write to the i2c, I get a Remote I/O error. I noticed there is also something at address 0x70. In the Linux wiki it mentions, under the Writing to ADC section that some devices require you to write to a device register. Is that what I am missing? Please help. I have been working on this for a little while now and would like to learn and push my project forward. Thank you in advance.

Charlie Barber

Can you make sure the Adafruit device is powered up correctly? If other devices on this bus can be detected, then it should be your device problem.

It was powered up. The problem I found was that I was not sending the register to write to along with the data in the write call. Thank you for the response

1 Like