Problem with ADXL345_Sparkfun_Particle.h

when i add this library in web ide to my code I get this error


any ideas what i’m doing wrong?
thanks

The reason for this error is that the contributor of this library changed the name of the library but not the names of the individual files.

When you look at the actual file names in the library you'll find that there are only these files
image

Once you change the automatically generated include (which uses the library name as default) to reference an existing file, things should work.

That's also why it's often advisable to start with one of the library examples to check whether the library works at all and what you'd need to do when using such library in your own project.

2 Likes

Thank you for figuring that out and the great advise on libraries

i changed the spelling and got the same error with new spelling
i’m way out of my league on the adxl345
let me start at the beginning i’m trying to make a device that sends a text if one of our machines gets shaken
i got the boron to work with an 801 sensor and send a text through web hook and pushover with the help of this community
but the 801 was not able to be adjusted to tell the difference between the door being shut or someone shaking machine.. so i got the bright idea to use a adxl345 accelerometer in hopes it could be adjusted to tell the difference. but i’m finding out i’m not good enough to figure out the adxl345
can you guys recommend someone i can pay to figure out how to integrate the adxl345 into my project?
thanks

Have you tried the library examples?
e.g. this one Particle Web IDE

1 Like

Hi @cal39 -

I do not know much about your use-case, but you may want to look at these little sensors from SignalQuest

They are extremely simple to use and do not consume any power when not in trigger-state. I have used them extensively in a similar situation where I simply needed to detect motion/vibration and did not need to know the exact extent or nature of the movement.

In the photo below I used their tilt sensors to detect wether the device has been tilted by more than 15° in either direction. Actually replaced the ADXL385 which I initially had planned the application in the photo in order to extend battery life.

The vibration sensors are just as easy to implement and are omnidirectional.

They have several options.

Hope this helps.

PS: I am planning a Particle Photon 2 tutorial with 6 axis sensor WSEN-EVAL ISDS sensor soon

1 Like

i couldn’t find any example that i could understand :sweat_smile:
i found someone that is willing to help me
do you know how i can share my ide with someone else so they can write the code and have access to my boron if it is plugged in to my ide ?
is that possible
thanks

that might work but i kinda need adjustment of how much of an angle will trigger the boron
is there anything like that😅
also i found someone willing to help me with code
is there a way for them to access my ide and possibly download to my boron remotely?
thanks :pray:

Hi @cal39 -

Haha, best of both worlds!! They only have set tilt angles, 15° and I think 30° (not sure about the last one) In addition to that, they have a range of impact sensors with more options, but they will not measure tilt angles.

As far as I know this is not possible. There is a SHARE button in the webIDE though that will generate a link. You can send this link to the person assisting you, but it IS NOT a collaboration function. He will need to do the same if you want to see the code he wrote. You could the duplicate and save that from the link he sent back.

Not sure whether VSC maybe has an extension for this.

hhmmm.... the Boron will have to be allocated to a user account they have access to. If you are using the webIDE it means they will need access to "your webIDE."

I stand to be corrected of course :slight_smile:

Regards, Friedl.

@cal39, doing simple googling on using the ADXL345 for sensing shake or other motions, I get some interesting sites.
This Adafruit Circuit Playground article shows how total acceleration, basically the magnitude of the acceleration vector, can be used for detecting shake. Closing a door would produce a "pulse" on one of the axes whereas shaking would affect two or three axes, thus the reason for using the overall acceleration vector for shake detection. The Circuit Playground does not use the ADXL345 but wouldn't be much different for your application.

This other article from TronicsBench shows how to use the ADXL345's different detection mode including limited tilt angle.

If you do a bit of searching, you will likely find everything you need!

1 Like

thanks
the guy who is helping me with the code is using an mpu6050 gyroscope and accelerometer
hes using arduino ide with serial monitor
do you know how i gith particals ide to show a serial monitot?
i found an events page on partical ide but nothing is populating when we are using the mpu6050 example
its says something like get events to appear in the streamby using partical.publish()

do i need to change serial.printr to particle .publish?
void loop() {
// read raw accel/gyro measurements from device
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
Serial.print("a/g:\t");
Serial.print(ax); Serial.print("\t");
Serial.print(ay); Serial.print("\t");
Serial.print(az); Serial.print("\t");
Serial.print(gx); Serial.print("\t");
Serial.print(gy); Serial.print("\t");
Serial.println(gz);

thanks

Hi @cal39 -

If you want to display the info in the web console, you would use Particle.publish();

You COULD do something like this;


Particle.publish("AX:" + String(ax) + " AY:" + String(ay) + " AZ:" + String(ay), PRIVATE);

There are much neater ways to do it though and some really clever guys in the forum that might eb able to assist with the best way to do it. I can try a little later, but still at work, so it will only be in a couple of hours. :smiling_face:

I have not tested this... hopefully someone can point out any mistakes :slight_smile: I am not a programmer at all... not even close, but feel free to try the code below

// above Setup declare the msg and size
char msg[64];

// in your function construct the message

snprintf(msg, sizeof(msg)
        , "%3d AX, "                              
          "%3d AY, " 
          "%3d AZ\r\n"
        , (ax)
        , (ay)
        , (az)
        );

// Send messages to Particle Cloud
Particle.publish("Gyroscope", msg);   

1 Like

@ScruffR -

Thanks for the edit. Did I not remove my comments? :melting_face:

1 Like

thanks i havent tried code yet i have to go to work but i cant seem to figurge out where the web console is i found events is that the page where data should populate when i try your code?

also in arduino theres a baud rate you have to include . does particle have similar requirement?
here is our example code we are trying to adapt to particle ide. notice there is serial begin?
do we remove serial begin and insert your code? thanks again for help

int ledPin = D7;

// MPU variables:
MPU6050 accelgyro;
int16_t ax, ay, az;
int16_t gx, gy, gz;

bool ledState = false;

void toggleLed() {
    ledState = !ledState;
    digitalWrite(ledPin, ledState ? HIGH : LOW);
}

void setup() {
    pinMode(ledPin, OUTPUT);

    Wire.begin();
    Serial.begin(9600);

    // The following line will wait until you connect to the Particle device using serial and hit enter.
    // This gives you enough time to start capturing the data when you are ready.
    // So, open a serial connection using something like:
    // particle serial monitor
    while (!Serial.available()) {
        Particle.process();
    }

    Serial.println("Initializing I2C devices...");
    accelgyro.initialize();

    // Verify the connection:
    Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
}

void loop() {
    // read raw accel/gyro measurements from device
    accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
    
    Serial.print("a/g:\t");
    Serial.print(ax); Serial.print("\t");
    Serial.print(ay); Serial.print("\t");
    Serial.print(az); Serial.print("\t");
    Serial.print(gx); Serial.print("\t");
    Serial.print(gy); Serial.print("\t");
    Serial.println(gz);

    toggleLed();

    delay(1000); // Delay for 1 second (1000 milliseconds)
}

Hi @cal39 -

When you click on that icon it will take you to the device in your Particle Web console. It should look something like this...

You should be ok with you code as is, but to get data in Particle Cloud you need to use Particle.publish() To start I would take one of the readings and first test:

Serial.print("a/g:\t");

Serial.print(ax); Serial.print("\t");
Particle.publish("AX: " + String(ax), PRIVATE);

Serial.print(ay); Serial.print("\t");
Serial.print(az); Serial.print("\t");
Serial.print(gx); Serial.print("\t");
Serial.print(gy); Serial.print("\t");
Serial.println(gz);

This should publish all the AX data to Particle Cloud every one second (set by the delay in your Loop() {} )

Once you have this working you can tidy up the message and send all the data from the different axis in a single publish (as per my previous message)

Hope this helps.

thanks
we cant get anything to populate in serial monitor :sweat_smile:is this where it should populate sensor data?

which is the box to the right where it says events in console?

Hi @cal39 -

This is where you will see data sent using Particle.publish() The console to the right will give you more details about each publish when you click on in it.

Can you send me your code? I can take a look if you want?

ps: I will see whether I can do a Tutorial for Particle using WSEN-EVAL ISDS It will take couple of days though but can see how quickly I ca get some code to you which you can then use to build your application. You would have to get gold of one of those modules then, as I do not have any ADXL modules.

Regards,
Friedl.

thats awesome thank you
we dont need it to go to cloud unless the cloud is the console
we just want to see data as we tilt a mpu6050 module
to see if our iic and the module are working
also do we need a wire library along with 6050 library
in this code we were trying to get an led to light if sensor was tilted, but that didnt work either :sweat_smile:
here is our code
// Once you import this library into an app on the web based IDE, modify the code to look something like the following.
// This code is a heavily modified version of the MPU6050_raw.ino example found elsewhere in this repo.
// This code has been tested against the MPU-9150 breakout board from Sparkfun.

// This #include statement was automatically added by the Particle IDE.
#include "MPU6050.h"

int ledPin = D7;

// MPU variables:
MPU6050 accelgyro;
int16_t ax, ay, az;
int16_t gx, gy, gz;

bool ledState = false;
void toggleLed() {
ledState = !ledState;
digitalWrite(ledPin, ledState);
}

void setup() {
pinMode(ledPin, OUTPUT);

Wire.begin();
Serial.begin(9600);

// The following line will wait until you connect to the Spark.io using serial and hit enter. This gives
// you enough time to start capturing the data when you are ready instead of just spewing data to the UART.
//
// So, open a serial connection using something like:
// screen /dev/tty.usbmodem1411 9600
while(!Serial.available()) SPARK_WLAN_Loop();

Serial.println("Initializing I2C devices...");
accelgyro.initialize();

// Cerify the connection:
Serial.println("Testing device connections...");
Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");

}

void loop() {
// read raw accel/gyro measurements from device
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
Serial.print("a/g:\t");
Serial.print(ax); Serial.print("\t");
Serial.print(ay); Serial.print("\t");
Serial.print(az); Serial.print("\t");
Serial.print(gx); Serial.print("\t");
Serial.print(gy); Serial.print("\t");
Serial.println(gz);

toggleLed();

}

1 Like

Hi @cal39

Let's start by testing your connections to the module. From your post I gather yo are using I2C ??

Copy and paste the code below into a new sketch and upload. The, in the console (yes Console is the cloud based section) you should see the results.

#include <Wire.h>
 
 
void setup() {
    
  Wire.begin();
 
  Serial.begin(9600);
  while (!Serial);             
  Serial.println("I2C Scanner");

//    pinMode (D4, OUTPUT);
//    digitalWrite(D4, LOW);
    
}
 
 
void loop() {
    
  byte error, address;
  int nDevices;
 
  Particle.publish("Scanning...");
 
  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
 
    if (error == 0)
    {
      Particle.publish("I2C device found at address 0x" + String(address,HEX), PRIVATE);
      nDevices++;
    }
    
    else if (error==4)
    {
      Particle.publish("Unknown error at address 0x");
        if (address<16)
        Serial.print("0");
        Particle.publish(String(address,HEX), PRIVATE);
    }    
  }
  
  if (nDevices == 0)
    Particle.publish("No I2C devices found");
  else
    Particle.publish("done");
 
  delay(5000);           // wait 5 seconds for next scan
} 

If you do indeed find the I2C device, we are on the right track and then need to look at the code itself. I see a function toggleLed((); being called in your void loop(); but cannot see where that function is, unless I am missing something obvious?

Regards, Friedl