This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How implement step for connect sensor type I2C or Twi ?

in my tutorial I need to implement an I2C or TWI sensor on a peripheral BLE. In SoftDevice Software in Example-> Peripheral there are 2 methods 1) twi_sensor or 2) twi_master_with_twis_slave, which is the best solution for me, in the first solution it is sufficient to import the files in the project and set the pins and the following methods to configure the sensor reading ???

Parents
  • Hi Frank,

    I would recommend you to use the "twi_sensor" example as reference on how to use the TWI interface.

    You could for example start with the "ble_app_uart" example, and add the necessary TWI files and enable it in "sdk_config.h".

    Then add the TWI code to your application similar to the tutorial made by Bjorn.

    Check out TASK 3

  • Thank Martin.

    I set the tutorial by following the your advice. 

    I preferred as base project ble_app_hts, to which I added the files as per example twi_sensor.

    initially I had errors, after adapting sdk_config, as you advised me, they disappeared.

    modifying sdk_config.h I found this code:

    #Ifndef NRF_TWI_SENSOR_ENABLED

    #define NRF_TWI_SENSOR_ENABLED 0

    #endif

     In file sdk_config of twi_sensor this code is not present 

    how should i set up ? leave at 0 or 1 

    I also ask you for other suggestions:

    In twi_sendos use a simple LM75B temperature sensor

    In my app I use a ms5837 pressure sensor : www.te.com/.../DDEController

    looking in the internet I found this tutorial : github.com/.../ms5611.h

    in this tutorial use a ms5611 very similar to ms5837, I took as an example, I also created the files ms5837 h and c, there are differences in the tutorial write and read with I2C method, but I prefer to use twi, using a fusion between twi_sensor and this tutorial.

    In your opinion risk of making a big mess ????

Reply
  • Thank Martin.

    I set the tutorial by following the your advice. 

    I preferred as base project ble_app_hts, to which I added the files as per example twi_sensor.

    initially I had errors, after adapting sdk_config, as you advised me, they disappeared.

    modifying sdk_config.h I found this code:

    #Ifndef NRF_TWI_SENSOR_ENABLED

    #define NRF_TWI_SENSOR_ENABLED 0

    #endif

     In file sdk_config of twi_sensor this code is not present 

    how should i set up ? leave at 0 or 1 

    I also ask you for other suggestions:

    In twi_sendos use a simple LM75B temperature sensor

    In my app I use a ms5837 pressure sensor : www.te.com/.../DDEController

    looking in the internet I found this tutorial : github.com/.../ms5611.h

    in this tutorial use a ms5611 very similar to ms5837, I took as an example, I also created the files ms5837 h and c, there are differences in the tutorial write and read with I2C method, but I prefer to use twi, using a fusion between twi_sensor and this tutorial.

    In your opinion risk of making a big mess ????

Children
No Data
Related