Hello Fernando,
Once again, accept my apologies for the delay.
Definitively, that is a weird situation. I have never heard something like that.
I would like to know if the temperature changes during the night.
Please be aware that the temperature change could affect the performance of the system.
In this case I would recommend setting the MMA8452 registers as follow:
I2C_WriteRegister(CTRL_REG1, 0x0C); // ODR = 400Hz, Reduced noise, Standby mode
I2C_WriteRegister(XYZ_DATA_CFG_REG, 0x00); // +/-2g range -> 1g = 16384/4 = 4096 counts
I2C_WriteRegister(CTRL_REG2, 0x02); // High Resolution mode
I2C_WriteRegister(PULSE_CFG_REG, 0x15); //Enable X, Y and Z Single Pulse
I2C_WriteRegister(PULSE_THSX_REG, 0x20); //Set X Threshold to 2.016g
I2C_WriteRegister(PULSE_THSY_REG, 0x20); //Set Y Threshold to 2.016g
I2C_WriteRegister(PULSE_THSZ_REG, 0x2A); //Set Z Threshold to 2.646g
I2C_WriteRegister(PULSE_TMLT_REG, 0x28); //Set Time Limit for Tap Detection to 25 ms
I2C_WriteRegister(PULSE_LTCY_REG, 0x28); //Set Latency Time to 50 ms
I2C_WriteRegister(CTRL_REG4, 0x08); //Pulse detection interrupt enabled
I2C_WriteRegister(CTRL_REG5, 0x08); //Route INT1 to system interrupt
CTRL_REG1_val = I2C_ReadRegister(CTRL_REG1); //Active Mode
CTRL_REG1_val |= 0x01;
I2C_WriteRegister(CTRL_REG1, CTRL_REG1_val);
Please let me know if the issue remains besides this configuration.
Finally, I would like to share with you, a sample project that could be useful for you.
Please find the sample project at MMA8451Q -Single Tap Detection Bare metal example project .
I hope you find it useful.
If I misunderstood your question, feel free to let me know. I will be glad to help.
Have a great day.
David Diaz.