-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot Build with Wire.h on Arduino #4077
Comments
@eggsactly you are using an incomplete sketch, see http://arduino-esp8266.readthedocs.io/en/2.4.0/libraries.html#i2c-wire-library |
Which board do you have selected? |
@pieman64, I'm assuming you mean that I should call Wire.begin(0, 2). Regardless, adding it produces the same result. I don't believe it is necessary to add that begin call because the SDA and SCL lines should default to pins 4 and 5 respectively. Modifying esp8266/2.4.0/libraries/Wire/Wire.cpp to use
Instead causes this code to compile (I modified the following code below from my code in the first post because it won't work on the generic esp8266 board, but this will because it has the loop() function).
It appears these values are defined in esp8266/2.4.0/variants/generic/pins_arduino.h, but I don't know enough about how your project is configured to try to include it. @igrr To try to answer your question I have selected the Arduino under ESP8266 Modules, and selected Uno WiFi as the model. |
Thanks @eggsactly, this looks like an issue with Uno WiFi board variant. Other board variant header files define SDA and SCL constants for the default I2C pin names, e.g.: Arduino/variants/generic/pins_arduino.h Lines 31 to 35 in d9ef6b5
These definitions are missing from the variant header file for Uno WiFi: https://github.com/esp8266/Arduino/blob/master/variants/arduino_uart/pins_arduino.h |
@igrr I would assume that the reason those pins aren't defined is because all the GPIO-pins except GPIO5 are already in use for something else on the board, at least according to https://eu.mouser.com/pdfdocs/Arduino-UNO-WiFi-V4_AF1.pdf Given that they're already in use, I don't think it's a good idea to define any I2C-pins in the first place, or if one really insists on defining some, GPIO5 and GPIO14 seem safe to use (though pointless) on the Arduino Uno WiFi, but then one would have to check that they're safe on the Primo and Star OTTO, too. |
Couldn't find a schematic for Star OTTO, so no idea if the pins are in use there or not. |
Alternatively, we could have something like this in Wire.cpp: #if !defined(PIN_WIRE_SDA) || !defined(PIN_WIRE_SCL)
#error Wire library is not supported on this board
#endif Not sure whether this is what @eggsactly wants... |
@eggsactly, on Uno WiFi the esp8266 has no pin headers. why do you try to use the Wire library? |
@WereCatf, not all pins are used. GPIO0 is connected to enable pulling low for bootloader mode, GPIO2 is connected, only to a soldering point, 4 controls the direct serial connection for Atmega flashing from esp, 5 is not connected, 12 is to Atmega reset pin, 13 is not connected, 14 is LED, 15 is not connected only pulled down, , |
@WereCatf and @JAndrassy perhaps I'm not understanding something, but it appears that on the Uno and Uno Wifi, the I2C pins are located on the same pins, Pins 27 and 28 on ZU4 on both devices. I believe I should be able to attach an I2C device to the A4 and A5 pins. I was able to compile the code below using the vanilla Arduino AVR Board "Arduino Uno WiFi", but the same code does not compile with the ESP8266 Module "Arduino". This code is different from above because it does not include the ESP8266WiFi.h library so it should compile regardless of which device I have selected.
My perception as a user is this code should compile for both the Arduino AVR Board "Arduino Uno WiFi" and the ESP8266 Module "Arduino". My perception is based on the assumption that the normal Arduino library for Wire is the same as the library for ESP8266. Perhaps I made a mistake in assuming that pins 4 and 5 correspond to A4 and A5, perhaps these pins are different, I am unsure because the Arduino's API for Wire does not allow you to choose output pins, you're glued on A4 and A5. @JAndrassy to answer your question about why I would like to use the Wire library, I would like to hook this shield https://www.adafruit.com/product/772 up to the Arduino Wifi, while also being able to get wifi BSSIDs without being connected to a network, demonstrated on this project. It appears that the Arduino WiFi library does not have this capability but ESP8266WiFi does. |
@eggsactly Yes, A4 and A5 are brought out, but A4 and A5 are the Atmega328P-pins, not ESP8266-pins. The ESP8266 and the Atmega328P are separate microcontrollers, you can't program the Atmega's I2C-pins with this ESP8266-core. Also, the pins on the ESP8266 seemingly haven't been brought out on any pin-headers, so you couldn't use them anyways, unless you actually went and modified the board itself. |
@eggsactly, you must write two sketches and program the communication between them. one for Armega and one for esp8266. if you need guidance with it, write a post on Arduino forum |
@igrr, this is not a bug and not a 'good first', but the the #define check would help |
I think it is a bug — if it fails, it should fail with a clear error message. Regarding "good first", okay, i will remove the label. |
Closed via #4261 |
I change place 'AppData' and etc. I remove Arduino IDE. Then install Arduoino IDE from Microsoft Store. Board: ESP8266 or NodeMCU Sketch:
How to fix? |
This looks like an installation problem. |
@Bagunda, esp8266 core version you use? |
Basic Infos
Hardware
Hardware: ?Arduino?
Core Version: ?2.4.0?
Description
I cannot build a sketch that includes both the Wire.h and EP8266WiFi.h libraries. I am trying to build for an Arduino Uno Wifi. Using Arduino 1.8.5 on Debian 9.3.
Settings in IDE
Module: ?Arduino?
Flash Size: ?4MB/(1MB SPIFFS)?
CPU Frequency: ?80Mhz?
Flash Mode: ?N/A?
Flash Frequency: ?115200?
Upload Using: ?SERIAL?
Reset Method: ?N/A?
Sketch
Debug Messages
The text was updated successfully, but these errors were encountered: