WhitehawkTailor / I2C-sniffer

This code catches I2C communication by running on an ESP32 board that are connected to I2C BUS lines as a passive listener.
GNU General Public License v3.0
27 stars 16 forks source link

Extracting data from output #1

Open ITstreet1 opened 2 years ago

ITstreet1 commented 2 years ago

I tried this sniffer and it works just fine.

My question is: If I get say, this line in the output buffer S0100000W+00001000+s I can see that on the 0100000 address I have 00001000 data. How to take this data for this specific address and do something with it? Maybe send to a server. Do anything.

The reason is, if there are multiple I2C devices, and I want to monitor only specific. So if I get a bunch of those readings and want to filter all of them and take only this one, cut everything and send this 00001000 to a server.

Any help would be appreciated.

WhitehawkTailor commented 2 years ago

It would be good to see the beginning of the message flow. The example I can see above has no S and s part to indicate the beginning (S-Star) and the end (s-stop).

ITstreet1 commented 2 years ago

It was a bad wire on SDA2. I fixed that and those 1111 are gone. Now there is still the problem with resets...

This is from the middle of the response.

S0100111W+00000000+11111000+s
S0100111W+00000010+s
S0100111R+11111000-s
S0100111W+00000010+11110000+s
S0100111W+00000010+s
S0100111R+11110000-s
S0100111W+00000010+11100000+s
S0100111W+00000010+s
S0100111R+11100000-s
S0100111W+00000010+11000000+s
S0100111W+00000010+s
S0100111R+11000000-s
S0100111W+00000010+10000000+s

Start delay    
End delay    ets Jun  8 2016 00:22:57

rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1284
load:0x40078000,len:12836
load:0x40080400,len:3032
entry 0x400805e4

Start delay    
End delay    
SCL up: 1782 SDA up: 379 SDA down: 379 false start: 1694
0100011W+00000011+s
S0100011R+11100001-s
S0100011W+00000011+11110001+s
S0100011W+00000011+s
S0100011R+11110001-s
S0100011W+00000011+11111001+s
S0100011W+00000011+s
S0100011R+11111001-s
S0100011W+00000011+11111101+s
S0100011W+00000011+s
S0100011R+11111101-s
S0100011W+00000011+11111111+s
S0100011W+00000011+s
S0100011R+11111111-s
S0100011W+00000011+11111111+s
S0100011W+00000010+s
S0100011R+00000000-s
S0100011W+00000010+10000000+s
S0100011W+00000010+s
S0100011R+10000000-s
S0100011W+00000010+11000000+s
S0100011W+00000010+s
ITstreet1 commented 2 years ago

Ok, I get the new PCBs

With ISO1540, when everything is connected, it works like a charm. When I turn on/off power on the device I sniff, it is ok. No issues. When I do the same on my sniffer, the device I sniff froze. After much testing, I noticed that when I want to do a simple reset of my sniffer, I have to disconnect VCC and I2C lines from the SIO1540, the side of the device I sniff. I tried with some MOSFETs but had no luck. Relays are overkill.

WhitehawkTailor commented 2 years ago

Just make sure that the power resources of the elements (sniffer, sniffed device and ISO1540) are independent. Do not attache the module that you want to sniffe to the VCC pin of the sniffer device. ISO1540 also should have its own pover suply, so do not either connect it to the VCC of the sniffer device.

ITstreet1 commented 2 years ago

schematic (2)

Mate, they are. Here you can see clearly.

While on wires, I have to disconnect VCC, SCL, and SDA. I thought VCC would be enough.

WhitehawkTailor commented 2 years ago

I can see now. The fet2 part causes the trouble. When it is switched of, or the sniffer is down, then SDCL2 and SDA2 lines flies away that causes the trouble for the sniffed device. I think you don't need the R9 and R10 at all. This function should be implemented on the working side that you want to observe. Just make sure your connection point on the I2C BUS is as close as possible to the observed device and don't use long wires.

ITstreet1 commented 2 years ago

For ISO1540 I made a schematic according to this: https://www.mikroe.com/i2c-isolator-click Without those resistors, it acts the same.

While I tested it a lot, I realize I must cut the SDA line when ESP32 is off. I think it can be done with a MOSFET or so. Do you have some suggestions? I am all ears.

Edit: As for wires, for testing, I use a standard jumper wire from an Uno to a PCA9535 with a 7seg display, and another jumper wire to this board I sent schematic. Just regular prototyping.

WhitehawkTailor commented 2 years ago

in my implementation I did not handle the Vcc and GND of the observed side. I just connected the 4 lines (Vcc, GND, SDC, SDA ) of he observed side to the ISO1540 and attached my ESP32 to the other side.

If you really want to switch all the four lines then try to find some multichannel low power switch for this purpose.

ITstreet1 commented 2 years ago

There will be times I had to reset or power off the ESP32. In that case, the observed device will just be held in the middle of the loop. That is why I have to cut VCC and now the SDA.

For testing purposes, I use MikroE I2C Isolator Click. There is a link few posts above. The problem occurs the same, on protoboard with this Click, and on my PCB with ISO1540 soldered on.

Edit: Can you please try this? Just make some simple LED blink on a PCF8574 or similar and see does this happens to you? In my case, when it blinks and I shut down ESP32, blinking stops, no matter on or off.

WhitehawkTailor commented 2 years ago

I don't have PCF8574. Are you sure that without the R9 , R10 and the whole fat2 part (R21, Q5, R24, Q4) it still makes trouble on the observed side? Theoretically you don't have to switch off (isolate) the observed side, since you have an isolator. The isolator makes that nothing goes back and harms the observed side. The only connection between the two side is the fat2 part. The other changes you made on the observed side is the two pull-up resistors (R9, R10). So get rid of them. These should solve the issue. Please confirm.

WhitehawkTailor commented 2 years ago

I think I know the reason why power off on sniffer side kills the observed side. When you power off the sniffer than the isolator seems to pull down the observed side lines. Can you measure the voltage level of the SDA2 and SDC2 lines when the sniffer side is powered off? If it is not on the ground then maybe the power off event on the sniffer side pulls down only temporarily the observed SDA2 and SDC2. Either way it is bad from the observed I2C master point of view, because only the master can initiate pull down first. This may cause the trouble.

ITstreet1 commented 2 years ago

Mate, you have a drink the first time you come to Belgrade!

The problem was, that I used MikroE I2C Isolator Click for testing and its schematic for a PCB. But on this click, there were 2 pull-up resistors on the observer side. They cause the problem while testing, and I tried to work around it on my design, not realizing that all I had to do is to remove those 2 resistors.

On the PCB I bypassed VCC2, removed pull-ups on the observer side, and it worked as expected. So far so good. No matter, I will order a new revision of the PCB. Hope it will arrive in a week or two.

Then, all that is left is the software. It worked last time as it sends the data to a server. But maybe to polish a thing or two. We will see.

I will post the schematic here later if some other needs it.

WhitehawkTailor commented 2 years ago

good news, congrats! I will keep it in my mind and will find you when I go to Belgrade, thanks :)

ITstreet1 commented 2 years ago

New boars arrived. That also means new problems...

In the previous revision, I had a circuit for switching 3.3V on the ISO1540 (the ESP32 side). I remove it in this newer version. But as SDA is tied on GPIO12 and with 1K on 3.3V it won't boot. GPIO12 is a bootstrap pin and the boot fails if pulled HIGH. On the previous design, 3.3V is there only after I write digital logic on fet pin.

There are a few questions... -do I need those pull-up resistors of 1K on ISO1540? -can I use another pin for SDA? -should I bring back this switch circuit on the 3.3V rail for ISO1540? -something else?

WhitehawkTailor commented 2 years ago

Hi, 1)pull up resistor on your side (R7, R8) are needed, but on the observed side it is not required, because the system you observes should already has it. 2)On ESP you can use any PIN for SDA and SDC that is free to use, just modify the program accordingly. Be careful to avoid special pins that are used for any other function. This part of the code need to e changed:

define PIN_SDA 12 //BLUE

define PIN_SCL 13 //Yellow

3) I don't see the necessity of the switch circuit part. 4) The only question is the ISO1540 operation. I think the issue is when you switch off your circuit part and this makes the ISO1540 to pulls down the observed SDA and SDC if the ISO1540 7PIn and 6PIN goes to ground or to any level that somehow interferes with the observed SDA or SDC. If you have an oscilloscope you could check the voltage level during operation or when your ESP side is switched off. Theoretically it should not work on this way. In case any Vcc goes under 2.1V the output should become Z. See the table of 8.5 Device Functional Modes in the bellow datasheet: https://www.ti.com/lit/ds/symlink/iso1540.pdf?ts=1651344550926&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FISO1540

But for some reason it seems that the situation is not the described. When you switch off the ESP what is the volt level on the observed side? Can you check it with an oscilloscope and see the transient if there is a small drop down or anything?

Does your observed device works if you switch on only that side and your observer ESP remains off? So the question is whether the switching off ESP side as a transient kills the observed side, or it can work only with the switched on ESP side?

ITstreet1 commented 2 years ago

After a bunch of testing with the PCA9535 as it has two ports and is a little bit more complex than the PCF8574, I get some issues.

Sniffing works as expected, board too. But the collected data is not what I expect.

It looks like the window when the ESP32 takes a picture is small. If I add two 7 seg displays and make it "blink" two numbers it doesn't capture whole segments at the time. Like it takes a capture while it hasn't turned on all segments. For PCA9535 I use an Uno and fire segment after segment in a loop, so it is obvious. Lib works this way.

So the question is, how can I make this window bigger? Should it mess the whole thing?

The sketch is here: https://github.com/ITstreet1/I2C-sniffer/blob/main/main_wifi.ino I didn't remove the fet part but it doesn't harm anything as there is nothing on the board.

WhitehawkTailor commented 2 years ago

my sniffer does not use any window. It is driven by the interrupts generated by the changes on the SDC and SDA lines. The only possible reason I can imagine to have less data to display is when the I2C communication is too fast comparing the speed how you send data from the buffer and the dataBuffer is overwriten.

This may happen if the WiFi communication is too slow comparing to the i2c data cycles. Try to increase the buffer size: static volatile byte dataBuffer[64000];

And also try to put the output to the serial first instead to WiFi. This can help to see if the WiFi communication time it too much comparing to i2c and that is why data gets overwritten after a while.

The problem could be that if I2C data is a continuous flow, than after a while it will produce more data than WiFi can send it over and the buffer will fill up and will overwrite the data in it. This will cause that you won't see the complete i2c communication just part of it.

WhitehawkTailor commented 2 years ago

more explanation There is no function to handle the situation when the databuffer is overwritten. The idea was to empty the buffer in the loop before it is filled up.

Anyway if the I2C communication provides more data than the loop can send it either to the console or to the WiFi channel than it will be overwritten and it also can cause problems too when it writes to a non registered area outside of the reserved buffer.

ITstreet1 commented 2 years ago

Ok. I finally managed to add my custom board to a board I want to sniff out. This board has a bunch of I2C devices while I tested on only one. So, there are additional problems.

Let's start from the start, shall we? This is what Serial prints out with a 6400 dataBuffer:

S0100000W+S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10011000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+00000001+01111111+01111111+0S0010000R+10000011+11111111-01111111+0S1010000W+1S0000010WS0111111S0000011R-0S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S1010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011s000S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111110-11111010S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+00001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111+11111111-S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+10100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+11111111+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000s1S0100000R+01111111+11111111-S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001S0011111R-10111111-10S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10000000+S0000100W+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10000000+S0000100W+S0010000W+0S0000000WsS0100000R+01111111+11111111-S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10000000+S0000100W+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10000000+S0000100W+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000010W-11111110-11111010S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10000000+S0000100W+S0010000W+0S0000000W+01100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10000000+S0000100W+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10000000+S0000100W+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10000000+S0000100W+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+00000001+01000000+0S0000100W+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10000000+S0000100W+S0010000W+0S0000000W+00000000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S1010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000010W-00010000-00010000S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11s110100S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S1010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+1S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W-11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111110-11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000010W-11111110-11111110S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W-11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111+11111111-S0010001R+1S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0000000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S1010000W+0S0000000W+00100000-00111111-01111111-S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S001S0000000S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S1010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+1101101S0000100W+100S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010011R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S1010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+00001111+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111110-11111110S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11s110100S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111WS0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+11111111+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111110-11111010S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10010000-00010000S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W-S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0100011W+S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111110+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10011000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+00000001+01000100+01000100+0S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11111010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100001+01111111+11111111-S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+1S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+1S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+SsS0100000W+S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+1S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+SsS0100000W+S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S1010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111110S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000010W-11111010-10110100S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111110+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0001111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011W+S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10000000+S0000100W+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10000000+S0000100W+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10000000+S0000100W+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S1010011W+0S0000001W+10000000+S0000100W+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10000000+S0000100W+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010SsS0100001W+S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10000000+S0000100W+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10000000+S0000100W+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S001000s100S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10000000+S0000100W+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000011W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10000000+S0000100W+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111S1010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10000000+S0000100W+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111+11111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111001+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100001+01111111+11111111-S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-01111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111S0111111W-0S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001S0000100W-0000S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000000W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111101+11011010+S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111100-10110100S0010000R+0S0000001W+11111111+11111101+S0010000W+0S0000001W+11111111+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0010001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+SsS0100111W+S0000001W+10001000+10001000+S0010000W+0S0000000W+00100000-00111111-01111111-1S0000001R+0S0000001W+11111111+11111111+S0010000R+0S0000001W+11111111+11111111+S0010000W+0S0000001W+S0111111R+S0000111R+S0010011R+0S0000001W+10001000+10001000+S0110000W+1S000

This is pretty much of an output. This resets the ESP32 after two readings.

Additional thing: I don't get data inserted into DB. This I still have to debug as it could be a problem in the DB, my PHP code, or something else.

What do you suggest I do?

WhitehawkTailor commented 2 years ago

Good news is that we have progress again. It seems there is a continuous communication on that observed I2C BUS.

The problem is that the sniffer writes faster the data than your program reads it. So after a while the buffer will be overloaded and the program writes data to area that is not allocated for the buffer. So it starts overwrite something, that is why the ESP32 will collapse after a while.

The program is not perfect, I did not prepared it for such situation that you have. In my use case the communication went rarely, so there was time to write out the buffer and reset it.

It can be fixed by pausing the observation, while the buffer is not empty again. You can also increase the buffer size even for couple of mega byte depending on you r ESP32 setup.

What really strange for me is that there is no stop sign in the data flow. S is the START s is the stop. It could be a program issue or something strange on the communication.

I am sure this code would need a revisit, but I have no time at the moment. A couple of week from now I may have chance to review this issue again.

Meanwhile you could check the I2C protocol and create a parser for the data flow.

I cannot help in the DB issue, since I don't know your code.

ITstreet1 commented 2 years ago

After a few attempts, I realize the URI is way too big (414 code). Maybe to cut down the dataBuffer?

ITstreet1 commented 2 years ago

Ok, tried with a smaller buffer, and ESP goes into reset all the time. With a bigger buffer, it can not go through the URL as a GET request. Just it is a big URL address. I get URI too long (414).

There could be a few solutions.

I think this could be an interesting project for others when finished. I just don't believe I am the only one who needs to spy on one device's I2C lines and get data from it.

Edit: Just check it out. Through URL it can go only some 25% of the whole reading from above.

WhitehawkTailor commented 2 years ago

A usual ESP32 has something like 4Mega byte memory. About a 2Mega form the 4 can be used as a file system and you can write data there. But the problem remains the same. More data coming than you can send it out. So sooner or later file system will be full too.

Filtering the address can help, but this should be implemented. Filtering helps in case you can send more data than you receives, otherwise the problem is the same.

Use POST instead of GET when sending, because GET has the limit.

In a few weeks I can start working on the code:

check the missing stop issue implement the address filtering handle the buffer overwrite situation pause feature

ITstreet1 commented 2 years ago

I have a working solution for filtering. I have posted it somewhere here, LOL. I can post it here again. Maybe those two sketches could be joined together.

It would be much easier to just cut all addresses but one. That means I will send to DB only what I need. If I send it all, then I will have to filer it on the server. Much fewer problems to filter it on the ESP.

WhitehawkTailor commented 2 years ago

You are right saying that it is easier to filter at the source. The only thing is the computing capacity. If it will need too much time than the whole operation will slow down.

Anyway I will develop the filter capability that will be optional. But in case the targeted source address will produce too much data you will have the same problem. We will see.

I don't see the code you posted. Where is it?

ITstreet1 commented 2 years ago

It is at the top: https://github.com/WhitehawkTailor/I2C-sniffer/issues/1#issuecomment-1001592140

WhitehawkTailor commented 2 years ago

OK, thanks

ITstreet1 commented 2 years ago

I have a proposal for you. Feel free to contact me on dekip[at]beotel.rs