I2CScanner problem - or is it me?

I installed library I2CScanner and loaded example from the File > Examples > Examples from Custom Libraries > Check, but when I compile it I get error message:

In file included from /tmp/.arduinoIDE-unsaved2023111-27860-wbl44d.b6yi/Check/Check.ino:1:0:
/home/me/Arduino/libraries/I2CScanner/src/I2CScanner.h:5:11: fatal error: arduino.h: No such file or directory

#include "arduino.h"

compilation terminated.

exit status 1

Compilation error: exit status 1

Any ideas?

btw, I get the same result on the desktop IDE 2.2.1 and the Arduino Cloud

What board? Arduino Uno compiles fine with this library.

The library that you use does not work.
It was fixed in 2019, but maybe they forgot to upgrade the version number.
There is no "arduino.h" only "Arduino.h" with a capital 'A'.

Can you find a I2C Scanner sketch ?

This is the scanner I normally use.

// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// Version 6, November 27, 2015.
//    Added waiting for the Leonardo serial communication.
// 
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>


void setup()
{
  Wire.begin();

  Serial.begin(115200);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}


void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ ) 
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4) 
    {
      Serial.print("Unknow error at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}

Now I am the one who does not understand why it works for me.

I have this in the I2Cscanner.h and it's example scanner compiles fine for a few boards I tried.

#if defined(ARDUINO) && ARDUINO >= 100
	#include "arduino.h"
#else
	#include "WProgram.h"
#endif

in Windows ? I have linux. The gcc compiler seems to ignore lower- and upper-case of filenames in Windows.

1 Like

Yep, Win11. Thanks for your clarification.

1 Like

Now, I am the one to be confused. By the way I’m using an Arduino Uno board. I was getting exactly the same error message on my Linux machine as on my windows 11 machine and on Arduino Cloud editor

You can try if it is the same problem by editing the I2Cscanner.h and change "arduino.h" into "Arduino.h" and see what happens.

If that gives the same error there it's something else.

1 Like

I have been using it with Linux for a lot of years and many versions without any problems. I dropped windows when they obsoleted XP, glad I did. The software keeps on working as I upgrade the OS.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.