Code Monkey home page Code Monkey logo

Comments (16)

maruel avatar maruel commented on May 21, 2024

Ok it seems quite straightforward. I've ordered two on aliexpress for now.

The main annoyance is the 2s/4s standby but since I've unexported Standby in af3fbce, this simplifies hiding this discrepancy.

I'm wondering what to do with the driver name though, as it's not really worth having a completely separate package, since the actual device can be easily detected. I guess bmx280 would be fine, albeit slightly confusing. :/

Another option is to create a directory bosch, then put the devices in there as subdirectories so it's easier to share the code via an internal package. Actually everything could be in the bosch directory.

I'm open to other ideas too.

from periph.

maruel avatar maruel commented on May 21, 2024

I've made a commit showing how it could me done. I think it's feasible, the main annoyance is the user needs to know "more" about the right I²C address to use.

from periph.

quinte17 avatar quinte17 commented on May 21, 2024

maybe device-creation needs a bit of a rework?
what about something like
func NewBMP180() (clever_device_object)
the only problem i see here, is how to get the difference between spi and i2c.
NewBMP180I2C
NewBMP180SPI
seems a bit redundant?

from periph.

UnAfraid avatar UnAfraid commented on May 21, 2024

Thanks for the quick reply i really didn't wanted to fork the repo just for a single byte change.
Also i really like the idea of not duplicating the driver but naming it bmx280, great idea!

from periph.

maruel avatar maruel commented on May 21, 2024

@quinte17 the function NewI2C() handles all of bmp180/bme280/bmp280 seamlessly as per the WIP code I pushed. The only challenge is the address: I'm thinking it would be split off as a separate argument in NewI2C, so it couldn't awkwardly be passed to NewSPI due to its presence in Opts{}.

from periph.

maruel avatar maruel commented on May 21, 2024

FTR, I'm planning a v2 release really soon, so getting this in before the v2 would be a good idea since it's totally a breaking change.

from periph.

quinte17 avatar quinte17 commented on May 21, 2024

With the options...
the only thing I can imagine is to use different types or different interfaces.
or just live with it and just write it into the docs that address wont have any affects when using spi.
but that means you also dont error out if an address is given.

from periph.

maruel avatar maruel commented on May 21, 2024

I changed NewI2C() to have an additional argument. It's not that bad (3 args now) and makes the code simpler.

from periph.

maruel avatar maruel commented on May 21, 2024

@UnAfraid can test 2ba2860 locally? You can get with it:

git fetch && git checkout origin/bosch

Even better would be to connect one BMP280 device over I²C, one over SPI then run:

periph-smoketest bmx280

and confirm that both readings are close, which means both protocols work correctly. This would greatly increase the confidence level for the whole thing working.

Thanks

from periph.

UnAfraid avatar UnAfraid commented on May 21, 2024

Sure gonna try it.

from periph.

UnAfraid avatar UnAfraid commented on May 21, 2024

I couldn't get nor bme or bmp to work under SPI, on i2c it works fine tho.
It says

chip@chip4:~/go/src/periph.io/x/periph/cmd/bmxx80$ sudo ./bmxx80 -spi /dev/spidev32766.0 -v
19:34:12.601514   CLK : INVALID   
19:34:12.602751   MOSI: INVALID   
19:34:12.603339   MISO: INVALID   
19:34:12.603854   CS  : INVALID

Here's BME280 and BMP280 sensors attached at same i2c bus 2 on both available addresses 0x76 and 0x77

chip@chip4:~/go/src/periph.io/x/periph/cmd/bmxx80$ sudo i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- 76 77                         
chip@chip4:~/go/src/periph.io/x/periph/cmd/bmxx80$ sudo ./bmxx80 -i2c 2 -ia 0x76
27.800°C 100.453KPa
chip@chip4:~/go/src/periph.io/x/periph/cmd/bmxx80$ sudo ./bmxx80 -i2c 2 -ia 0x77
28.390°C 100.382KPa  40.20%rH

from periph.

maruel avatar maruel commented on May 21, 2024

The SPI driver on the CHIP is, I'd say, "subpar". I'm only testing SPI on a Raspberry Pi. But that's fine I'll confirm first I didn't break anything (likely tomorrow or the day after) with my 2 BME280 and that should be good enough.

from periph.

UnAfraid avatar UnAfraid commented on May 21, 2024

I have Rasberry PI Zero around, i can try with it.

from periph.

UnAfraid avatar UnAfraid commented on May 21, 2024

Here's smoketest output from 2 BMP280s and BME280s

pi@pi-zerow:~/go/src/periph.io/x/periph/cmd/periph-smoketest $ # BMP Test
pi@pi-zerow:~/go/src/periph.io/x/periph/cmd/periph-smoketest $ ./periph-smoketest bmx280 -i2c 1 -spi /dev/spidev0.0
BMP280{I2C1(118)} : 25.830°C 100.825KPa   0.00%rH
BMP280{SPI0.0}    : 26.060°C 100.814KPa   0.00%rH
Delta             :  0.230°C   0.011KPa   0.00%rH
pi@pi-zerow:~/go/src/periph.io/x/periph/cmd/periph-smoketest $ # BME Test
pi@pi-zerow:~/go/src/periph.io/x/periph/cmd/periph-smoketest $ ./periph-smoketest bmx280 -i2c 1 -spi /dev/spidev0.0
BME280{I2C1(118)} : 28.170°C 100.734KPa  33.37%rH
BME280{SPI0.0}    : 28.760°C 100.814KPa  31.10%rH
Delta             :  0.590°C   0.080KPa   2.27%rH
pi@pi-zerow:~/go/src/periph.io/x/periph/cmd/periph-smoketest $

Can you add support for -ia on the smoke test as well?

from periph.

maruel avatar maruel commented on May 21, 2024

Thanks a lot for the verification. I added the flag to the smoke test.

from periph.

UnAfraid avatar UnAfraid commented on May 21, 2024

Thanks!

from periph.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.