-1
\$\begingroup\$

Currently I am working on a project where I have to set an I2C device high, would I do thing by writing to the address of that I2C device then do something like I2C_Write(1)? I am also doing this on a pic16f1825 using mikroC.

here is the datasheet for the device http://www.ti.com/lit/ds/symlink/pca9554.pdf

\$\endgroup\$
6
  • 2
    \$\begingroup\$ What do you mean by "set an I2C device high"? This doesn't make much sense without any context. \$\endgroup\$
    – brhans
    Commented Jul 18, 2017 at 17:14
  • \$\begingroup\$ @brhans the context of that is that I have a relay and I need to set the relay high and then low when the relay is a latching relay and just high when its a normal relay using a pic and the relay is an i2c device \$\endgroup\$ Commented Jul 18, 2017 at 17:21
  • 3
    \$\begingroup\$ There's usually more to I2C devices than just writing a 1 or a 0. Your I2C relay should have a datasheet which tells you what I2C commands you need to use to make it do something. If you share a link to this datasheet then someone might be able to help... \$\endgroup\$
    – brhans
    Commented Jul 18, 2017 at 17:33
  • 1
    \$\begingroup\$ ULN2003A is not an I2C device \$\endgroup\$
    – mjh2007
    Commented Jul 18, 2017 at 18:10
  • 2
    \$\begingroup\$ @brhans - the original version of the post had a link to the ULN2003A data sheet, which was later changed. This question may not be clear enough to be answerable. \$\endgroup\$ Commented Jul 19, 2017 at 2:53

1 Answer 1

0
\$\begingroup\$

Your pic16f1825 does not have any general purpose outputs so you're using a pca9554 which has 8 General Purpose IOs switched via I2C. The relay needs to be connected to one of the pca9554 IOs (labeled with a P in the datasheet). The pca9554 can output 5v at 20ma. If your relay will switch with that current and voltage then great. If not you'll need the pca9554 to switch something that can, a transistor switch would be a normal choice. You then need to connect the pic to the pca9554 and use the datasheet to set the appropriate registers for output (by default they're configured as inputs) and then send the command to set the pin high. A schematic of your circuit would be useful as I've made some assumptions here.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.