4 ms·
Agreed, the ESP32 ecosystem is a stellar example of what MCU vendors could offer.
by flqn 6y ago
Agreed, the ESP32 ecosystem is a stellar example of what MCU vendors could offer.
- sgtnoodle 6y agoWhen I used it for a hobby project, it was pretty gnarly. All I wanted to do was sample an ADC channel at 8Khz. The software triggered ADC proved to be fundamentally broken (it felt like a race condition in their lower level coprocessor), and I had to switch to I2S so that the ADC would be accessed by DMA. The documentation was basically non-existent and the most relevant code examples were an incoherent mess. I eventually got it to work barely well enough, after probably spending 16 hours on it. I'm still impressed with the wifi functionality. It's a cool chip, and I appreciate the company's willingness to support hobbiests. I wouldn't use their SDK as the reference for a particularly good vendor support package, though. On the other hand, maybe there are no good vendor support packages and ESP32 is one of the least worst?
- elcritch 6y agoI've had similar experience with the ESP-IDF, with racey bugs in certain parts and broken i2c, etc. Though turns out most of those were due to their v4.1 branch being listed as stable (AFAICT) but it's actually pretty broken. Switched to v4.0 and everything works. Still it's open source and the dev's will respond to GitHub issues. Overall I'd say it's not too bad, or not so much worse than other chips. It seems every piece of embedded hardware will have quirks and the SDK's will have pain points. From what I gather and my limited experience, it's more a matter of how many and how severe. I prefer at least an open source SDK where it's possible to share patches with the broader community. From what I gather here and elsewhere the only other open source SDK's are for the Nordic chips. P.S. the esp32's ADC supposedly has terrible calibration issues.
- sgtnoodle 6y agoI used the ESP32 to build a two lead ECG SD logger with real time viewing over wifi. I randomly had to get a pacemaker this year, and it's been very useful to self-diagnose device issues (such as why my heart rate was jumping back and forth between 50bpm and 100bpm!) The pacemaker generates 350uS 2V "capture pulses", and they're very easy to detect coming out of an analog ECG amplifier front end. The ESP32 would completely miss maybe 1 out of every 5 capture pulses until I switched to I2S. Now it reliably samples every single pulse. The data coming out is good enough to see what I need to see; qualitatively how my heart is beating. When using software triggered ADC conversions via an 8Khz timer interrupt, the racey issue would occur periodically for several milliseconds at a time. The ADC would act as if its input was disconnected and floating. With a changing input signal, the samples would read as a nearly constant voltage and completely miss blips that were well within the Nyquist frequency. Switching to I2S/DMA seemed to work around that issue. Even with the ADC working reliably, the samples suffer from what I can only guess is horrendous differential non-linearity. The waveform really looks quite ugly, despite the ADC being driven by a very low impedance amplifier output. At least I can clean up the ECG plots with a low pass filter to make them pretty. The pacemaker pulse is a 350uS square wave, but the heart's natural impulses are significantly lower frequency.
- elcritch 6y agoFantastic that you're able to track down your health issues. One day I really want to get into making health tracking sensors. Oh I've read about the ESP32 ADC being pretty non-linear, but the racey issues are new to me. Do you have example code/repo for how you use the I2S to read the ADC? I'd like to add it to my ESP32 wrapper library (see `elcritch/Nesper` on GitHub)). It's mostly started as Nim wrapper's for the ESP-IDF api's, but it is letting me wrap certain errors conditions in the ESP-IDF and configure workarounds. Mostly small stuff, but handy.
- sgtnoodle 6y agoDue to all the medical scans I've had done, I can confidently say that my heart is in perfect health other than the nerves being flaky. The pacemaker is a nearly flawless replacement, but it has its technical limitations. It's been very handy to see what's going on when my heart is beating funny. Here's the relevant section. I was getting pretty fed up with battling the ESP32, so it's probably not the prettiest. http://sgtnoodle.com/files/adc_snippet.txt http://sgtnoodle.com/files/adc_snippet.txt The function runs as an RTOS task, woken up once every millisecond by a timer. I also pinned it to one of the two CPUs because I was originally doing software triggered sampling at 8Khz. The timer and pinning is rather overkill since I2S clocks the sampling and has tons of buffer. In an effort to get better data, I have the I2S sample at 40Khz. The function copies the samples out the I2S buffers, and down-samples to 8Khz. The 8Kz samples are pushed into a circular buffer that uses a std::atomic head pointer to make it thread safex.
- elcritch 6y agoThanks! I'll take a look at it and try and port it over. Hopefully it'll help some other poor souls (possibly myself) who have to deal with the same issues.