Need Help with Basic Operation of ADXL362 with Photon

Hello,

I am very new to the photon and am trying to get the SimpleRead example from the ADXL362 library running on my photon. I’ve wired the ADXL362 to the SPI pins on the photon and checked my wiring several times. Do I need to modify the ADXL362_SimpleRead.ino code before flashing to my photon to get the SPI bus up and running? I literally just forked the example and flashed my device.

I’ve tried a number of things but continue to get “No devices available via serial” when viewing the particle CLI serial monitor. I’ve looked over some arduino + adxl362 tutorials (linked below) and scrubbed the library code for hours but can’t seem to figure out what i’m doing wrong. Any help would be greatly appreciated! Seems like i’m missing something simple …

https://ez.analog.com/docs/DOC-2222

Thank you very much for your help.

  • guessing you are using the ADXL362 library from Web IDE?
  • Consider using something like Putty or Coolterm as a serial terminal

I might be wrong but the library seems to use A0 for chip select via xl.begin(SS);

Thank you for your reply, kennethlimcp!

You are correct, I am using the ADXL362 library from the Web IDE.

Why do you recommend Putty or Coolterm over using particle serial monitor (CLI)? Do you think the issue could be with the particle CLI?

Looking at the adxl362.h file (from the library), I see the following line:

void begin(int16_t chipSelectPin = 10); 

which leads me to believe the library is using pin 10 (A2) for chip select which appears to match the SPI pin-out here and here. I tried replacing “SS” in the xl.begin(SS); line with “A0” and “10” but that didn’t fix the issue.

Pin 10 is not A2 on the :spark: Core.
On the Core A0 corresponds to 10, while A2 is equivalent to SS and is equivalent to 12.

FIXED: I realized I needed to plug my photon in to my USB port for the serial monitor to work (duh! :flushed: ). I am now receiving the accelerometer data and after fixing a minor ground issue causing sporadic readings, I’m up and running!

Thanks for your help.

1 Like

Hi accelerometer specialists! :wink:

I am also experiencing problems to get data out of this module.

Here is the sketch: (without the # for the include lines!)

#include "application.h"
#include "adxl362.h"

ADXL362 xl;

int16_t temp;
int16_t XValue, YValue, ZValue, Temperature;

void setup()
{
  Serial.begin(9600);
  xl.begin(SS);      // Setup SPI protocol, issue device soft reset
  xl.beginMeasure(); // Switch ADXL362 to measure mode
}

void loop()
{
  // Read all three axis in burst to ensure all measurements correspond to same sample time
  xl.readXYZTData(XValue, YValue, ZValue, Temperature);

  Serial.print(" X=");
  Serial.print(XValue);
  Serial.print("\t Y=");
  Serial.print(YValue);
  Serial.print("\t Z=");
  Serial.print(ZValue);
  Serial.print("\t TEMP=");
  Serial.println(Temperature);
  delay(100); // Makes serial monitor easier to observe
}

As there is no description of the connections for Particles in the library example “ADXL362_SimpleRead.ino”, I made my own table, based on this discussion.

Connections for Particle:

ADXL362         => Particle
-------         --------
VIN             => 3V3
GND             => GND
SCL             => A3
SDA(I?)         => A5 (MOSI)
SDO             => A4 (MISO)
CS              => A0

The serial monitor shows only empty variables:

X=0. Y=0. Z=0. TEMP=0
X=0. Y=0. Z=0. TEMP=0
X=0. Y=0. Z=0. TEMP=0
X=0. Y=0. Z=0. TEMP=0
X=0. Y=0. Z=0. TEMP=0

Does you breakout board include pull-up resistors on SCL and SDA? You need them with Particle products.

2 Likes

Sorry! It works now…
I changed SCL to A2 and it works…
Sorry to say @ScruffR :disappointed_relieved:

1 Like

@FiDel, you mean you have now connected SCL to the A2 pin on your Photon and it works? :confused:

A2 is the default Slave Select pin on the Photons primary SPI interface and does not provide an SPI clock (as A3 = SCK), so I’m genuinly puzzled as of how this can work.

But if it works, I won’t argue :wink:

1 Like

Yes indeed @ScruffR , it works fine…
It’s strange indeed. I’m always interested to know why this is…

And @bko : Indeed also without pull-up resistors.
I wonder if this break-out has them installed. (It’s the one I received with the Electron…)

In the photo, the blue wire connects A2 to CS, which is correct as @ScruffR points out above.

The break-out board must have pull-ups since (1) they are required and (2) the Photon does not have them.

2 Likes

I found a schema of the board showing the pull-ups

And thanks for the photo, it in fact does show, that I’m not completely bonkers (at least on this front ;-))
Your yellow wire goes from A3 to SCL, so I’m happy again.

BTW: If you use xl.begin(A2); instead of SS things might also be a bit clearer ((CS) = SS = A2, but only A2 is printed on the silk screen).

1 Like

OK, great! It’s all my misunderstanding then!
Thanks @bko and @ScruffR for your kind and prompt help.

1 Like

My mistake on the pull-ups–I was thinking this was i2c where they are absolutely required. But it is SPI where the master only drives SCL and SDA so you do not technically need them to operate.

They are still a good idea since without them the inputs on the slaves are floating when the master is not set up to drive them yet. Floating inputs can lead to problems sometimes, particular in noisy electrical environments.

3 Likes

Yes, thanks for your explanation @bko , it seemed like a mix between SPI and I2C to me…