Say I have some I2C device with an Arduino. That Arduino sends some data to the device. Let's say it is a PCF8574. Arduino tells this chip to pull P3 HIGH. If I use another Uno and connect to the I2C lines and GND can I somehow get in any form and see that first Uno told the PCF to pull P3 HIGH?
There are I2C sniffer examples, many for UNO, etc. There is a limit of 100KHz. As far as I can see ESP32 can go for 400KHz. I tried a few examples, say this one for ESP32:
But the data I get don't mean anything to me.
My setup is basic. Barebone PCF8574 with pullup resistors and an LED with Nano. And there is an ESP32 to sniff. I can make a schematic if needed.
Or some other solution.
The goal is to clearly see that this P2 is High or LOW. Or if someone gives me a hand for translating this output to something I can understand. Right now basic Blink sketch works through a PCF8574 and lit an LED. ESP32 gives me:
I don't know the answer to the rest of your question but have you read the PCF8574 data sheet to see what it expects and how it responds? Typically any chip at the hardware level sends and receives bytes of data to tell it what to do / respond to what it gets and those bytes are not normally in an easy to read format. To understand them you have to read the data sheet to find out what they mean.
PCF8574 datasheet gives an exact pattern. I forgot to check it. Sry. What I get is the same as what my Nano sends.
Here one can see the I2C address and array of bits.
One thing more.
The author of this sketch recommends an ISO154x IC. But which one? ISO1541 or ISO1540? If in my case I use this setup from above?
There are differences between them But, here, I can by only ISO1541.
After some testing, I can understand the structure I get from this sketch. It is pretty much what the datasheet says. Now, as output is in the buffer, any suggestion on how to strip all things off and get only an array of bits I need. The part between the plus sign.
The buffer is not always as you see here. Sometimes it has a gibberish or two.
It is possible to translate that code and then find the things that you want:
S0100000W = Start, Address 0x20, Write command
00001000 = Data byte 0x08
s = Stop
Can you tell more about your project ?
Do you want that information in a Arduino ? Could you add code to the Master Arduino ?
Do you want to analyze that information on a computer ? Then you better buy a 30 dollar LHT00SU1.
Do you only need to read pin P3 ? Can you connect P3 to a digital input pin of a Arduino board ?
There is an option to put an Arduino board between the Master and the Slave. Using the hardware I2C bus on one side and a software I2C bus on the other side. Since it can not directly respond to a request of the Master (that information has to be requested from the Slave), the project must allow that and the sketch might have to poll the Slave all the time to update the status.
Do you want to do this in real time or afterwards when you've got a buffer of data?
If it's real time, then you may well run out of processing time - even on a 100kHz I2C bus.
If it's afterwards, so you are post-processing the data, then it should be fairly easy to get the values out.
That's usually because the software I2C capture code can't keep up with the I2C bus, but if you're using an ESP32 like the software author did, they indicate on their github page that it should work on a 400kHz bus. That's also assuming that there isn't a bug in their code that causes it to loose track of the capturing process.
Nothing is that much important. Some solution just to even get the data would be fine.
In these few days, I learned a lot. Never even thought about how I2C works in detail. Before, I just skipped this I2C part in the datasheet. Never tried to understand the process. Now, I see everything is so obvious and logical.
I made this setup again, with an ISO1540.
I noticed when I turn off my Nano which is "blinking" two LEDs over PCF8574, ESP32 just waits. When I turn Nano on, ESP32 moves on. So this is ok.
But when I turn off ESP32, there are problems. Nano keeps working fine, but ESP32 when turned on goes into resets. This can be fixed to remove VCC from ISO1540, the side connected to the ESP32. When ESP32 starts, then connect VCC on the ISO1540 and everything is fine.
In a project, this should be done with some MOSFET or so, I think. To power the IS01540 side after the ESP32.