Closed
Description
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
#include <ESP8266WiFi.h>
#include <Wire.h>
void setup() {
// Do Nothing
}
Debug Messages
/home/$USER/.arduino15/packages/esp8266/hardware/esp8266/2.4.0/libraries/Wire/Wire.cpp:48:30: error: 'SDA' was not declared in this scope
static int default_sda_pin = SDA;
^
/home/$USER/.arduino15/packages/esp8266/hardware/esp8266/2.4.0/libraries/Wire/Wire.cpp:49:30: error: 'SCL' was not declared in this scope
static int default_scl_pin = SCL;
^
exit status 1
Error compiling for board Arduino.
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
pieman64 commentedon Jan 3, 2018
@eggsactly you are using an incomplete sketch, see http://arduino-esp8266.readthedocs.io/en/2.4.0/libraries.html#i2c-wire-library
igrr commentedon Jan 3, 2018
Which board do you have selected?
eggsactly commentedon Jan 4, 2018
@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.
igrr commentedon Jan 4, 2018
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
WereCatf commentedon Jan 5, 2018
@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.
WereCatf commentedon Jan 5, 2018
Couldn't find a schematic for Star OTTO, so no idea if the pins are in use there or not.
igrr commentedon Jan 5, 2018
Alternatively, we could have something like this in Wire.cpp:
Not sure whether this is what @eggsactly wants...
JAndrassy commentedon Jan 7, 2018
@eggsactly, on Uno WiFi the esp8266 has no pin headers. why do you try to use the Wire library?
JAndrassy commentedon Jan 7, 2018
@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, ,
eggsactly commentedon Jan 8, 2018
@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.
Uno Rev 3 Diagram
Uno Wifi Diagram
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.
WereCatf commentedon Jan 8, 2018
@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.
13 remaining items