Ramblings of an aging IT geek
← Ramblings of an aging IT geek
hardware

i finally bought a logic analyser, and the bus stopped lying to me

A cheap logic analyser and sigrok turned a flaky I2C sensor from guesswork into a readable trace that showed the bus address was simply wrong.

A soldering iron and electronics on a workbench

I'd been bodging an I2C sensor for a fortnight, reading nothing but zeroes and blaming, in order, the wiring, the pull-ups, the library, and finally the sensor itself. What I should have done at the start was actually look at the bus, instead of guessing what was on it.

So I gave in and bought one of those eight-channel USB logic analysers, the cheap clone everyone has in a drawer. Clipped the probes onto SDA and SCL, fired up sigrok with the I2C decoder, and there it was: every start, every byte, every ack, laid out as readable hex instead of a mystery.

The fault took about thirty seconds to find. I was writing to the address from the datasheet's example, which had the read/write bit already shifted in, on top of a library that does the shift for itself. So I was talking to an address that wasn't there, and the bus was politely returning nothing. No ack, no data, no error I'd notice. The analyser showed the wrong address on the wire in plain hex, and that was the whole argument over.

I feel slightly foolish for not buying one years ago. When you can see the signal you stop debugging by superstition. The sensor was fine the entire time, which I suspected and now actually know.