←back to thread

76 points todsacerdoti | 7 comments | | HN request time: 0.215s | source | bottom
1. arghwhat ◴[] No.43684165[source]
Go for the SPI version, which is the same chip but just s different breakout board.

Many ESP32's can only do 400kHz I2C, whereas their SPI peripheral can often do 80 MHz or more (although you wouldn't want to go that fast here). 400kHz sort of works, but if you also want to handle other I2C devices it can easily become a problem.

replies(2): >>43684255 #>>43684297 #
2. grmnygrmny2 ◴[] No.43684255[source]
(author here) I've been pondering this, yeah. I'm currently sharing the I2C bus with a DAC and that's working alright, but the refresh rate issue is enough to make me consider SPI. I know the SPI peripheral supports DMA as well, and the I2C one doesn't (sort of? I know there's "async" transmit now but can't tell if that's really doing DMA)
replies(2): >>43685194 #>>43689251 #
3. generj ◴[] No.43684297[source]
I2C is nice because it is (with Adafruit and Sparkfun’s Stemma QT/Qwiik) literally plug and play for beginners, with a wide variety of sensors available.

Plus not needing to dedicate a control pin per device added to the bus. Though of course if data throughout is an issue SPI is better than I2C.

replies(2): >>43684823 #>>43685955 #
4. arghwhat ◴[] No.43684823[source]
I2C is fine for sensors and other low-bandwidth devices, but inappropriate for displays and other high-bandwidth devices.

When used with those kits, you'd use the QWIIC/whatever connector for all the sensors and other low-bandwidth things like I2C is meant for, while the display would be connected with SPI.

(I2C isn't more plug and play than SPI though, and a preterminated plug shouldn't be a big deal.)

5. arghwhat ◴[] No.43685194[source]
The I2C peripheral is DMA - a write just queues an operation descriptor in a hardware FIFO, and interrupts fire whenever something exciting happens or the FIFO is drained. The synchronous implementation is just blocking on a condition set by the interrupt handler.

But this is exactly the kind of thing the SPI peripheral is meant for. This cannot be said for the I2C peripheral, with its measly fast mode support.

Depending on the chip and your usecase, you might also want to use I2S for your DAC.

replies(1): >>43685944 #
6. grmnygrmny2 ◴[] No.43685944{3}[source]
Ah! That makes sense, thanks!

And yes, the audio data runs over I2S - the chip I’m using just uses I2C for control.

7. hadlock ◴[] No.43685955[source]
If you're going to do I2C just get an LCD display. This OLED can be driven at 150fps by simple devices like an ardunio which is where it really shines - super crisp, high contrast, smoove as buttah graphics for realtime readouts etc. OLED over SPI is really visually impressive stuff and effectively 0 latency. Using the SSD1306 for static displays over I2C is almost a crime.