-->
Page 1 of 2

Wire library trouble

PostPosted: Fri Jul 24, 2015 5:04 pm
by jtheires@netins.net
Installed the esp8266-as-arduino stuff into my Arduino IDE and built a working blink example (this is *so* cool!).
Next, I added a BMP180 temp/pres sensor and adapted the espa_thingspeak_v03.ino sketch to my wifi router (SSID/Password) and thingspeak apikey.
When compiling, Arduino IDE gives an error on what appears to be associated with the Wire library:
Code: Select allespa_thingspeak_v03.ino: In function 'void setup()':
espa_thingspeak_v03:195: error: no matching function for call to 'TwoWire::begin(int, int)'
espa_thingspeak_v03.ino:195:18: note: candidates are:
In file included from espa_thingspeak_v03.ino:8:0:
C:\Users\Donatech\Documents\Arduino\hardware\esp8266com\esp8266\libraries\Wire/Wire.h:53:10: note: void TwoWire::begin()
     void begin();
          ^
C:\Users\Donatech\Documents\Arduino\hardware\esp8266com\esp8266\libraries\Wire/Wire.h:53:10: note:   candidate expects 0 arguments, 2 provided

My guess is that the wire library adaptation discussed briefly in the github documentation did not get installed.
Can someone help me work through this?

Arduino Library Manager shows the following:
"Wire Built-In by Arduino Version 1.0.0 INSTALLED
Allows the communication between devices or sensors connected via Two Wire Interface Bus. For esp8266 boards."
Is this the correct wire library supporting 2 parameters in the call to Wire.begin()?

Re: Wire library trouble

PostPosted: Sat Jul 25, 2015 2:54 am
by tytower
So what version IDE do you have?
If latest then look in preferences lower left there is a link to where ESP stores its packages and follow down to wire library . Look in .cpp program but I think it should be something like Wire.begin(0,2);
Code: Select all void TwoWire::begin(int sda, int scl)   

Re: Wire library trouble

PostPosted: Sat Jul 25, 2015 3:30 pm
by jtheires@netins.net
tytower,
Thanks for answering.
I'm on 1.6.4 Arduino IDE.
I followed the link in the preferences dialog to: C:\Users\Donatech\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries\Wire, which is where you intended right? (not OneWire)?
There are Wire.cpp and Wire.h files there.
In Wire.cpp, I see the following code:
Code: Select allvoid TwoWire::begin(int sda, int scl){
  default_sda_pin = sda;
  default_scl_pin = scl;
  twi_init(sda, scl);
  flush();
}

This looks to be consistent with the call in my sketch, so I still don't know why my sketch doesn't compile...
I assume the constructor (or some other 'magic') takes care of the conversion between my code's call to Wire.begin to the TwoWire::begin code you just led me to?
So, what keeps the IDE from looking for the *old* (default) Wire.begin, as opposed to the *new* Wire.begin you just made me aware of?

Re: Wire library trouble

PostPosted: Sat Jul 25, 2015 5:46 pm
by tytower
If you hack through the code in there Wire is defined as TwoWire somewhere so the compiler transposes Wire:: whatever to TwoWire:: whatever whenever it reads it.

On the other question on old wire I don't know but I will see if I can find an answer and post it back here when I do