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

BMP390 minor fix for SPI read #6722

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft

Conversation

latonita
Copy link
Contributor

@latonita latonita commented May 11, 2024

What does this implement/fix?

bugfix for SPI read

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Related issue or feature (if applicable): fixes esphome/feature-requests#2680

Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040
  • BK72xx
  • RTL87xx

Example entry for config.yaml:

esphome:
  name: bmp3xx-test

esp32:
  board: esp32dev
  framework:
    type: arduino

# esp8266:
#   board: nodemcuv2

logger:
  level: DEBUG


external_components:
  - source: github://pr#6722
    refresh: 10s
    components: [bmp3xx_base, bmp3xx_i2c, bmp3xx_spi]

spi:
  clk_pin: 19
  mosi_pin: 20
  miso_pin: 21

i2c:
  sda: GPIO14
  scl: GPIO26
  scan: true


sensor:
  - platform: bmp3xx_spi
    cs_pin: 13
    temperature:
      name: "Outside Temperature"
      oversampling: 16x
    pressure:
      name: "Outside Pressure"
    update_interval: 60s
  - platform: bmp3xx_i2c
    address: 0x77
    temperature:
      name: "Outside Temperature"
      oversampling: 16x
    pressure:
      name: "Outside Pressure"
    update_interval: 60s

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@codecov-commenter
Copy link

codecov-commenter commented May 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 54.01%. Comparing base (4d8b5ed) to head (de256c8).
Report is 672 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #6722      +/-   ##
==========================================
+ Coverage   53.70%   54.01%   +0.30%     
==========================================
  Files          50       50              
  Lines        9408     9619     +211     
  Branches     1654     1692      +38     
==========================================
+ Hits         5053     5196     +143     
- Misses       4056     4096      +40     
- Partials      299      327      +28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jrydval
Copy link

jrydval commented May 26, 2024

Hello Sirs!

I tested this fix and it is the only branch which finds my BMP390 connected via SPI.
The issue is that the reported pressure and temperature values are not the right ones - but I can undestand that this is still a work in progress.

Not sure if you need a report, just in case it could be useful there is my VERY_VERBOSE log:

[14:27:50][C][bmp3xx.sensor:151]: BMP3XX:
[14:27:50][C][bmp3xx.sensor:152]:   Type: BMP 390 (0x60)
[14:27:50][C][bmp3xx.sensor:172]:   IIR Filter: OFF
[14:27:50][C][bmp3xx.sensor:173]:   Update Interval: 60.0s
[14:27:50][C][bmp3xx.sensor:175]:   Temperature 'Lolin1 Temperature'
[14:27:50][C][bmp3xx.sensor:175]:     Device Class: 'temperature'
[14:27:50][C][bmp3xx.sensor:175]:     State Class: 'measurement'
[14:27:50][C][bmp3xx.sensor:175]:     Unit of Measurement: '°C'
[14:27:50][C][bmp3xx.sensor:175]:     Accuracy Decimals: 1
[14:27:50][C][bmp3xx.sensor:176]:     Oversampling: 16x
[14:27:50][C][bmp3xx.sensor:179]:   Pressure 'Lolin1 Pressure'
[14:27:50][C][bmp3xx.sensor:179]:     Device Class: 'pressure'
[14:27:50][C][bmp3xx.sensor:179]:     State Class: 'measurement'
[14:27:50][C][bmp3xx.sensor:179]:     Unit of Measurement: 'hPa'
[14:27:50][C][bmp3xx.sensor:179]:     Accuracy Decimals: 1
[14:27:50][C][bmp3xx.sensor:180]:     Oversampling: 16x

[14:29:45][VV][scheduler:225]: Running interval 'update' with interval=60000 last_execution=342538 (now=402543)
[14:29:45][V][bmp3xx.sensor:189]: Sending conversion request...
[14:29:45][VV][spi-esp-arduino:021]: 8266 mangled SPI mode 0x0
[14:29:45][VV][bmp3xx.sensor:202]: measurement time 67
[14:29:45][VV][scheduler:032]: set_timeout(name='data', timeout=67)
[14:29:45][VV][scheduler:225]: Running timeout 'data' with interval=67 last_execution=402560 (now=402627)
[14:29:45][VV][spi-esp-arduino:021]: 8266 mangled SPI mode 0x0
[14:29:45][VV][bmp3xx.sensor:349]: data ready status 8
[14:29:45][VV][spi-esp-arduino:021]: 8266 mangled SPI mode 0x0
[14:29:45][D][bmp3xx.sensor:212]: Got temperature=150.2°C pressure=1425.9hPa
[14:29:45][V][sensor:043]: 'Lolin1 Temperature': Received new state 150.208694
[14:29:45][D][sensor:093]: 'Lolin1 Temperature': Sending state 150.20869 °C with 1 decimals of accuracy
[14:29:45][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 1856764387
  state: 150.209
  missing_state: NO
}
[14:29:45][V][sensor:043]: 'Lolin1 Pressure': Received new state 1425.935181
[14:29:45][VV][sensor.filter:014]: Filter(0x3fff5394)::input(1425.935181)
[14:29:45][VV][sensor.filter:021]: Filter(0x3fff5394)::output(1503.933838) -> SENSOR
[14:29:45][D][sensor:093]: 'Lolin1 Pressure': Sending state 1503.93384 hPa with 1 decimals of accuracy
[14:29:45][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 1976195786
  state: 1503.93
  missing_state: NO
}
[14:29:45][VV][spi-esp-arduino:021]: 8266 mangled SPI mode 0x0
[14:29:45][W][component:237]: Component bmp3xx_base took a long time for an operation (97 ms).
[14:29:45][W][component:238]: Components should block for at most 30 ms.

Thank you for your afford!

Best Regards,
Jan

@latonita
Copy link
Contributor Author

@jrydval Jan, would you please check last version with very verbose - i added some logging to show what we read from the device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add SPI Support for BMP388 and BMP390
3 participants