2021-08-12 6:18 PM
We have been using the LIS2HH12 accelerometer and it will work on a fresh board for about a day or so and then stop working. Below is some stripped down code from this library:
https://gitlab.com/rhombio/rhio-libraries/rhio-LIS2HH12/-/blob/master/examples/basic-example.cpp
#include <U8g2lib.h>
#include <Arduino.h>
#include <rhio-LIS2HH12.h>
float x, y, z;
char bufferx[80];
char buffer_display[80];
U8X8_SSD1306_128X32_UNIVISION_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 8, /* reset=*/ 9);
LIS2HH12 lis = LIS2HH12();
void setup()
{
Serial.begin(9600);
lis.begin();
lis.setBasicConfig();
u8x8.begin(); //Set up OLED Display
u8x8.setPowerSave(0);
}
void loop()
{
lis.getAccel(&x, &y, &z);
sprintf(bufferx,"xAngle:%d",round(x));
delay(333); //333
u8x8.setFont(u8x8_font_8x13B_1x2_r); //Set Font for mode and angle
u8x8.draw1x2String(0,0,bufferx);
delay(2000);
}
#include <U8g2lib.h>
#include <Arduino.h>
#include <rhio-LIS2HH12.h>
float x, y, z;
char bufferx[80];
char buffer_display[80];
U8X8_SSD1306_128X32_UNIVISION_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 8, /* reset=*/ 9);
LIS2HH12 lis = LIS2HH12();
void setup()
{
Serial.begin(9600);
lis.begin();
lis.setBasicConfig();
u8x8.begin(); //Set up OLED Display
u8x8.setPowerSave(0);
}
void loop()
{
lis.getAccel(&x, &y, &z);
sprintf(bufferx,"xAngle:%d",round(x));
delay(333); //333
u8x8.setFont(u8x8_font_8x13B_1x2_r); //Set Font for mode and angle
u8x8.draw1x2String(0,0,bufferx);
delay(2000);
}An oled display is being used as a serial monitor for this. Attached also are snippets from the schematic:
2021-08-18 1:34 AM
Hi, the fact that your application works for a while (an entire day, continuously?) and then stops, makes me suspect that is is not a configuration issue, but it is related to something else. Maybe a buffer filling and then getting overflow? Or what if you your application or the device itself loose the supply connection for a while? It would cause the LIS2HH12 to stop working since the volatile register would go back to 00h value. When you restart the application, does the LIS2HH12 functionality recover?
Tom
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.