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 …
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.
FIXED: I realized I needed to plug my photon in to my USB port for the serial monitor to work (duh! ). I am now receiving the accelerometer data and after fixing a minor ground issue causing sporadic readings, I’m up and running!
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.
@FiDel, you mean you have now connected SCL to the A2 pin on your Photon and it works?
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.
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).
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.