2020-04-03 11:48 PM
nRF + LIS3DH board. I need to reduce current of the nRF advertising. I want to stop the nRF advertising and use LIS3DH to trigger restarting. Can I have the LIS3DH to monitor accel data and wake up nRF when reach a threshold? I know I can have nRF connect to the LIS3DH timely through I2C to check, but the I2C is current costing, and is much more than the advertising. I am looking for a way to trigger nRF advertising by LIS3DH without using I2C.
Thanks,
2020-04-04 02:04 AM
Hello,
Yes, it is possible. You have two pins on the LIS3DH called INT1 and INT2. When the conditions meets your specifications, there is a rising edge on INT1 or INT2, so you can wake up your uC. You will need to program the duration, the value, and to activate x or/and y or/and z axis by changing the different control registers and interruption registers. And, of course, you will need to program your nrf to be waken up on rising edge.
2020-04-04 03:16 AM
Thanks a lot. So how the nRF to know the registers change? Reading it through i2c? You know that's more current consumption. Can you please share more about how the program the nRF to be waken on the rising edge, without using i2c timely reading registers?
Thanks,
2020-04-04 03:34 AM
The nrf knows registers changed because of the rising edge on INT1 or INT2. For example, if I need to have an alarm if a freefall occurs on my system, I have to configure the registers of the lis3dh to detect no acceleration on x/y/z axis during xx ms (depends on the needs of my system). It avoids reading constantly the registers through i2c.
I am not an nrf expert and you didn't tell the reference of the chip, so I can't help you anymore.
2020-04-04 03:37 AM
Thanks. Sorry, I used nRF 51822 and 52810. I am not also much experienced on the embed development so if you could please provide more details will be much appreciated. For example ,some reference code or sample. Thanks,
2020-04-04 03:51 AM
I understand we can have lis3dh to change the registers, but how can we let the nrf 51822 knows the lis3dh registers change without using i2c? So far my knowledge is that we can only read lis3dh registers through either i2c or spi in nrf 51822, and both operations are current consumption. And nrf 51822 needs to timely read those registers to see if the values are changed. I need to know a different way that nrf can know the lis3dh registers changed without using i2c/spi. Thanks!
2020-04-04 03:55 AM
while(1)
{
/*
* Check INT 1 pin or read source register
*/
lis3dh_reg_t all_source;
lis3dh_int1_gen_source_get(&dev_ctx, &all_source.int1_src);
if (!(all_source.byte & 0x3f))
{
sprintf((char*)tx_buffer, "freefall detected\r\n");
tx_com(tx_buffer, strlen((char const*)tx_buffer));
}
}
this is the st lis3dh driver freefall example code. we can see that in the while loop it keeps reading those registers, and the reading function(lis3dh_int1_gen_source_get) actually uses either i2c or spi. You know, that's much current consumption. Is there a different way to read registers?
Thanks,
2020-04-04 03:56 AM
1) Try to communicate with your lis3dh from your nrf to validate the i2c communication (try to read the register WHO_AM_I for example).
2) Ensure that INT1 or INT2 is connected to one of the gpio of the nrf.
3) Configure the lis3dh to generate an interruption when the acceleration meets certain conditions.
4) Handle the interruption in your code.
Example: https://devzone.nordicsemi.com/f/nordic-q-a/27257/external-interrupt-from-gpio
2020-04-04 03:58 AM
OK, thanks a lot. Let me look into these.
Take care,