Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Bosch BMP3xx Pressure sensors #4689

Closed
iz8mbw opened this issue Jun 4, 2023 · 32 comments · Fixed by #4789
Closed

Add support for Bosch BMP3xx Pressure sensors #4689

iz8mbw opened this issue Jun 4, 2023 · 32 comments · Fixed by #4789
Labels
Category: Plugin Related to supported sensors Type: Feature Request Add a completely new feature (e.g. controller/plugin)

Comments

@iz8mbw
Copy link
Contributor

iz8mbw commented Jun 4, 2023

Hi!
Is it possible to add Bosch Sensortec BMP3xx series Pressure sensors in ESPEasy?
Sensors are BMP380 / BMP384 / BMP388 / BMP390.

Docs and Libraries:

https://github.com/boschsensortec/BMP3-Sensor-API
https://github.com/adafruit/Adafruit_BMP3XX
https://github.com/MartinL1/BMP388_DEV

Datasheets:

BMP384
BMP388
BMP390

Many thanks!

@TD-er
Copy link
Member

TD-er commented Jun 4, 2023

Hmm, haven't seen those before.
I will order some too.

@TD-er TD-er added Category: Plugin Related to supported sensors Type: Feature Request Add a completely new feature (e.g. controller/plugin) labels Jun 4, 2023
@iz8mbw
Copy link
Contributor Author

iz8mbw commented Jun 4, 2023

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Jun 29, 2023

Hi @TD-er is there a plan to support Bosch Sensortec BMP3xx?
Thanks

@TD-er
Copy link
Member

TD-er commented Jun 29, 2023

As we speak I am labelling all stuff I received yesterday from the postman.
Included are these sensors.

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Jun 29, 2023

Ok, I will receive a BMP390 next week so I can support for testing.
Thanks!

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Jul 6, 2023

Hi @TD-er the BMP390 sensor is now delivered here, when you are ready I can support for testing.
Thanks!

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Aug 30, 2023

Hi @TD-er any news about implementing these sensors series?

@TD-er
Copy link
Member

TD-er commented Aug 30, 2023

Well I can already see the color of my floors and even parts of the original color of my anti-static mats on my desks.
So the re-arrangements of my office is near to "good enough. After which implementing sensors is on my todo list.

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Aug 30, 2023

Thanks!

@TD-er
Copy link
Member

TD-er commented Sep 6, 2023

OK, ADS1x15 is done, so this is next :)

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Sep 6, 2023

Great!

@TD-er
Copy link
Member

TD-er commented Sep 6, 2023

I've just looked into the datasheets of both BMP388/390 and the already supported BMP280.
The only similarities between those is the brand and the fact they measure temperature and air pressure...
Oh and they seem to use electricity and interface via I2C.

They are so completely different, that I will allocate a new plugin ID for this BMP3xx series.
--> P154 it is

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Sep 6, 2023

Yes, BMP3xx series is different from the already supported BMP280, this is why I asked on this issue to support BMP3xx series.
Thanks.

@TD-er
Copy link
Member

TD-er commented Sep 6, 2023

Just started with just using the Adafruit library, to get an idea of how this sensor may work.

But I'm a bit surprised it only took like 30 minutes to write this. :)
See PR #4789

not yet tested, but I see no reason why this shouldn't work.
Let's summarize it as "it compiles".

Now I have to dig up some of the ordered modules as I'm sure they have to be somewhere....

@TD-er
Copy link
Member

TD-er commented Sep 6, 2023

Hmm that was easy....

image

image

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Sep 6, 2023

Oh.. Yes!
It works well also here, thanks!
image

Please can you add the "Altitude" (that is a fine tuning on the Pressure value) on the "Device Settings" likes it was done for BME68x, for BMx280 and for BMP085/180?

image

@TD-er
Copy link
Member

TD-er commented Sep 6, 2023

Like this for the BME280?
image

Not sure if temperature offset is really needed here, as it is used in the BME280 to compensate for the measured humidity (and offset in temp of course, but that's easy to do in the formula field)

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Sep 6, 2023

Indeed, just asking for "Altitude" parameter only.
See also BMP085/180.
'Altitude" is a value (in meters) that should be used to "normalize" pressure to sea level.
So it should be a easy formula to increase pressure value when the sensor is on a specific altitude.

@tonhuisman
Copy link
Contributor

That's a standard conversion, pressureElevation(), and
also available as a rules/formula conversion %c_sea_pres_alt%(850,1350.03) (see System Variables page in the web interface).

@TD-er
Copy link
Member

TD-er commented Sep 6, 2023

So like this?

image
Pressure at 0 m altitude is roughly 1021.47656 mbar.

N.B. I also added the detected sensor type.
Since the library only shows 0x50 for BMP3_CHIP_ID and 0x60 for BMP390_CHIP_ID, I can only show "BMP38x" or "BMP390".
If there is another value, it will show just the number, so we could add it to the code.

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Sep 6, 2023

Thanks, I will test tomorrow.

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Sep 7, 2023

Hello and thanks!
@TD-er just tested latest commit and "Altitude" works as expected, also "Detected Sensor Type" works:
image

Just a note, also in this new Plugin returning "nan" when I disconnect VCC or I2C signals (between the sensor and the ESP32) is not covered.
As you know to recognize a read error returning "nan" is better then returning 0 values for both Temperature and Pressure.
For example for Plugin SHT3x and SHT4x the read error returning "nan" was covered, see comments here #4590

Apart to manage read error (returning "nan" instead to return 0) for me this PR can be merged.

Thanks.

@TD-er
Copy link
Member

TD-er commented Sep 7, 2023

Well I can't yet merge it as we're missing 1 important aspect of the PR...
The documentation.

Good to know the BMP390 is also working as expected, as I never received the BMP390 I ordered.
I only have 3 pieces of BMP388.

I will think about the NaN option...
Not sure if I will add it right now, as we were planning to make it a generic option for all plugins to have an error state value which the user can set.
So better not create a legacy setting where there may be users who have it setup based on plugin specific error states.
Also the default setting is to disable plugins which cannot access the I2C device, so with that option checked you would not get any values if the sensor gets disconnected.

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Sep 7, 2023

OK.
About NaN, OK to for the future generic option, make sense, I agree.
And when you will work on the generic NaN option make also sense to remove the disable plugins which cannot access the I2C device.
A temporary (or accidental) read error must NOT disable the plugin!

@tonhuisman
Copy link
Contributor

A temporary (or accidental) read error must NOT disable the plugin!

The check does actually probe the device for accessibility via the I2C bus, and only after 10 failures in a row, it is disabled.
This is a security/stability measure, to stop failing I2C sensors from blocking the entire ESP, as has been seen several times in the past.

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Sep 7, 2023

Ok but if I have a sensor with 10 seconds of polling and I accidentally disconnect a signal cable and I notice it after some hours I will have the sensor marked as disabled and then I must manually re-erbale it.
Personally I don't like this behavior.

For me, by default, a sensor must remain enabled until the user will go to disable it and ESPEasy should manage the "read error" (or disconnection) returing nan.
In this way, with "nan", the user can understand there is an issue and so solve the issue and decide if disable or not that sensor.

Thanks.

@TD-er
Copy link
Member

TD-er commented Sep 7, 2023

You can uncheck this I2C check.
And like I said, we're working on a generic "error state" setting for all plugins.
So that will be added later, not yet for this plugin.

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Sep 7, 2023

The sensor will become disabled also if I2C check is disabled.

@TD-er
Copy link
Member

TD-er commented Sep 7, 2023

Ah yep, if PLUGIN_INIT returns false, it will be disabled.
That's when the sensor is not found.

But that's done with many more plugins.

I have to dig a bit more into the code to see if we added a 'retry' later, as I'm sure that option has been discussed before.

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Sep 7, 2023

Ok, for now as told, the sensor will become disabled also if I2C check is disabled and this is annoying.

@TD-er
Copy link
Member

TD-er commented Sep 7, 2023

Ok, for now as told, the sensor will become disabled also if I2C check is disabled and this is annoying.

And that exact part is what I'm looking into right now.

So if you will double check your solder joints, I will double check the code and together we will end up with something that's working as expected :)

@iz8mbw
Copy link
Contributor Author

iz8mbw commented Sep 7, 2023

Great and thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Plugin Related to supported sensors Type: Feature Request Add a completely new feature (e.g. controller/plugin)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants