Until now I used Arduinos with shields and ICs and mostly I used libraries to communicate with i.e. ADC, DAC, Real Time Clock, etc.

Now I want to do the same kind of programming with the same ICs with the ESP32 and ESP-IDF framework. But often there are no libraries so I have to do this from scratch. This is obviously different from Arduino programming and I have to learn how to use APIs for i.e. SPI, I2C and other protocols.

The problem which I see is how to do this right. Let's say I want to communicate with an ADC IC with SPI. This needs a couple of lines of code to configure the ADC and then to request data and read this data. And if one line is not 100% correct then it "wont work". I will likely only see that it does not work but I won't know why it does not work and what I did wrong.

Now my idea is to use a logic analyzer and record the electrical signals between and Arduino and an ADC IC. I know this works so then I have a sample how the signals should look like.

And then, when I start to program something similar with the ESP32 and ESP-IDF, I can also record the electrical signals and compare them with the signals from the Arduino. I guess with this method I should be able to see which programming lines do what I expect and which are wrong.

Is this a good way to do this? Or are there better and maybe easier ways to write and analyze low level code like this?

Is a logic analyzer a good tool to write and debug low level code?


A logic analyzer is a useful piece of equipment to have on the lab bench. However, looking at how the signals look for an existing device then copying it is bush league unless you are reverse engineering something. If you're hooking up an Arduino or some other uC to some other device, you should be looking at the datasheets first, and grabbing out the probes last. Reason being is that the signal behavior you see won't necessarily be what you want to duplicate when you want to do something new, and only reading the datasheet will tell you what those aspects are. Additionally, on some device at high speeds, connecting your probes can affect the signal characteristics enough to make the device not function, unless you are careful to use the right set of probes.

I can empathize that until you've had a lot of experience it can seem like a lot of variables to flip around to get something working, and a piece of lab equipment is great for getting a feel for how things work. However you shouldn't expect to use it as the first step in wiring up an SPI device, or other device for that matter. You should expect to get to the state where you can get the SPI settings right on the first try, purely by looking at the data sheets.

With that said, if you can, you should pony up the cash to get a mixed-signal, or even better mixed-domain oscilloscope, rather than something calling itself a logic analyzer. The scope will provide much more utility. In the embedded world, digital signals are also analog signals, and at high speeds the analog components of your signals can start to cause trouble, and a logic analyzer won't be able to help with that. While 4 analog channels is enough for debugging SPI for an Arduino, many respectable MSO scopes have the option for additional digital channels, which allows you to use the device as the logic analyzer functions. Many can also do convenience functions like decoding many protocols like SPI or UARTS or even USB.

If the day comes that you need a proper logic analyzer with all the tools that you can't get on the MSO scopes, by that point you won't be programming arduinos.

  • Thanks. In the moment I use a cheap logic analyzer with this software sigrok.org And I also just bough a 70USD oscilloscope. It's not perfect but it should help me to get started. EEVblog Dave tested it recently: youtube.com/watch?v=SIH48bIUU00
    – Edgar
    Dec 12 '19 at 5:00
  • @Edgar: from looking at that video, that scope looks super dodgy. Next time get good tools the first time. Buy once, cry once. Dec 12 '19 at 5:13
  • In principle I agree with you about buy once... But in the moment this is just a hobby for me and with limited money I don't want to spend lots of money on tools which I like but which I would use only from time to time for a hobby. That oscilloscope is my first one and I guess I will learn the basics with it. When I really NEED a better one then I guess I will find the money somewhere.
    – Edgar
    Dec 12 '19 at 6:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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