I'm working on KX132-1211 Accelerometer with nRF52832 (Step count).

Hello,

I'm working on KX132-1211 accelerometer with nRF52832 and am using I2C(TWI) protocol. For that I need to create driver files even I was contact with manufactural but they also don't have any refer code (For ::  how to make driver files for KX132-1211). And after that I have to do step count  using kx132 sensor. If anyone have any idea regarding KX132-1211 sensor means how to make file then please help me sort out this problem.

Thank you,

Parents
  • Hi,

    There are no officially supported drivers in the nRF5 SDK, but I see there is a repo with some drivers here that are referred to in this thread. Perhaps can say something about it?

    Einar

  • Hello ,

    Regarding your inquiry about a Zephyr RTOS compatible driver for Kionix' KX132-1211 accelerometer, I got a partially implemented KX132-1211 driver working a few months ago.  The driver itself which Einar mentions is, of course, not a stand-alone code.  To exercise it you will want to clone and build the Kionix driver_demo I posted along side on Github.

    This driver I am sure will not get you the full solution you need.  It can however help you, as the groundwork has already been completed such that the driver has most of Zephyr RTOS API hooks in place to write to and read from sensor registers.  The only Zephyr 2.6.0 API I did not implement is one to configure hardware based interrupts, to tie those from the sensor to Zephyr's device driver code.

    Driver starting point:

    I got this tiny project to a point where I can query for tri-axis accelerometer readings.  The demo itself is based on a combining of Zephyr RTOS 2.6.0 samples "blinky" and "hello_world".  I located these early on in my use of Nordic's ncs SDK.  I'm still building against ncs v1.6.1, though on github the SDK has moved forward a couple of releases.

    Also I must give credit to engineer and developer Jared Wolff and his community forum, and to Jared's Memfault.com blog post.  I got a lot of help from Jared's posts, and on both forums Devzone and CircuitDojo communities.  These groups of developers carried me a good deal of the way along my 2021 crash course introduction to Zephyr RTOS!

    What is unfinished:

    My partial implementation of this sensor driver leaves a number of configuration parameters undeveloped -- KX132-1211 technical reference -- but to implement these is mostly a matter of extending, making routines which call the Zephyr register read and write API functions with specific values and sequences of values.  Our team last year found that there were supply chain delays of months to obtain this sensor.  Maybe that has changed now.  We also found that there was some question how accurate the sensor itself was timing its internal readings.  That accuracy impacts how meaningful gathered data sets may be treated when used in Fast Fourier transformations and other numeric processing,

    Tools and Environment where driver tested:

    This said, I am relatively new to Zephyr, about eight months in.  I've gotten to do nearly all my learning and development on Linux stations at the command line.  Initially to set up command line tools on an Ubuntu host I followed Nordic Semi's Getting Started toolchain instructions, with a few minor changes of which I took notes.  The command line environment makes it easy to `git clone` the above Kionix driver demo.  Assuming you have python, west, dtc, an appropriate cross compiler and related tools installed, it is then also relatively easy to init your workspace (sounds like you've already done this in one way or another) and then build and flash firmware to corresponding hardware.

    I mention my tools because most Devzone posts I see, where developers mention their environments, they are using things like Segger IDE, VSCode, many are developing on Windows and some even on Macs.  I've built my projects in Nordic's version of Segger, but I won't be able to help debug things related to troubles opening projects in these other environments.  I know these alternate tool sets have advantages, but for me the command line has been the most straight-forward place to solve problems and to maintain a good workflow.

    Hardware on which tested:

    At the time I was learning about Zephyr RTOS in-tree and out-of-tree drivers I was developing on a Sparkfun Sparkfun Thing Plus nRF9160 board.  I connected a KX132-1211 sensor on break out daughter board to the Sparkfun board, namely lines GND, VCC, SCL, SDA.  I believe I must also tie a pin of the KX132-1211 high to enable I2C, and not SPI.

    While not on my git repository, I also have successfully run this Kionix demo on a Nordic Thingy91 kit, with same sensor break out attached to that board.

    Getting started you efforts may vary:

    If your tools are other than command line it may take a bit of work to change your project configurations to include this driver.  The demo is a stand alone Zephyr app.  Stand alone in the sense that it lives outside of the sample apps in Nordic's ncs 1.6.1 'nrf' top level directory, as well as outside of Zephyr RTOS sample apps directories.  To get to a point of building this stand alone app I must first `git clone` this project, and then issue a `west init . . .` above the directory to which I cloned.  You may already be familiar with these steps.  They're only needed once.  Then you can build and develop in a normal git + software workflow.  I'm not sure how to execute these steps from Segger.  I can only point Segger Studio to a project whose top level directory is already initialized by `west` utility.

    Forgive me if you already know these things.  If you are further along and comfortable to amend your current project's manifest file, that will be most likely a needed step to bring a new out-of-tree driver to your present Zephyr based app.  After you see the demo work, that could at your project stage be a natural next step.  Then you would re-build your project and have that driver API and some specific Zephyr device macros for the KX132-1211 available to add to your code.

    Manthan let me know if this helps.  If you reach out regarding this driver work I'll attempt to share help and what I know as time permits.

    - Ted

  • hello tedhavelka,

    First I'll try to make drivers according to what you mention above the ans. And after that I'll contact you again.

    Thank you,

Reply Children
No Data
Related