So, I am doing a project that requires the wire library, but it seems that 1.6.5 Arduino IDE does not include it in the libraries. Everywhere I look, it is assumed that it is there, so it is not availible to download. If someone could upload it as a whole, that would be very appreciated (and karma rewards).
It shows up in my ide (same version)
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries
but here it is just in case
Wire.zip (14.7 KB)
For some reason it wasn't in mine. I tried re-downloading but no luck. Thanks for the help!
Dannyboy001:
So, I am doing a project that requires the wire library, but it seems that 1.6.5 Arduino IDE does not include it in the libraries.
Please post your code. It may be you are not including it in the correct way.
it seems that 1.6.5 Arduino IDE does not include it in the libraries
Are you implying that it worked perfectly with 1.6.4 IDE?
Also please post your error message(s).
... it seems that ...
That is not very specific.
Hi,
I came across this thread as I was trying to compile I2CScanner.ino for an ESP8266 board.
I get a compile error: ...fatal error: utility/twi.h: No such file or directory
I am using a freshly installed copy of IDE 1.6.7 with ESP8266 board files installed by the 'Boards manager'.
I looked in the Arduino\hardware\arduino\avr\libraries folder and can see the 'Wire' library there. There is no /utility folder in that library though.
I copied the /utility folder into Arduino\hardware\arduino\avr\libraries\Wire but I still get the same compile error.
Here is the code I am using. It is the standard I2CScanner.ino from I2CScanner: Arduino as I2C bus scanner – todbot blog
/**
* I2CScanner.pde -- I2C bus scanner for Arduino
*
* 2009, Tod E. Kurt, http://todbot.com/blog/
*
*/
#include "Wire.h"
extern "C" {
#include "utility/twi.h" // from Wire library, so we can do bus scanning
}
// Scan the I2C bus between addresses from_addr and to_addr.
// On each address, call the callback function with the address and result.
// If result==0, address was found, otherwise, address wasn't found
// (can use result to potentially get other status on the I2C bus, see twi.c)
// Assumes Wire.begin() has already been called
void scanI2CBus(byte from_addr, byte to_addr,
void(*callback)(byte address, byte result) )
{
byte rc;
byte data = 0; // not used, just an addverifeye admin ress to feed to twi_writeTo()
for( byte addr = from_addr; addr <= to_addr; addr++ ) {
rc = twi_writeTo(addr, &data, 0, 1, 0);
callback( addr, rc );
}
}
// Called when address is found in scanI2CBus()
// Feel free to change this as needed
// (like adding I2C comm code to figure out what kind of I2C device is there)
void scanFunc( byte addr, byte result ) {
Serial.print("addr: ");
Serial.print(addr,HEX);
Serial.print( (result==0) ? " found!":" ");
Serial.print( (addr%4) ? "\t":"\n");
}
byte start_address = 1;
byte end_address = 127;
// standard Arduino setup()
void setup()
{
Wire.begin();
Serial.begin(19200);
Serial.println("\nI2CScanner ready!");
Serial.print("starting scanning of I2C bus from ");
Serial.print(start_address,DEC);
Serial.print(" to ");
Serial.print(end_address,DEC);
Serial.println("...");
// start the scan, will call "scanFunc()" on result from each address
scanI2CBus( start_address, end_address, scanFunc );
Serial.println("\ndone");
}
// standard Arduino loop()
void loop()
{
// Nothing to do here, so we'll just blink the built-in LED
digitalWrite(13,HIGH);
delay(300);
digitalWrite(13,LOW);
delay(300);
}
Any help would be greatly appreciated.
I think it will be sufficient if you remove the 'utility/' from the include
#include <twi.h>
If that fails, you can try
[code]
#include "twi.h"
Note:
does the ESP board support hardware I2C; I seem to recall to have read that it doesn't but not sure.
Hi sterretje, thanks for the reply.
I tried using the 2 different include statements you quoted but neither worked.
I found that I had to include the full path to the file to be able to include it properly.
#include "C:\arduino-1.6.11\hardware\arduino\avr\libraries\Wire\src\utility\twi.h"
When I did that it compiled and worked OK for a Uno board.
I am getting a bunch of error when trying to compile it for ESP12E though.
In file included from C:\Users\don.m\Dropbox\Arduino\Projects\I2C_BusScanner\I2C_BusScanner.ino:10:0:
C:\arduino-1.6.11\hardware\arduino\avr\libraries\Wire\src\utility\twi.h:41:21: error: declaration of C function 'void twi_init()' conflicts with
void twi_init(void);
^
In file included from C:\Users\don.m\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/Arduino.h:39:0,
from sketch\I2C_BusScanner.ino.cpp:1:
C:\Users\don.m\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/twi.h:35:6: error: previous declaration 'void twi_init(unsigned char, unsigned char)' here
void twi_init(unsigned char sda, unsigned char scl);
^
In file included from C:\Users\don.m\Dropbox\Arduino\Projects\I2C_BusScanner\I2C_BusScanner.ino:10:0:
C:\arduino-1.6.11\hardware\arduino\avr\libraries\Wire\src\utility\twi.h:45:59: error: declaration of C function 'uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t, uint8_t)' conflicts with
uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t, uint8_t);
^
In file included from C:\Users\don.m\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/Arduino.h:39:0,
from sketch\I2C_BusScanner.ino.cpp:1:
C:\Users\don.m\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/twi.h:40:9: error: previous declaration 'uint8_t twi_readFrom(unsigned char, unsigned char*, unsigned int, unsigned char)' here
uint8_t twi_readFrom(unsigned char address, unsigned char * buf, unsigned int len, unsigned char sendStop);
^
In file included from C:\Users\don.m\Dropbox\Arduino\Projects\I2C_BusScanner\I2C_BusScanner.ino:10:0:
C:\arduino-1.6.11\hardware\arduino\avr\libraries\Wire\src\utility\twi.h:46:67: error: declaration of C function 'uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t)' conflicts with
uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t);
^
In file included from C:\Users\don.m\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/Arduino.h:39:0,
from sketch\I2C_BusScanner.ino.cpp:1:
C:\Users\don.m\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/twi.h:39:9: error: previous declaration 'uint8_t twi_writeTo(unsigned char, unsigned char*, unsigned int, unsigned char)' here
uint8_t twi_writeTo(unsigned char address, unsigned char * buf, unsigned int len, unsigned char sendStop);
^
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
The ESP board does not have hardware I2C, but there is a software implementation.
No idea about the ESP.
In my 1.6.7 installation, I have the below twi.h files
C:\Program Files (x86)\Arduino\hardware\tools\avr\avr\include\util\twi.h
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\utility\twi.h
C:\Program Files (x86)\Arduino\hardware\tools\avr\avr\include\compat\twi.h
I'm not sure if I ever compiled an I2C code on this system.
The_Don:
#include "C:\arduino-1.6.11\hardware\arduino\avr\libraries\Wire\src\utility\twi.h"
That Wire library is specifically for AVR, which is why it's bundled with the Arduino AVR Boards package, is only accessible for includes in the normal way when an Arduino AVR Boards board is selected, and is causing you errors. There is an ESP8266 specific Wire library included with the ESP8266 package at C:\Users{your username}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\Wire but unfortunately that library doesn't contain a file named twi.h, it only has Wire.h and Wire.cpp. There is a file named twi.h at C:\Users{your username}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266\twi.h
I'd recommend looking around for an ESP8266 specific version of the scanner sketch, otherwise you will probably need to make some modifications to the sketch you're trying to use now.