2026-05-31 1:41 PM
Hello after some headaches with the issue of getting wakeup interrupt working in LIS3DSH accelerometer. I got a working configuration, i would like to share with other users.
This example generate a INT1 pulse (50us) each time LIS3DSH is moved. Note after each time int is catched and processed you need to call to limpiarInterrupcionAcelerometro() for clear 0x5F register, if not you only get the first INT pulse.
No any dedicated library is used, direct I2C comunication with the chip
```
/* Lee el registro 0x5F correspondiente la INT1 para limpiarla y poder volver a generar otra*/
void limpiarInterrupcionAcelerometro() {
Wire.beginTransmission(acelerometro.adr);
Wire.write(0x5F); // Registro OUTS1
if (Wire.endTransmission(false) == 0) {
if (Wire.requestFrom(acelerometro.adr, (uint8_t)1) == 1) {
byte estadoFSM = Wire.read();
// Serial.printf("Interrupción limpiada. Estado FSM: 0x%02X\n", estadoFSM);
}
}
}
/* Configura el Acelerometro
-Condiciones NEXT/RESET Ver datashhet pag 48 (6.1 Operation codes). El nibble alto(bits izq) es la condicion de reset y el bajo (bits derecha) la de next
-Comandos Ver datashhet pag 54 (6.2 Commands Operation codes)
-An interrupt is triggered when the output/stop/continue state is reached. */
void acelerometroConfigura() {
// Soft Reset. Borrar cualquier posible configuracion previa
writeRegister(0x23, 0b00000001); // CTRL_REG3 (0x23): Bit 0 = 1 activa el Software Reset (SR)
delay(20); // estabilizar chip
// RELOJ INTERNO. CTRL_REG4 (0x20). Bits 7-4 = 0110 (ODR: Frecuencia de muestreo fijada a 100Hz nativos). Bits 2-0 = 111 (Habilita de forma estricta los ejes Z, Y, X)
writeRegister(0x20, 0b01100111);
// Escala. CTRL_REG5 (0x24). Bits 5-3 = 000 (Escala completa de +/- 2g).Bits 7-6 = 00 (Filtro Anti-Aliasing a 800Hz por defecto)
writeRegister(0x24, 0b00000000);
// CTRL_REG3 (0x23)
// Bit 7: 0= data interrupt dis/ena
// Bit 6: Interrupt signal low/hi
// Bit 5: interrupt latched/pulsed
// Bit 4: interrupt 2 dis/ena
// Bit 3: interrupt 1 dis/ena
// Bit 2: Vector filter dis/ena
// Bit 1: reserved
// Bit 0: Soft reset when set to 1 (automatically returns to 0)
writeRegister(0x23, 0b01101000);
// THRS1_1 (0x57) Sensibilidad
writeRegister(0x57, 75); // Valor Umbral sensibilidad aceleracion decimal de 0 a 255
writeRegister(0x5A, 0b11111100); // MASK1_A (0x5A) monitorizar los ejes +/-X, +/-Y, +/-Z
// PROGRAMACIÓN DE LA FSM ST1
writeRegister(0x40, 0x05); // Modo evaluacion ST1_0: GNTH1 Espera a que el sensor se mueva y supere el Umbral 1 (THRS1_1)
writeRegister(0x41, 0x88); // Modo accion ST1: OUTC Si se mueve, dispara interrupción
writeRegister(0x42, 0x11); // CONT. Reset to ST1_1
// CTRL_REG1 (0x21). Bit 0 = 1 (SM1_EN: Habilita la Máquina de Estados 1)
writeRegister(0x21, 0b00000001);
limpiarInterrupcionAcelerometro(); // Limpiar registro interrupcion
}
```
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.