[DRIVER] bmp180 sensor driver implementation#5078
[DRIVER] bmp180 sensor driver implementation#5078LudwigKnuepfer merged 1 commit intoRIOT-OS:masterfrom
Conversation
drivers/bmp180/bmp180.c
Outdated
| printf("MB: %i\n", (int)dev->calibration.mb); | ||
| printf("MC: %i\n", (int)dev->calibration.mc); | ||
| printf("MD: %i\n", (int)dev->calibration.md); | ||
| #endif |
There was a problem hiding this comment.
Can you use the DEBUG() function available on debug.h?
|
Just a side note about potential improvements: sections 3.6 and 3.7 of the bmp180 datasheet explain how to compute respectively the absolute altitude and pressure at see level. Maybe I can add the 2 missing functions to compute those values ? |
|
Is up to you! the driver can offer basic functionality but if you want to implement all the features it's always better |
drivers/bmp180/bmp180.c
Outdated
| DEBUG("MB: %i\n", (int)dev->calibration.mb); | ||
| DEBUG("MC: %i\n", (int)dev->calibration.mc); | ||
| DEBUG("MD: %i\n", (int)dev->calibration.md); | ||
| #endif |
There was a problem hiding this comment.
then the #if ENABLE_DEBUG becomes unnecessary don't you think?
There was a problem hiding this comment.
Indeed, I removed them.
I added the missing functions. |
Answering to myself: apparently using float_t type is the way to go. |
|
|
Indeed, but I don't know how to enable this either. |
a00fe87 to
42e657d
Compare
It seems that I have to apply RIOT patches on newlib sources, rebuild them and re-install them, using the available scripts. |
|
@aabadie I don't think you need to rebuild newlib. I did this in Contiki before to get float printf support: |
|
Thanks @gebart, I tried to add |
|
@aabadie Try adding it to the end of LINKFLAGS at https://github.com/RIOT-OS/RIOT/blob/master/cpu/Makefile.include.cortexm_common#L124 |
|
Thanks @gebart, this time it works ! |
|
Maybe we need to take care about the platforms that can support it, since not all can handle floats in this way. Let's run the CI and if everything goes ok we can merge it ;) |
|
Oh! it is already complaining about the white spaces. Can you take care of this? |
b872573 to
69c3d3f
Compare
cpu/Makefile.include.cortexm_common
Outdated
| # use the nano-specs of Newlib when available | ||
| ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0) | ||
| export LINKFLAGS += -specs=nano.specs -lc -lnosys | ||
| export LINKFLAGS += -specs=nano.specs -lc -lnosys -u _printf_float |
There was a problem hiding this comment.
I would suggest to split this out into a separate pull request.
|
|
tests/driver_bmp180/main.c
Outdated
| #include "xtimer.h" | ||
| #include "board.h" | ||
|
|
||
| #define SLEEP (2 * 1000 * 1000u) |
There was a problem hiding this comment.
maybe rename to SLEEP_2S or document..
There was a problem hiding this comment.
(2S or whatever this is ;)
|
@LudwigKnuepfer, I addressed most of your comments. |
e5ca2b8 to
0536e92
Compare
drivers/include/bmp180.h
Outdated
| * @return 0 on success | ||
| * @return -1 if device's I2C is not enabled in board config | ||
| */ | ||
| int bmp180_altitude(bmp180_t *dev, double *pressure_0, double *altitude); |
There was a problem hiding this comment.
I am not sure if double is a good idea here - I would strongly vote for something more ressource friendly - why not altitute in cm as int32_t? I doubt you get a better precision anyway... Same for the pressure...
There was a problem hiding this comment.
Ok, altitude precision can be 1m, under I think it doesn't really make sense. I changed the returned type from double to int32_t.
drivers/include/bmp180.h
Outdated
| * @return 0 on success | ||
| * @return -1 if device's I2C is not enabled in board config | ||
| */ | ||
| int bmp180_altitude(bmp180_t *dev, int32_t *pressure_0, int32_t *altitude); |
There was a problem hiding this comment.
pressure_0 is an input, right? So why pass it as a pointer?
There was a problem hiding this comment.
No particular reason (seems to be a bad practice ;) ). I changed that.
|
Murdock is complaining about |
tests/driver_bmp180/Readme.md
Outdated
| * reads pressure (hPa) ; and prints them to the STDOUT; | ||
| * computes the pressure at sea level (assuming the current pressure is computed | ||
| based on Polytechnique School Campus altitude, 158m); | ||
| * computes the altitude (given the pressure at sea level). |
There was a problem hiding this comment.
given the pressure at sea level => based on the pressure at sea level calculated above
There was a problem hiding this comment.
given the pressure at sea level=>based on the pressure at sea level calculated above
branch updated including this change.
543c243 to
0814e2f
Compare
|
Just pushed a commit activating |
| * @brief Read pressure value from the given BMP180 device, returned in Pa | ||
| * | ||
| * @param[in] dev Device descriptor of BMP180 device to read from | ||
| * @param[out] pressure Pressure in Pa |
There was a problem hiding this comment.
I think changing the output range to use 10^-1000 Pa (mPa) is probably more precise and feasible. If I am correct, the pressure is somewhere between 10 and 150 from sea-level to very high up (https://upload.wikimedia.org/wikipedia/commons/thumb/8/88/Atmospheric_Pressure_vs._Altitude.png/300px-Atmospheric_Pressure_vs._Altitude.png), so using mPa here would be more precise...
There was a problem hiding this comment.
I think changing the output range to use 10^-1000 Pa (mPa) is probably more
precise and feasible. If I am correct, the pressure is somewhere between 10
and 150 from sea-level to very high up
(https://upload.wikimedia.org/wikipedia/commons/thumb/8/88/Atmospheric_Pressure_vs._Altitude.png/300px-Atmospheric_Pressure_vs._Altitude.png),
so using mPa here would be more precise...
I'm not sure to understand your comment, maybe you mean kPa ? the results here are already returned in Pa, which is 1000x more precise and corresponds to SI. Displaying the results in hPa is common in meteorology.
There was a problem hiding this comment.
sorry, my bad, I was way of here... Don't know what I was thinking - never mind...
There was a problem hiding this comment.
np.
Thanks to your comment I had to look again at the datasheet and this pointed me to the possibility of writing a unittest for the temperature/pressure computations: the datasheet gives ground truth values that could be used to test internal implementations of formulas in the driver.
Do you think it make sense ?
|
All the checks are successful, someone with the hardware can ACK? @LudwigKnuepfer ? |
|
it would be great if you could rewrite your commit messages to fit the |
|
Example: |
|
@LudwigKnuepfer, I edited the commit message following your suggestion. |
|
ACK |
[DRIVER] bmp180 sensor driver implementation
Thanks :)Merged #5078. You are receiving this because you were mentioned. |
|
No, thank you for your contribution and endurance with all the review comments =) |
Hi,
I have a bmp180 and noticed that there's no driver implementation for it.
I tested this implementation using a Samr21-xpro (SDA is pin PA16, SCL is PA17). It works well !