I am looking for (reasonably easy to use and well tested) alternatives to the Wire library. Wire works very well, but: I only need the Arduino to act as I2C master and the Wire library seems to be a real waste of resources:

My goal is to send out data en bloc (e.g. 32 or 64 bytes). This data is already sitting in an array in SRAM. Now when you use the Wire library, you call the TwoWire::write function which copies your data into a 2nd buffer. Afterwards, Wire makes use of the TWI library where twi_writeTo copies the data again into a 3rd buffer. That's a bit clunky, isn't it?

I have seen the DSSCircuits / I2C-Master-Library but I am not sure how mature it is because there hasn't been any commit after the initial commit which is 3 years old now.

  • 3
    Do you actually have ram usage problems? Optimizing something before it becomes a problem is often a wasted effort.
    – BrettAM
    May 9 '15 at 21:04
  • 1
    It all comes down to the question of wanting to make it work soon and/or portably vs wanting to make it work optimally. You are of course free to get the ATmega programmer's manual and write to the peripheral registers yourself. May 10 '15 at 5:44
  • dsscircuits' Arduino I2C master library webpage shows five revisions of the I2C library that your github link is for. It probably is an ok starting point for the revisions you have in mind. If Wire has had corrections since Jan. 2012 you might need to add them to I2C. May 10 '15 at 16:37
  • > Alternatives to Wire library for I2C write your own. i2c is one of the easier protocols to write from scratch.
    – dannyf
    Oct 5 '17 at 23:12

I don't see any objection to using DSS Circuits I2C Master Library.

It may not have been updated for a couple of years, but if it works it doesn't need to be. It's not as if libraries for micro-controllers have to support new printer drivers, video drivers, etc.

If it works, it works.

The chip hasn't changed, and the only real reason for updates these days is if the IDE changes (or the compiler changes) in such a way that it introduces compile errors. Such things have happened fairly recently with things like PROGMEM having tighter rules, for example.

  • This library looked very promising, but note it does only support AVR targets. Since Arduino cores have been developed for a variety of architectures, this library will not "just work" for any Arduino-compatible board. For example, it is not compatible with Adafruit's STM32F405-based Feather
    – ardnew
    Dec 16 '19 at 21:58

Also Procyon AVR library worth be checking. It is a bit old now but very professional and kinda minimalistic. Not much dependencies, should be fine to use just I2C module only. There is hardly anything new in AVR I2C part since.


Cosa TWI class is a very different approach to I2C device driver support. It does not use any extra SRAM for buffers at all. If a device driver is non-blocking it must handle the necessary buffering. Also the Cosa TWI class supports typical interaction with I2C devices such as master/slave, "write register-read data"-patterns, and transactions when using multi-threading.

A software and hardware Arduino-TWI library is available. It uses the Arduino-GPIO library and can be used on AVR and SAM based boards.

Some examples: TWI Scanner, DS3231 Real-Time Clock/Calender, I2C LCD Adapter with PCF8574.


I made 2 libs myself for easier use and consistant calls:

one for AVR targets:

another using the same functions for all other targets (which basically is a wrapper for Wire library):

Both are available within the IDE library manager.
They both work as master without using interrupt and are tested on different targets with different slaves:
- UNO, Nano for cI2C
- Zero, Due & ESP8266 for WireWrapper


You can use completely different approach to the top question. Asking for alternatives you have given reason to this: getting rid of unused code in the binary. You can achieve removal of unused code without actually using alternative library. Please keep in mind, that you can instruct the compiler and linker to exclude unused code from the compiled binary. Just use compilation flags:

CFLAGS += -Wl,-static
CFLAGS += -ffunction-sections
CFLAGS += -Wl,--gc-sections

Rach function will be in its own section.

LDFLAGS += -Wl,-gc-sections

This tells GCC to send the -gc-sections flag to the linker which will remove unused sections. And voilla! Unused sections are removed.

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.