Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 16:51 05 Sep 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Pico as I2C sniffer ?

Author Message
58kk90
Regular Member

Joined: 14/06/2023
Location: United Kingdom
Posts: 80
Posted: 07:55am 29 Aug 2026
Copy link to clipboard 
Print this post

I urgently need to capture some data between a piece of old test equipment and it's battery.
Looking on the scope I believe it to be either SMbus or I2C which are essentially very similar as far as I can tell for just two devices on the bus.
I am not at home currently so I don't have access here to logic analyser or bus pirate, but I do have a couple of Pi Pico's in my laptop bag, does anyone have any quick and dirty code to sniff I2C data and output it to raw bytes to the terminal?

Tony
 
mozzie
Guru

Joined: 15/06/2020
Location: Australia
Posts: 429
Posted: 08:11am 29 Aug 2026
Copy link to clipboard 
Print this post

G'day Tony,
Can you ascertain the clock frequency from the scope, if so you could try:

Assuming the battery is the slave:
Hook up a PicoMite to CLK/DAT
Set system I2C
Use LIST SYSTEM I2C to find address of battery

If that works then:
Hook up PicoMite to CLK/DAT via 22K series resistors
Connect battery to device
Set PicoMite as slave at battery address
Use Interrupts to see what is sent

I have done something similar to get touch info from a touchscreen controller but it took a fair bit of stuffing around.

Someone will likely chime in with a better solution using PIO etc  

Regards, Lyle.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 3374
Posted: 08:40am 29 Aug 2026
Copy link to clipboard 
Print this post

Mozzie is on to something with the PIO idea. In the manual Appendix F, The PIO Programming Package, EXAMPLE PROGRAM 3 is a basic logic analyser that could probably be adapted to do what you want.

For a more comprehensive logic analyser search Volhout's posts.

Here it is
Edited 2026-08-29 18:54 by phil99
 
58kk90
Regular Member

Joined: 14/06/2023
Location: United Kingdom
Posts: 80
Posted: 10:02am 29 Aug 2026
Copy link to clipboard 
Print this post

@Mozzie, the clock frequency seems to be just about 20KHz, I'll try and find the battery I2C address using the List System I2C as you suggest, that would be a starting point I guess, then I could do as you suggest  capturing the data, but I'm not sure how the Pico I2C slave code would deal with the acknowledges  as the Pico would be on the same I2C address as the battery.
I'll do a bit of poking around and update later.
@phill99, the PIO is waay above my level  of programming, but i'll take a look and see if I can make sense of it.

If only i'd have my Buspirate in the laptop bag, it would be quick and easy!

Tony
 
Volhout

Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 6088
Posted: 02:54pm 29 Aug 2026
Copy link to clipboard 
Print this post

Hi,

Use the PicoLA (picomite logic analyzer for PicoMiteVGA.
You can trigger on start condition, and it has a built in I2C decoder.
In the help menu it shows where to connect SDA and SCL.

PicoLA



Alternatively you can use SCOPPY (the free version). It has a built in logic analyzer, and 2 channel scope.

Volhout

Volhout
Edited 2026-08-30 00:56 by Volhout
PicomiteVGA PETSCII ROBOTS
 
mozzie
Guru

Joined: 15/06/2020
Location: Australia
Posts: 429
Posted: 03:23pm 29 Aug 2026
Copy link to clipboard 
Print this post

G'day,
With a 20khz clock frequency I would guess its SMBus, pretty sure a lot of the power tool batteries use this.

SMBus_made_Simple_slua475.pdf

Volhouts Pico_LA logic analyzer looks like the answer here   am going to load it up and take it for a spin myself, Thanks Volhout  

Regards, Lyle.
 
Volhout

Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 6088
Posted: 03:29pm 29 Aug 2026
Copy link to clipboard 
Print this post

LA26.zip

The latest. Runs on V60302.

Maybe I finally will start looking at integrating other decoders (SPI/UART) (**). It has been 3 years, and since I only kept it compatible with evolving MMBasic.
Should also work on HDMI.

If you have no sound attached to GP6/7 you can change the define at line 55 of the program to enable channels 7 and 8. You will also have to disable the built in test pattern generator in the program (comment line 61).

Volhout
(**) LA uses quite a lot of heap, and only recently improvement has been on heap for the 2040 VGA. Maybe there is enough room now to add features.
Edited 2026-08-30 01:37 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Volhout

Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 6088
Posted: 03:46pm 29 Aug 2026
Copy link to clipboard 
Print this post

If you only have a pico (the module), and no VGA/HDMI, use SCOPPY.
You can install scoppy in a pico, connect it through a USB cable to your (android) phone, install the scoppy app on the phone.
If you have a pico-W, you can also connect the phone through WIFI.

Not sure how far the "free" version goes (decoding I2C). But you can for sure see the waveforms on scope , and use the logic analyzer built in.

Volhout
Edited 2026-08-30 01:48 by Volhout
PicomiteVGA PETSCII ROBOTS
 
58kk90
Regular Member

Joined: 14/06/2023
Location: United Kingdom
Posts: 80
Posted: 05:35am 02 Sep 2026
Copy link to clipboard 
Print this post

Apologies all for the delay in replying, and just to follow up the thread, in the end , mainly due to time constraints, we grabbed a cheap and cheerful logic analyser from Amazon (less than 15UK pounds), delivered next day and used that.
Easily managed to grab all the data I needed, the protocol does appear to be SMBUS looking at the timings, so next job now is to write some code to 'emulate' the battery.

Thank you to all who replied and offered suggestions.

Tony
 
ville56
Guru

Joined: 08/06/2022
Location: Austria
Posts: 584
Posted: 06:24am 02 Sep 2026
Copy link to clipboard 
Print this post

instead of writing your own decoder, you may try to use the PulseView decoder from Sigrok. It's free and it works fine with many hardware LA. I use the el cheapo from china with 8 channels and USB for around 10€ for work with the Pico. As SMBUS is similar to I2C (a subset more or less) you may be able to decode your data off the shelf.
I've also modified the serial decoder as I did want to have a different way of displaying the data. It was easy to do as the decoders (hopefully all) are written in python. So you may tweak the I2C decoder for SMbus if you dare to. And the logic was not to hard to understand for me.

There are some explanaitions on the web how to install the Zadig USB driver in Windows. That has to be done once, but is easy AFAIR.

There are also ports for Linux and MacOS on their website.

Gerald
Edited 2026-09-02 16:25 by ville56
                                                                 
73 de OE1HGA, Gerald
 
Volhout

Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 6088
Posted: 06:36am 02 Sep 2026
Copy link to clipboard 
Print this post

Hi Tony,

From your post, I assumed you where on site, where you could not get access to other hardware. That you had to do with what was in your tools box.

Yes, ordering a cheap SALEAE clone, and running their PC tools (free for 8 channel units) is by far the easiest option. It has 10 protocol decoders, and is plenty fast for I2C/SMBUS (24MHz).

Volhout.
PicomiteVGA PETSCII ROBOTS
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026