How to make LIS3DH work with Argon?

Hi there,

I am new to Argon. The following code works with Electron, but it does not work with Argon. What needs to be changed? Any information will be appreciated.


// Connect the Adafruit LIS3DH breakout
// https://www.adafruit.com/products/2809
// VIN: 3V3
// GND: GND
// SCL: C5 (Electron Wire1)
// SDA: C4 (Electron Wire1)
// INT: WKP

  LIS3DHI2C accel(Wire1, 0, WKP);

  // Make sure you match the same Wire interface in the constructor to LIS3DHI2C to this!
  Wire1.setSpeed(CLOCK_SPEED_100KHZ);
  Wire1.begin();

  // Initialize sensor
  LIS3DHConfig config;
  config.setAccelMode(LIS3DH::RATE_100_HZ);

  bool setupSuccess = accel.setup(config);
  Serial.printlnf("setupSuccess=%d", setupSuccess);

    if(accel.getSample(sample)) 
      Serial.printlnf("%d,%d,%d", sample.x, sample.y, sample.z);

What exactly isn’t working? Are there compile errors, is there incorrect output, etc?

No compile errors. Just cannot get any sample.

Have you tried Wire instead of Wire1? I think there is a problem with Wire1 now on the mesh devices.

2 Likes

I think that’s it - I am using the Feather Prop wing and it works using Wire (not Wire1).

Peter

1 Like

@Ric @gothamsound Yes, it works. Thank you all.

1 Like

@anderson916, have you updated your Argon to 0.8.0-rc.26? The Wire1 issue should have been resolved with that version (although I haven’t tried it myself yet :blush:)
https://github.com/particle-iot/firmware/releases/tag/v0.8.0-rc.26

1 Like

Glad to know that. Can you tell me what is the difference between Wire and Wire1? @ScruffR

Wire1 is connected to a different set of pins.
Just look at the docs :wink:
https://docs.particle.io/reference/device-os/firmware/argon/#wire-i2c-