cancel
Showing results for 
Search instead for 
Did you mean: 

LIS2HH12 Works for a moment and then stops working, value of 0 is being returned.(Using Arduino on a custom atmel328p board)

CPhip.1
Associate II

0693W00000D2NHfQAN.png0693W00000D2NHuQAN.pngWe 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:

1 REPLY 1
TBomb.1
Senior II

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