twi.writeTo problem not declared

I am playing with a multiplexer that will connect to 3 BNO055’s. I am working on the basic multiplexer detection and i get a “not declared in this scope” errror on twi.writeTo what should it be declared as ??

#include <Wire.h>
#include <Adafruit_BNO055.h>

#define BNO055_SAMPLERATE_DELAY_MS (20)     // Set pause between samples

#define TCAADDR 0x70

void tcaselect(uint8_t i) {
  if (i > 7) return;
  Wire.write(1 << i);

Adafruit_BNO055 bno0 = Adafruit_BNO055();     // Use object bno to hold information

void setup() {
  Serial.begin(9600);                          // open the serial port at 9600 bps: 

    while (!Serial);
    Serial.println("\nTCAScanner ready!");
    for (uint8_t t=0; t<8; t++) {
      Serial.print("TCA Port #"); Serial.println(t);
      for (uint8_t addr = 0; addr<=127; addr++) {
        if (addr == TCAADDR) continue;
        uint8_t data;
        if (! twi_writeTo(addr, &data, 0, 1, 1)) {
           Serial.print("Found I2C 0x");  Serial.println(addr,HEX);


Here is the compiler error

TEST_TEST_TEST:40: error: 'twi_writeTo' was not declared in this scope

if (! twi_writeTo(addr, &data, 0, 1, 1)) {


exit status 1
'twi_writeTo' was not declared in this scope

Your project is called "TEST_TEST_TEST" ? with the sketch being "TEST_TEST_TEST.ino" ?
The compiler has a problem at line 40 with the function "twi_writeTo". The compiler says that you want to call it, but that function is not declared somewhere, it does not exist.

Have you gathered little pieces of code from the internet ? The "twi_writeTo" is not a normal Arduino function.
Are you trying to run a I2C Scanner ? Try this one: Arduino Playground - I2cScanner.

Please tell us also which Arduino board that you are using, and which multiplexer and how it is connected.

The twi code came from the mutiplexer look up

Adruino UNO

Switch IC Development Tools TCA9548A I2C Multiplexer

nothing is hooked up yet i am working on the code before i build it. I will hook up the multiplexer to the SDC SDA pins.

The code example I used was

I forgot to use #include "utility/twi.h"

it now got past the first error but now is throwing this error below. I feel like i am missing something simple any help is appreciated. Thanks

undefined reference to `twi_writeTo(unsigned char, unsigned char*, unsigned char, unsigned char, unsigned char)'

I got it i'm an idiot, i was not including the correct library.

No, no, you are not, but at Adafruit they are. I am very unhappy that Adafruit is using a low level function of the Arduino Wire libary :smiling_imp: They should have used the normal functions of the Wire library. The more I think about it, the more I am convinced that they should not have done that.

This is the low level twi_writeTo :
These are the normal functions of the Wire library: Arduino - Wire