structure7 / fridgeTemps

Monitoring of a refrigerator and freezer's temperature to an OLED display.
1 stars 0 forks source link

Serious look: Wire.h in ESP8266 vs Wire.h in core Arduino library #7

Closed structure7 closed 8 years ago

structure7 commented 8 years ago

This references the ESP-01 specifically but probably need to at least experiment with it: https://github.com/adafruit/ESP8266-Arduino#i2c-wire-library (just noticed that's an Adafruit fork... hmmm... might need to compare the source files).

From ada:

I2C (Wire library)

Wire library currently supports master mode up to approximately 450KHz. Before using I2C, pins for SDA and SCL need to be set by calling Wire.begin(int sda, int scl), i.e. Wire.begin(0, 2); on ESP-01, else they default to pins 4(SDA) and 5(SCL).

structure7 commented 8 years ago

Kind of another mention of this:

In theory you can use any pins for I2C and SPI but to make it easier for people using existing Arduino code, libraries, sketches we set up the following: I2C SDA = GPIO #4 (default) I2C SCL = GPIO #5 (default) If you want, you can connect to I2C devices using other 2 pins in the Arduino IDE, by calling Wire.pins(sda, scl) before any other Wire code is called (so, do this at the begining of setup() for example

...from https://learn.adafruit.com/adafruit-feather-huzzah-esp8266/pinouts#i2c-and-spi-pins

The above doesn't work (at least not with the default Arduino Wire.h)... it didn't compile.

***NOTE: I removed #include <Wire.h> from the sketch, changed the board from Uno to ESP-12E, then re-added Wire.h... it compiled!!! Still didn't work! But might be a lead!

structure7 commented 8 years ago

With Wire.h compiling (still not 100% convinced it's the right one) trying things:

  1. Wire.pins(5,4); in setup didn't do anything.
  2. Wire.begin(4,5); in setup also didn't do anything.

*Tested correlation between IDE pin 5 = D1 and IDE pin 4 = D2 using blink, just to be sure!!!

structure7 commented 8 years ago

Hold the horn... Ada SSD1306 is calling #define OLED_RESET 4 that might be hijacking my pin 4.

structure7 commented 8 years ago

I could cry. Finally solved it! The reset was "fouling" my pin 4... any other pin choice and I probably would have been fine! Therefore:

#define OLED_RESET 0 This change to 0 did it!