LIS3DH Accelerometer (something's f*cked)

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
matt8011
 
Posts: 3
Joined: Thu Aug 05, 2021 12:16 pm

LIS3DH Accelerometer (something's f*cked)

Post by matt8011 »

Hello,
very new to coding and all this stuff, but im trying to use a LIS3DH accelerometer with my Arduino uno but I am continuously getting the "something's f*cked" in my serial Monitor, no clue why. I am using what is practically the start up code for the accelerometer demo:

Code: Select all

// Basic demo for accelerometer readings from Adafruit LIS3DH

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_LIS3DH.h>
#include <Adafruit_Sensor.h>

// Used for software SPI
#define LIS3DH_CLK 13
#define LIS3DH_MISO 12
#define LIS3DH_MOSI 11
// Used for hardware & software SPI
#define LIS3DH_CS 10

// software SPI
Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS, LIS3DH_MOSI, LIS3DH_MISO, LIS3DH_CLK);
// hardware SPI
//Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS);
// I2C
//Adafruit_LIS3DH lis = Adafruit_LIS3DH();

void setup(void) {
  Serial.begin(9600);
  while (!Serial) delay(10);     // will pause Zero, Leonardo, etc until serial console opens

  Serial.println("LIS3DH TEST");

  if (! lis.begin(0x18)) {   // change this to 0x19 for alternative i2c address
    Serial.println("something's f*cked");
    while (1) yield();
  }
  Serial.println("LIS3DH found!");

  // lis.setRange(LIS3DH_RANGE_4_G);   // 2, 4, 8 or 16 G!

  Serial.print("Range = "); Serial.print(2 << lis.getRange());
  Serial.println("G");

  // lis.setDataRate(LIS3DH_DATARATE_50_HZ);
  Serial.print("Data rate set to: ");
  switch (lis.getDataRate()) {
    case LIS3DH_DATARATE_1_HZ: Serial.println("1 Hz"); break;
    case LIS3DH_DATARATE_10_HZ: Serial.println("10 Hz"); break;
    case LIS3DH_DATARATE_25_HZ: Serial.println("25 Hz"); break;
    case LIS3DH_DATARATE_50_HZ: Serial.println("50 Hz"); break;
    case LIS3DH_DATARATE_100_HZ: Serial.println("100 Hz"); break;
    case LIS3DH_DATARATE_200_HZ: Serial.println("200 Hz"); break;
    case LIS3DH_DATARATE_400_HZ: Serial.println("400 Hz"); break;

    case LIS3DH_DATARATE_POWERDOWN: Serial.println("Powered Down"); break;
    case LIS3DH_DATARATE_LOWPOWER_5KHZ: Serial.println("5 Khz Low Power"); break;
    case LIS3DH_DATARATE_LOWPOWER_1K6HZ: Serial.println("16 Khz Low Power"); break;
  }
}

void loop() {
  lis.read();      // get X Y and Z data at once
  // Then print out the raw data
  Serial.print("X:  "); Serial.print(lis.x);
  Serial.print("  \tY:  "); Serial.print(lis.y);
  Serial.print("  \tZ:  "); Serial.print(lis.z);

  /* Or....get a new sensor event, normalized */
  sensors_event_t event;
  lis.getEvent(&event);

  /* Display the results (acceleration is measured in m/s^2) */
  Serial.print("\t\tX: "); Serial.print(event.acceleration.x);
  Serial.print(" \tY: "); Serial.print(event.acceleration.y);
  Serial.print(" \tZ: "); Serial.print(event.acceleration.z);
  Serial.println(" m/s^2 ");

  Serial.println();

  delay(200);
}


I'll also attach pictures of my board.
Attachments
Blue on 13, Yellow on 12, Green on 11, Brown on 10 (Not pictured: Red on VIN, White on GND, Purple on 3.3V)
Blue on 13, Yellow on 12, Green on 11, Brown on 10 (Not pictured: Red on VIN, White on GND, Purple on 3.3V)
20210805_122319.jpg (273.29 KiB) Viewed 87 times
Red on VIN, Purple on 3V, White on GRND, Blue on SCL, Green on SDA.
Red on VIN, Purple on 3V, White on GRND, Blue on SCL, Green on SDA.
20210805_122311.jpg (479.75 KiB) Viewed 87 times
Yellow on SDO, Brown on CS
Yellow on SDO, Brown on CS
20210805_122254~4.jpg (954.77 KiB) Viewed 87 times

User avatar
dastels
 
Posts: 15817
Joined: Tue Oct 20, 2015 3:22 pm

Re: LIS3DH Accelerometer (something's f*cked)

Post by dastels »

What I can't tell from the photos, and something that is a surprisingly common problem: Are the header pins soldered to the sensor board or are they just through the board and into the breadboard?

Dave

User avatar
matt8011
 
Posts: 3
Joined: Thu Aug 05, 2021 12:16 pm

Re: LIS3DH Accelerometer (something's f*cked)

Post by matt8011 »

The pins are not soldered, I've never soldered before, any recommendations on how I'd go about doing that?

User avatar
dastels
 
Posts: 15817
Joined: Tue Oct 20, 2015 3:22 pm

Re: LIS3DH Accelerometer (something's f*cked)

Post by dastels »

That'd be why it's not working.

See https://learn.adafruit.com/adafruit-gui ... -soldering and https://learn.adafruit.com/collins-lab-soldering for some tips/advice/instruction on soldering.

Assuming you don't have a soldering iron, get something reasonably decent and it'll make things go much smoother. https://www.adafruit.com/product/4921 looks like a nice one. Having something adjustable is handy and a sturdy stand is indispensable. A hot soldering iron is not something you want rolling off the bench. Having a tip cleaner right there is nice, as well. That one is for 110v power, if that's not what you have where you live you should be able to find something comparable locally.

Dave

User avatar
matt8011
 
Posts: 3
Joined: Thu Aug 05, 2021 12:16 pm

Re: LIS3DH Accelerometer (something's f*cked)

Post by matt8011 »

Thank you, you have helped me immensely

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”