enjoyneering / HTU21D

This is an Arduino library for HTU21D, Si7021 and SHT21 Digital Humidity & Temperature Sensor
55 stars 15 forks source link

Added option to pass in existing read temperature to readCompensatedH… #3

Closed L-Carpenter closed 6 years ago

L-Carpenter commented 6 years ago

Hi

I've added a small change so that a previously read temperature may be passed into the readCompensatedHumidity method (optional) in order to avoid a second reading of the temperature from the sensor, this saves a few ms and a bit of battery power. In my case I needed both temperature and humidity values and as I had the temperature already it seemed unnecessary to retrieve it again.

I've also added the correct delays from the HTU21D datasheet for reading the temperature, as on some samples of the HTU21D the read would failed and return an error.

Please merge if you wish.

Regards

Lee

enjoyneering commented 6 years ago

Hi Lee,

Thank you for your request. It's realy cool. I don't know how to traumatically add your request, so I'll do it manually in the next couple of days.

enjoyneering commented 6 years ago

done. could you test it? also add the pull request link to the HTU21D.h

L-Carpenter commented 6 years ago

Hi

Many thanks will test.

The timings you had that I then reverted back to the ones for the HTU21D control as it wasn't working, well it turns out it did work on one HTU21D sensor, but not another one (from different Ebay sellers so not sure if one was a fake as it also showed different readings). I have some sourced from Farnell in the UK who are a legitimate supplier so will test with those. I can see you had the waits for the minimum time required then polled for the slower sensors, which makes sense, so it may be I have a bad part that stopped it from working. I will let you know.

Regards

Lee

enjoyneering commented 6 years ago

what arduino version and board type are you using for testing?

if you are using esp8266 with arduino core try this driver for i2c - https://github.com/enjoyneering/ESP8266-I2C-Driver

L-Carpenter commented 6 years ago

Hi

I've been using an Arduino Uno so ATMega 328P.

Regards

Lee

enjoyneering commented 6 years ago

I have two sensors. HTU21D, and Si7021. Both from from Ebay and work fine. When I was working on i2c driver for ESP8266, found interesting thread - "high value pullups ﴾10kOhm﴿ are placed on both SDA and SCL. This combinations leads to a raise time which far too long"

thread link - https://github.com/pasko-zh/brzo_i2c/tree/master/examples/HTU21D