{"action":"created","issue":{"url":"https://api.github.com/repos/BoschSensortec/BMP280_driver/issues/16","repository_url":"https://api.github.com/repos/BoschSensortec/BMP280_driver","labels_url":"https://api.github.com/repos/BoschSensortec/BMP280_driver/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/BoschSensortec/BMP280_driver/issues/16/comments","events_url":"https://api.github.com/repos/BoschSensortec/BMP280_driver/issues/16/events","html_url":"https://github.com/BoschSensortec/BMP280_driver/issues/16","id":313851187,"node_id":"MDU6SXNzdWUzMTM4NTExODc=","number":16,"title":"After initialization, the BMP280 always read the same temperature / pressure values.","user":{"login":"g-berthiaume","id":19377511,"node_id":"MDQ6VXNlcjE5Mzc3NTEx","avatar_url":"https://avatars3.githubusercontent.com/u/19377511?v=4","gravatar_id":"","url":"https://api.github.com/users/g-berthiaume","html_url":"https://github.com/g-berthiaume","followers_url":"https://api.github.com/users/g-berthiaume/followers","following_url":"https://api.github.com/users/g-berthiaume/following{/other_user}","gists_url":"https://api.github.com/users/g-berthiaume/gists{/gist_id}","starred_url":"https://api.github.com/users/g-berthiaume/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/g-berthiaume/subscriptions","organizations_url":"https://api.github.com/users/g-berthiaume/orgs","repos_url":"https://api.github.com/users/g-berthiaume/repos","events_url":"https://api.github.com/users/g-berthiaume/events{/privacy}","received_events_url":"https://api.github.com/users/g-berthiaume/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2018-04-12T19:08:40Z","updated_at":"2018-08-12T19:16:56Z","closed_at":null,"author_association":"NONE","body":"## Problem: \r\nEven without the IRR filter, the BMP280 always read the same temperature / pressure  value.\r\n\r\n### Problem details: \r\nI'm connecting a NUCLEO-L433RC-P (STM32L4 Microcontroler DevBoard ) to the BMP280 by a SPI Full duplex - 4 wires communication.\r\nI'm using your driver (the 3.0.0 version) and your example code to interface the BMP280.\r\n\r\n:heavy_check_mark:  `bmp280_init(&bmp)` return  `BMP280_OK`\r\n:heavy_check_mark:  `bmp280_get_config(&conf, &bmp)` return  `BMP280_OK`\r\n:heavy_check_mark:  `bmp280_set_config(&conf, &bmp)` return  `BMP280_OK`\r\n:heavy_check_mark:  `bmp280_set_power_mode(BMP280_NORMAL_MODE, &bmp)` return  `BMP280_OK`\r\n:heavy_check_mark:  `bmp280_get_uncomp_data(&ucomp_data, &bmp)` return  `BMP280_OK`\r\n:x: The data return by `bmp280_get_uncomp_data` is always the same.\r\n\r\nThis system has been tested inside (at 23 C) and outside (at -5 C). \r\nThe results is exactly the same.\r\n\r\n### Demonstration\r\nThis test is just initializing and configuring the BMP280 stuct and then try to get the uncompensated data.\r\nThe test will output the uncompensated and the compensated data returned by the function `bmp280_get_uncomp_data`.\r\nThe terminal output for this test is as followed.\r\n\r\n```\r\nMeasurement duration: 34ms.\r\nSPI READ return values:\r\n    reg_addr     : 247\r\n    reg_data[6]  : {0,107,118,144,128,94}\r\n\r\nUT: 591877, UP: 1719, T32: 25436, P32: 0\r\n```\r\n\r\n### Additional test\r\nI've tried to change the chip,  but the problem stay the same, but with slightly different output values. \r\n\r\n### Conclusion\r\nThe SPI communication seems to be correct. (The chip ID returned is valid )\r\nThe driver seems to be in the correct state (no error while using it)\r\nThe IC seems to be in the the correct state (no error, while initializing)\r\nIn the various forums i've read, no problem of this kind is reported. \r\n\r\nSince the driver is 8 days old, could it be a software problem ? \r\nFeel free to ask me question.\r\nThanks for your help.\r\n\r\n\r\n\r\n## Additional information:\r\nAfter the BMP280 initializations this is the `bmp280_calib_param` inside the `bmp280_dev` \r\nstructure:\r\n```\r\nt1: 23\r\nt2: -22016\r\nt3: 0\r\np1: 0\r\np2: 0\r\np3: 0\r\np4: 13056\r\np5: 0\r\np6: 192\r\np7: 85\r\np8: 0\r\np9: 24576\r\nfine: 0\r\n```\r\nIt seams to have a lot of 0... \r\nThese parameter are from a SPI call.\r\nThe terminal ouput for this call is as followed.\r\n\r\n```\r\nSPI READ reg_addr     : 136\r\nSPI READ reg_data[24] : {23,0,0,170,0,0,0,0,0,0,0,0,0,51,0,0,192,0,85,0,0,0,0,96}\r\n```\r\n\r\n\r\nAfter the BMP280 initalisation this is the `bmp280_config` inside the `bmp280_dev` structure:\r\n```\r\nos_temp:  4\r\nos_pres:  4\r\nodr:      5\r\nfilter:   0\r\nspi3w_en: 0\r\n```\r\n\r\n\r\nCode snippets:\r\n------------------------\r\nThese c/c++ snippets  are from the main. \r\nNote that the main include `#include \"bmp280.h\"` and `#include \"bmp280_defs.h\"`. \r\n\r\n```cpp\r\nvoid BMP280_Init_SPI(void)\r\n{\r\n  int8_t rslt;\r\n  /* function needed for the library*/\r\n  bmp280_com_fptr_t spi_read_fptr = &BMP280_SPI_Read;\r\n  bmp280_com_fptr_t spi_write_fptr = &BMP280_SPI_Write;\r\n  bmp280_delay_fptr_t delay_ms_fptr = &BMP280_SPI_Delay_ms;\r\n\r\n  /* Sensor interface over SPI with native chip select line */\r\n  bmp.dev_id   = 0;                 // No need if using SPI\r\n  bmp.intf     = BMP280_SPI_INTF;   // SPI config\r\n  bmp.read     = spi_read_fptr;\r\n  bmp.write    = spi_write_fptr;\r\n  bmp.delay_ms = delay_ms_fptr;\r\n\r\n  rslt = bmp280_init(&bmp);\r\n  \r\n  if (BMP280_OK != rslt)\r\n  {\r\n    /**ERROR HANDLING*/\r\n  } \r\n}\r\n\r\nvoid BMP280_Set_Config(void)\r\n{\r\n  int8_t rslt;\r\n  struct bmp280_config conf;\r\n\r\n  /* Read current settings */\r\n  rslt = bmp280_get_config(&conf, &bmp);\r\n  if (rslt != BMP280_OK)\r\n  {  \r\n    /**ERROR HANDLING*/\r\n  }\r\n\r\n  /* Overwrite the desired settings */\r\n  conf.filter = BMP280_FILTER_OFF;\r\n  conf.os_pres = BMP280_OS_8X;\r\n  conf.os_temp = BMP280_OS_8X;\r\n  conf.odr = BMP280_ODR_1000_MS;\r\n\r\n  rslt = bmp280_set_config(&conf, &bmp);\r\n  if (rslt != BMP280_OK)\r\n  {\r\n    /**ERROR HANDLING*/\r\n  }\r\n\r\n  /* Always set the power mode after setting the configuration */\r\n  rslt = bmp280_set_power_mode(BMP280_NORMAL_MODE, &bmp);\r\n  if (rslt != BMP280_OK)\r\n  {\r\n    /**ERROR HANDLING*/\r\n  }\r\n}\r\n\r\nvoid BMP280_getMeasurement(void)\r\n{\r\n  int8_t rslt;\r\n  uint8_t meas_dur;\r\n  struct bmp280_uncomp_data ucomp_data;\r\n\r\n  /*Get the duration for 1 sample.*/\r\n  meas_dur = bmp280_compute_meas_time(&bmp);\r\n\r\n  /* Loop to read out 10 samples of data */ \r\n  ucomp_data.uncomp_temp = 0;\r\n  ucomp_data.uncomp_press = 0;\r\n  bmp.delay_ms(meas_dur);\r\n\r\n  rslt = bmp280_get_uncomp_data(&ucomp_data, &bmp);\r\n  if (rslt != BMP280_OK)\r\n  {\r\n    /**ERROR HANDLING*/\r\n  }\r\n\r\n  int32_t temp32 = bmp280_comp_temp_32bit(ucomp_data.uncomp_temp, &bmp);\r\n  uint32_t pres32 = bmp280_comp_pres_32bit(ucomp_data.uncomp_press, &bmp);\r\n\r\n  /*Printing the results*/\r\n  char resString[300];\r\n  sprintf(resString, \"UT: %d, UP: %d, T32: %d, P32: %d\\r\\n\", \\\r\n    ucomp_data.uncomp_temp, ucomp_data.uncomp_press, temp32, pres32);\r\n  UsbPrint(resString);  // Custom uart print function\r\n\r\n  bmp.delay_ms(1000); /* Sleep time between measurements */\r\n}\r\n\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/BoschSensortec/BMP280_driver/issues/comments/412365347","html_url":"https://github.com/BoschSensortec/BMP280_driver/issues/16#issuecomment-412365347","issue_url":"https://api.github.com/repos/BoschSensortec/BMP280_driver/issues/16","id":412365347,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMjM2NTM0Nw==","user":{"login":"JeffRGray","id":32078789,"node_id":"MDQ6VXNlcjMyMDc4Nzg5","avatar_url":"https://avatars3.githubusercontent.com/u/32078789?v=4","gravatar_id":"","url":"https://api.github.com/users/JeffRGray","html_url":"https://github.com/JeffRGray","followers_url":"https://api.github.com/users/JeffRGray/followers","following_url":"https://api.github.com/users/JeffRGray/following{/other_user}","gists_url":"https://api.github.com/users/JeffRGray/gists{/gist_id}","starred_url":"https://api.github.com/users/JeffRGray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JeffRGray/subscriptions","organizations_url":"https://api.github.com/users/JeffRGray/orgs","repos_url":"https://api.github.com/users/JeffRGray/repos","events_url":"https://api.github.com/users/JeffRGray/events{/privacy}","received_events_url":"https://api.github.com/users/JeffRGray/received_events","type":"User","site_admin":false},"created_at":"2018-08-12T19:16:56Z","updated_at":"2018-08-12T19:16:56Z","author_association":"NONE","body":"@BoschSensortec \r\nre: \"The problem is that the delay function linked doesn't pause for the right period.\"\r\n\r\nin bmp280.c there is the following function:\r\n```\r\nint8_t bmp280_soft_reset(const struct bmp280_dev *dev)\r\n{\r\n\tint8_t rslt;\r\n\tuint8_t reg_addr = BMP280_SOFT_RESET_ADDR;\r\n\tuint8_t soft_rst_cmd = BMP280_SOFT_RESET_CMD;\r\n\r\n\trslt = null_ptr_check(dev);\r\n\r\n\tif (rslt == BMP280_OK) {\r\n\t\trslt = bmp280_set_regs(&reg_addr, &soft_rst_cmd, 1, dev);\r\n\r\n\t\t/* As per the datasheet, startup time is 2 ms. */\r\n\t\tdev->delay_ms(2);\r\n\t}\r\n\r\n\treturn rslt;\r\n}\r\n```\r\nmy delay function looks like this:\r\n\r\n```\r\nvoid user_delay_ms(uint32_t period)\r\n{\r\n\tfor (int i=0;i<period;i++)\r\n\t_delay_ms(1);\r\n}\r\n```\r\nand yet I am still getting the same unchanging values:\r\n![image](https://user-images.githubusercontent.com/32078789/44005510-7b7e2af2-9e29-11e8-9e1d-0dfd3bc7f7db.png)\r\n\r\n"}}
{"actor":{"display_login":"JeffRGray"}}