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

User avatar
By canedje
#35508
Olyflyer wrote:I have successfully used the Adafruit_BMP085 library in the Arduino IDE with an ESP8266-01, but you have to modify the Adafruit_BMP085.cpp file to disable the Pressure calculation function as this uses a 'pwr' maths function which does not appear to be implemented yet in the ESP library. If you use the standard Adafruit_BMP085 library then you will get a compile failure related to the 'pwr' function.

After the library has been sorted, include both Wire.h and the Adafruit_BMP085.h libraries in your sketch, define SDA_pin & SCL_pin as the chosen GPIO pins on your ESP (I used GPIO0 for I2C_SCL and GPIO2 for I2C_SDA on an ESP8266-01 module) and then call Wire.begin(SDA_pin, SCL_pin) in the sketch setup section BEFORE calling Adafruit_BMP085.begin(). The Wire call will then cause the Adafruit library to use the defined I2C pins.
Do the above to a standard Adafruit example sketch & it should work ok.
Just connect the BMP180 to 3.3v, and the two chosen I2C pins.

Note that you cannot use the Pressure reading parts of any examples due to the above mentioned maths library issue.

With the replaced libm.a you can keep all functionality as there is sqrt, pow, pwr math.
User avatar
By picstart
#35513 I had issue with the BMP085 code and the esp8266 Arduino IDE. The BMP180 is I believe compatible with the BMP085
The original code makes assumptions about the notation of negative numbers ( 2's complement). ( The esp8266 hardware and the bmp085 hardware use identical notation for 16 bit negative numbers)
The last line (if(ac1)... see the code below) was added to explicitly encode the 2's complement notation .
This last line should not be necessary, however, without it ac1 will not be correct for 16 bit 2's complement notation received in the two byte transfer from the BMP085.
I suspect the esp8266 internal hardware notation and or the c compiler are different (a suspected bug).

readmem(CAL_AC1, 2, _buff);
ac1 = ((int)_buff[0] <<8 | ((int)_buff[1]));
if (ac1>=0x8000) ac1=ac1-0xFFFF-1; /// calc two's compliment

Suggestion
I'd look at the raw bytes being received and check values above 0x8000 to make sure the 2's complement notation is correctly interpreted to give a negative number.
I found it to be incorrect hence the explicit code. If the negative numbers ( 0x8000 and above) are interpreted as positive you will get wacky results.