"LIS3DH test! Couldnt start" why?

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Taronyu
 
Posts: 50
Joined: Fri Jun 16, 2017 6:17 pm

"LIS3DH test! Couldnt start" why?

Post by Taronyu »

I set it up for i2c wiring and changed the code like the demo says (https://learn.adafruit.com/adafruit-lis ... g-and-test)
but all I get in the serial monitor is "LIS3DH test! Couldnt start"
this is the code

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();

#if defined(ARDUINO_ARCH_SAMD)
// for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!
   #define Serial SerialUSB
#endif

void setup(void) {
#ifndef ESP8266
  while (!Serial);     // will pause Zero, Leonardo, etc until serial console opens
#endif

  Serial.begin(9600);
  Serial.println("LIS3DH test!");
  
  if (! lis.begin(0x18)) {   // change this to 0x19 for alternative i2c address
    Serial.println("Couldnt start");
    while (1);
  }
  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");
}

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 commented out the SPI stuff like it said but it just says it can't start the test

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: "LIS3DH test! Couldnt start" why?

Post by adafruit_support_bill »

Typically, that is a sign of a connection issue. Please post some clear photos showing your soldering and connections.

User avatar
Taronyu
 
Posts: 50
Joined: Fri Jun 16, 2017 6:17 pm

Re: "LIS3DH test! Couldnt start" why?

Post by Taronyu »

this is it
Attachments
IMG_3285.jpg
IMG_3285.jpg (317.69 KiB) Viewed 1226 times

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: "LIS3DH test! Couldnt start" why?

Post by adafruit_support_bill »

The soldering looks excellent. Please show us your connections also.

User avatar
Taronyu
 
Posts: 50
Joined: Fri Jun 16, 2017 6:17 pm

Re: "LIS3DH test! Couldnt start" why?

Post by Taronyu »

this is it connected
Attachments
IMG_3304.jpg
IMG_3304.jpg (400.29 KiB) Viewed 1181 times

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: "LIS3DH test! Couldnt start" why?

Post by adafruit_support_bill »

Looks like you have it wired for hardware SPI, but your code is expecting i2c wiring.

https://learn.adafruit.com/adafruit-lis ... i2c-wiring
I2C Wiring
Use this wiring if you want to connect via I2C interface

Connect Vin to the power supply, 3-5V is fine. Use the same voltage that the microcontroller logic is based off of. For most Arduinos, that is 5V
Connect GND to common power/data ground
Connect the SCL pin to the I2C clock SCL pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A5, on a Mega it is also known as digital 21 and on a Leonardo/Micro, digital 3
Connect the SDA pin to the I2C data SDA pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A4, on a Mega it is also known as digital 20 and on a Leonardo/Micro, digital 2

User avatar
Taronyu
 
Posts: 50
Joined: Fri Jun 16, 2017 6:17 pm

Re: "LIS3DH test! Couldnt start" why?

Post by Taronyu »

I changed the code to use the spi code but it says"avrdude: error: programmer did not respond to command: exit bootloader".how did he get on my computer and why is he killing my sensor? this is BANNED because now this sensor is unusable

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: "LIS3DH test! Couldnt start" why?

Post by adafruit_support_bill »

That error message has nothing to do with the sensor. AVRDude is the upload code in the Arduino IDE and it is having trouble communicating with your UNO.

Disconnect all external wiring from the UNO and try to upload the blink sketch. That will tell you if there is a problem with the wiring or the UNO itself.

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

Return to “Arduino”