Adafruit BMP085 and HTU21D libraries work good with HardWire

Working libraries, libraries being ported and related hardware
Post Reply
oleg31337
Posts: 1
Joined: Mon Mar 28, 2016 2:53 pm

Adafruit BMP085 and HTU21D libraries work good with HardWire

Post by oleg31337 » Mon Mar 28, 2016 3:48 pm

Hi Everybody,
just tested BMP085 and HTU21D libraries from Adafruit with HardWire and they work very good!
I had to slightly modify both libraries:
remove #include "Wire.h" in both .h and .cpp files
add #include "HardWire.h" only in .cpp files
replace all Wire with HWire in all .cpp files
remove #include <util/delay.h> from Adafruit_HTU21DF.cpp (no reason to include it as it is already defined somewhere else)

At the beginning of the sketch it is required to include HardWire and define Hwire with specific i2c port (1 or 2):

Code: Select all

#include <HardWire.h> 
HardWire HWire(1, I2C_FAST_MODE);
#include <Adafruit_BMP085.h>
#include <Adafruit_HTU21DF.h>
this all works on a STM32F103C blue pill board (with yellow jumpers)

User avatar
RogerClark
Posts: 6911
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Adafruit BMP085 and HTU21D libraries work good with HardWire

Post by RogerClark » Mon Mar 28, 2016 8:34 pm

Cool

I think a number of people have tried the BMP085 using Wire but not Hardwire, but I dont recall anyone using that display before.

fari
Posts: 23
Joined: Sun Feb 26, 2017 12:01 pm

Re: Adafruit BMP085 and HTU21D libraries work good with HardWire

Post by fari » Sun Mar 19, 2017 12:27 pm

Hi Oleg!

I have been trying to run the measurement with HTU21D since few days, but with no success.
I have mad the changes in the .cpp files (wire exchanged by HWire) and connected the sensor to PB7 and PB6 (Pull up 4.7k and 3.3V VCC)
All I get ist 998 (time out).
Can you please give me any hint, which could help me, or your sketch and the relevant cpp files?
Thanks a lot!

Post Reply