Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By tytower
#17894 It all helps thanks . I note however that in the latest ESP8266-yesterday for Arduino IDE 1.6.4 library Igrr talks about I2C in the readme and uses Wire.begin(0, 2); on ESP-01, else they default to pins 4(SDA) and 5(SCL)..

So in my case it is easier to use pins 6 and 7 so I am playing with "Wire.begin(6, 7);" in setup . It compiles OK and uploads to the board but I have not got it reading the BMP180 yet.
User avatar
By martinayotte
#17897 @tytower, check my post at viewtopic.php?f=28&t=2991#p17753
you can either continue to use the deprecated Wire.pins or applying the fix I did in Wire.cpp :
Code: Select allvoid TwoWire::begin(int sda, int scl){
+  default_sda_pin = sda;
+  default_scl_pin = scl;
  twi_init(sda, scl);   
  flush();
}
User avatar
By tytower
#17944 OK it seems that the latest Ardino IDE 1.6.4 nightly build has been altered to load the library by a json file and I suspect that they have changed the pin assignments to follow the GPIO numbering so to use DHT for example normally on arduino pin 2 now you use GPIO2

If I am right ( and I have an ESP-12 board running with a DHT that way right now ) then the other pins have probably been changed to match the board so pin 6 would be GPIO6 . I have not got a BMP180 running on I2C pins which should then be GPIO 4 and 5.

Anybody concur?
User avatar
By tytower
#18123
martinayotte wrote:@tytower, check my post at viewtopic.php?f=28&t=2991#p17753
you can either continue to use the deprecated Wire.pins or applying the fix I did in Wire.cpp :
Code: Select allvoid TwoWire::begin(int sda, int scl){
+  default_sda_pin = sda;
+  default_scl_pin = scl;
  twi_init(sda, scl);   
  flush();
}

I find that interesting .
I looked in the Wire library which is now in /hardware/arduino/avr/libraries just to confuse things .
I found no function "void TwoWire::begin(int sda, int scl)" but using Wire.begin(sda,scl); is recognised in the IDE 1.6.4.so I don't follow why it recognises it
I put the above in the .cpp file and in the .h file and it made no difference. It didn't complain of being defined twice either so I am wondering why. Wire is defined to be TwoWire of course

Wire.pins(sda,scl); will also compile but does not show as recognised in the IDE. Playing around with that and with Wire.setClock(Varius speeds ie40000); I could not get my device to work on pins 4 and 5 at all


Seems to be an issue being resolved on github now https://github.com/esp8266/Arduino/issues/254
I put my bit in if it helps