banner

Blog

Jul 19, 2023

The Connector Zoo: I2C Ecosystems

I2C is a wonderful interface. With four wires and only two GPIOs, you can connect a whole lot of sensors and devices – in parallel, at that! You will see I2C used basically everywhere, in every phone, laptop, desktop, and any device with more than a few ICs inside of it – and most microcontrollers have I2C support baked into their hardware. As a result, there’s a myriad of interesting and useful devices you can use I2C with. Occasionally, maker-facing companies create plug-and-play interfaces for the I2C device breakouts they produce, with standardized pinouts and connectors.

Following a standard pinout is way better than inventing your own, and your experience with inconsistent pin header pinouts on generic I2C modules from China will surely reflect that. Wouldn’t it be wonderful if you could just plug a single I2C-carrying connector into an MPU9050, MLX90614 or HMC5883L breakout you bought for a few dollars, as opposed to the usual hurdle of looking at the module’s silkscreen, soldering pin headers onto it and carefully arranging female headers onto the correct pins?

As with any standard, when it comes to I2C-on-a-connector conventions, you would correctly guess that there’s more than one, and they all have their pros and cons. There aren’t quite fifteen, but there’s definitely six-and-a-half! They’re mostly inter-compatible, and making use of them means that you can access some pretty powerful peripherals easily. Let’s start with the two ecosystems that only have minor differences, and that you’ll encounter the most!

There’s two ecosystems of I2C modules that are based on four-pin JST-SH (1mm pitch) connectors, and they’re very interchangeable! One of them is Sparkfun’s QWIIC, and other is Adafruit’s STEMMA QT (pronounced ‘cutie’). Both of them are straightforward to add to your PCB, as long as you have a few JST-SH four-pin connectors ready. What’s more – Adafruit and Sparkfun connectors have the same pinout!

The connectors being used are JST-SH, surface-mount, with 1 mm pitch. Their JST family is SR/SH and the part number for the original JST part is SM04B-SRSS-TB, but you can find cheap third-party connectors with the same dimensions on LCSC using “1x4P SH 1mm” search terms. Both QWIIC and STEMMA have pages to refer to when doing your own designs. Now, what are the differences between the two?

QWIIC limits itself to 3.3 V on both host (i.e. MCU board, providing power) and device (i.e. sensor, consuming power) side – a reasonable decision, simplifying things a lot. An overwhelming majority of devices we work with nowadays are 3.3 V, to the point where level-shifting problems are mostly unheard of. Perhaps, the eventual move to 1.8 V will shake that up, but we are not there yet, and factors like LED forward voltages will necessitate some kind of higher-than-1.8 V reference in our project when we get there, anyway. So, 3.3 V power and two 3.3 V logic level I2C signals on a single connector – plain and simple. Chances are, you can already add QWIIC to your sensor or MCU board – without any additional components required but the connector itself!

In contrast, STEMMA QT is built to expand on the possible educational and convenience value, in line with other Adafruit offerings. As such, it allows for 5 V hosts – with devices designed to work in the 3.3 V-5 V power and logic level range, making sure that your Arduino Uno is not left out of the game. This is possible because every module has a low-dropout voltage regulator like the AP2112K or the MIC5219, which helps keep things almost-3.3 V when you feed the board with 3.3 V. The reasoning is simple – apart from 5 V hosts like Arduino Uno, you might also want to chain your STEMMA devices with some power hungry-devices, like I2C-savvy servos or RGB strips. In short, plugging anything into anything, with any kind of chain, shouldn’t result in magic smoke escaping – an event rarely on the TODO list of a maker’s project. One more upside of STEMMA QT is standardization of device board sizes, letting you easily mechanically integrate new sensors into the project before they even arrive to you, and spawning nifty hacks like this STEMMA Qt 3D-printable hotswap socket!

To sum up the voltage compatibility situation – all STEMMA QT devices will work with QWIIC hosts; and all QWIIC devices will work with 3.3 V STEMMA Qt hosts; as a result, any QWIIC host is also technically a STEMMA QT host. QWIIC devices will be fiercely incompatible with 5 V STEMMA QT hosts, but such hosts are rare, and you just have to be on the lookout when interfacing QWIIC devices with STEMMA hosts. Another minor hiccup with both of these standards is lack of interrupt signals – that, I will expand on below, in the “Breakout Garden” section. For now, let’s take a look at STEMMA QT’s bigger sister!

Oh, right, chaining! Both QWIIC and STEMMA QT are chaining-friendly – many modules offering a second JST-SH connector on the opposite side of the board, with the same signals passed through. This lets you wire up your projects in a comfortable way, not having to locate a spot in your project where you can put your MCU while not having it too far from all of your sensors, or not resorting to breadboards for splitting your I2C bus into multiple stubs. Many host boards also offer multiple sockets wired in parallel, and there’s “splitter” boards available that turn a single JST-SH cable with I2C into, say, three extra sockets.

As long as your addresses don’t conflict, you will generally be fine wiring an I2C bus for a project in such a way. Oh, and make sure to not overload your I2C bus with all the pullups added in parallel – they tend to be 10 kΩ for STEMMA QT and 2.2 kΩ for QWIIC, and at least in case of QWIIC, it seems you’re typically able to cut two trace jumpers with an xacto knife to disconnect the pullups on any module. With all non-Pico-based Raspberry Pi boards having 1.8 kΩ onboard pullups on their I2C ports, you might find yourself needing to do that quite early on as you chain devices.

STEMMA has the same pinout as STEMMA QT and QWIIC, but a different, larger connector. It, too, is flexible when it comes to voltages you can output on the host end, and in turn, must be able to accept on the device end. Most of the advantages in STEMMA QT section apply to STEMMA, save for QWIIC compatibility and reduced physical size.

STEMMA connectors are JST PH connectors with 2 mm pitch, with JST part number being S4B-PH-SM4-TB, and cheap third-party connectors available with “1x4P PH 2mm” search terms. They’re a bit easier to tackle with a soldering iron than the 1 mm pitch SH connectors, and for larger boards, they’re a good fit.

JST-PH is one of those cases where surface-mount sockets turn out to be way more resilient than the through-hole ones. With a tougher retention mechanism, your fingernails will no longer suffice – you’ll likely want to use your trusty pair of blue flush cutters for unplugging these! I2C-carrying STEMMA also has an GPIO and analog STEMMA counterpart, using 3-pin JST PH connectors for things like WS2812 strips – where 5 V compatibility becomes exceptionally handy. However, 4-pin connectors are firmly reserved for I2C, and such consistency is hard to not appreciate in educational and prototyping environments – checking the dozens of tutorials Adafruit has involving STEMMA devices, the “Wiring” sections in those are extra straightforward! On some STEMMA hosts, you will also be able to rewire the port to either 3.3 V or 5 V through a solder jumper.

The Grove connector standard, oldest of them all, is now somewhat of a black sheep among the I2C connector ecosystems, and is here half as a piece of history, half as a cautionary tale. Contrary to principles of open-source ecosystems, Grove uses a proprietary connector, which has makers scramble for its proper identification as they try to find a source that is not SeeedStudio. Unlike all the other standards listed here, when you see a 4-pin Grove connector, you don’t know if it’s for I2C, UART, two digital GPIOs or something analog, which ruins the whole “plug and play” idea.

To those of you unfortunate to have to interface with Grove, it also uses 3.3 V – 5 V range of possible voltages, but is less interested in explicitly advertising which one is used, or letting you change that – both things that STEMMA does without breaking a sweat. It uses the same pinout for I2C as QWIIC/STEMMA do. If you have a STEMMA-compatible (JST-PH) cable, you can sand it down a bit to make it fit into a Grove connector.

In other words, there’s a good reason you don’t see Grove connectors used more often. I couldn’t help but notice that Tom’s Hardware, when writing the conclusion section of their own I2C connector ecosystem overview article, failed to find an advantage of Grove that wasn’t generic to every other ecosystem they talked about. Unless you want to resign to paying SeeedStudio for every connector and cable you ever need, and are okay never being compatible with connector ecosystems worth investing effort into, I strongly recommend you avoid using Grove on your boards. Let’s spend time on the next – underappreciated – option instead.

The Breakout Garden ecosystem by Pimoroni uses an elegant pinout – taking a row of five pins off the Raspberry Pi GPIO header, pins 1 to 9, including 3.3 V, SDA, SCL, a GPIO pin and, of course, GND – in this order. They sure don’t hold a patent to this pinout – a whole lot of hackers, myself included, have been using this pinout for ages on our I2C-equipped boards. Such a pinout, for a start, means that you can plug any Breakout Garden board onto a Raspberry Pi directly.

You’re not limited to that, either – Pimoroni also offers nice slide-in connectors that let you hotswap Breakout Garden modules. And, if you don’t want to use the slide-in sockets, just solder angled male pin headers and treat them like any other module. Breakout Garden modules typically have a 3.3 V – 5 V input voltage range. They also claim reverse polarity protection on every module, so, inevitably plugging a module backwards shouldn’t delay your project.

With the Breakout Garden pinout, you also get an extra GPIO, which is most commonly either NC or used as an interrupt pin. Interrupt pins are under-appreciated when working with I2C devices – they let you offload your CPU and your I2C bus, avoiding polling and letting your I2C peripheral signal you when it wants your attention, something not possible through the I2C bus alone. For a few modules, like this haptic actuator driver, the GPIO is used as a “trigger” pin instead, for action synchronisation. That does hurt the concept of chaining somewhat, of course – to be fair, though, so does the bulky hotswap socket. Not that you can’t connect Breakout Garden boards in parallel – after all, INT pin is typically disable-able for I2C devices, which will absolutely come handy, given the the puzzling decision of wiring all the INT pins together on their 6-socket Raspberry Pi HAT.

Adding basic support for “Breakout Garden”-like connection in your project is as simple as adding a five-pin 2.54mm (0.1″) pin header – and with that, you instantly get Raspberry Pi GPIO header compatibility. When it comes to creating your own modules, I couldn’t find any dimensions or an official “how to create” modules, so you’re probably not meant to do that – which doesn’t mean that you can’t reverse-engineer the schematics and the dimensions and then try anyway, but it sure is quite discouraging. If you want to add a Breakout Garden socket, they have two rows of pins that are exactly 5.08mm (0.2″) apart, and provide convenient plug & play connectivity, though with the cost of £1 per socket (not including shipping), the slide-in sockets are the most expensive to use of these all.

In the market for some JST-SH accessories? You really can’t go wrong with the SMD connectors; however, you absolutely can go wrong when it comes to pre-crimped cables. Crimping JST-SH with its 1 mm pitch is far from easy, and buying your own cables is your best bet – except for when they come miswired. A year ago, I was preparing for a project and bought a bundle of JST-SH cables, pictured to the right. Upon closer inspection, something felt off.

Turned out that they had their cable ends wired in the opposite direction, one’s pinout reverse to that of the other – with likely disastrous consequences when used as an interconnect. The cables I bought will require some careful rewiring with tweezers, and next time you are shopping for third-party JST-SH cables so that you can wire up your next project, you will know to inspect the pictures before pressing the “Buy Now” button.

If you’ve ever worked with DFRobot parts, you might’ve seen JST-PH 4-pin (or 3-pin) connectors on their boards, too – they’re from their ecosystem called Gravity. Puzzlingly enough, Adafruit claims that STEMMA is compatible with Gravity, apart from their non-I2C devices – since Gravity does the same thing that Grove does, where a 4-pin connector doesn’t guarantee I2C. However, checking the pinout for Gravity I2C devices, it seems that every single pin is in a different spot, in particular, ground and power being reversed. Just like STEMMA, they use 3-pin connectors for digital and analog devices. The fun part is, they also managed to change the pinout for those at some point, also reversing the power pin polarity – while still using the same connector, a no-no for connector standards. Proceed with caution!

EasyC is basically QWIIC copied to a T, with the same pinout, connectors, chaining abilities and 3.3 V voltage limit – but not mentioning QWIIC in any way in their webpages and resources, which is a disappointment. Interoperability of different ecosystems is part of what makes them valuable, and arguably, you could be more inclined to buy from them if you knew that the standard they’re using is a widely accepted one – as opposed to “random pinout on some connector”. EasyC is driven by a Croatia-based e-radionica company, producing a medium-sized assortment of useful modules, including quite a few Chinese module clones and remixes – at European prices. Design files for their modules are not linked to from product files, but at least some of them seem to be on their GitHub! Interestingly enough, they also stock a 5cm “EasyC” cable which, upon closer inspection, has the same reversed wiring as the cables I told about in the previous section. Perhaps, putting a bit more thought into the EasyC ecosystem would be warranted.

Sometimes we see companies making an attempt at a JST-SH thing, but not quite getting there. An example of that is a somewhat recent board by Lolin, the Lolin D1 Mini Pro, with a JST-SH 4-pin connector on it labelled “I2C”. You could be forgiven for thinking that this is a QWIIC-like pinout; given that this connector is marked “I2C”, one could argue they’ve been tricked, backstabbed and quite possibly, bamboozled. Instead of GND-VCC-SDA-SCL pinout, this board is using GND-SDA-SCL-VCC, and it appears there’s even a few accessories like shields made with this pinout in mind. It’s as if someone sent Lolin a letter saying “hey, you should put I2C on a JST-SH connector” and then refused to elaborate further. Thankfully, with the GND pins matching, the likelihood of destroying things is not as extreme.

Which one of the standards should you follow when designing your own boards? I have provided you with all the information you could ever need to make your own decisions, but if you’re looking for a recommendation or a guideline, I will happily provide one, too.

I personally don’t use full-sized STEMMA (JST-PH) connectors, as way too often, they’re bulky enough to make the PCB itself seem small, and can make small boards a bit unwieldy due to their height – plus, they can be harder to unplug. The JST-SH connectors, however, are way too enticing due to the prospect of being compatible with two ecosystems at once, as long as I avoid 5V hosts. And – a simple, standard pinout 5-pin header provides a surprising amount of benefits for how quickly you can add it!

In short, I recommend that you combine a Breakout Garden-like pin header and the QWIIC/STEMMA QT JST-SH connector on your boards. This way, you will always have compatibility with three out of the four ecosystems worth talking about, and connecting your I2C board to a Raspberry Pi will be as straightforward as getting five jumper cables. With this combination, you will never have to think about I2C header pinouts ever again, and you’ll have an interrupt signal handy for the times when you really could use one.

Do you have to add level shifting? Not if you don’t use 5 V in your projects, and especially not if you’re making a breakout for an IC that has a wide range of input voltages, like, say, I2C EEPROMs and RTCs. I personally work with mainly 3.3 V, and I don’t have reels of AP2112 regulators to sprinkle on every board I make – thankfully, I don’t have 5V I2C hosts, either. In case you do want to make your devices 5 V-compatible, you can’t go wrong with the classic, incredibly elegant, and inexpensive MOSFET solution for I2C level shifting!

Out of these, QWIIC, STEMMA and Breakout Garden have so far stood the test of time, with hobbyist electronics companies backing them all the way there. It is only fair that we benefit from the standards they created. Hopefully, the insights and the instructions provided get us closer to universal interoperability days, when one hacker’s MCU board can seamlessly interface with other hacker’s sensors. From there, one day, our favourite SSD1306 OLED breakouts might start arriving into our mailboxes equipped with a JST-SH connector and an extra cable. Today is not that day, but with every JST-SH footprint we add to our PCB, I believe we will see to it soon.

SHARE