IOT linking the sensor data to the thing

I have a simple sketch that reads accelerometer data and what to display it on a dashboard.
I have included my code below.

How do i link or copy (accel.acceleration.x) to acc1 to display to my dashboard?
I cant simply make acc1 = acceleration!

Any help would be appreciated

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/2fdc2dbc-7eb5-4461-9fcf-e8c9000107c8 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  float yax;
  int accel;
  int acc1;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"
#include <Adafruit_MPU6050.h>

Adafruit_MPU6050 mpu;
Adafruit_Sensor *mpu_temp, *mpu_accel, *mpu_gyro;



void setup() {
   
  Serial.begin(115200);
  while (!Serial)
    delay(10); // will pause Zero, Leonardo, etc until serial console opens

  Serial.println("Adafruit MPU6050 test!");

  if (!mpu.begin()) {
    Serial.println("Failed to find MPU6050 chip");
    while (1) {
      delay(10);
    }
  }

  Serial.println("MPU6050 Found!");
  mpu_temp = mpu.getTemperatureSensor();
  mpu_temp->printSensorDetails();

  mpu_accel = mpu.getAccelerometerSensor();
  mpu_accel->printSensorDetails();

  mpu_gyro = mpu.getGyroSensor();
  mpu_gyro->printSensorDetails();


  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found

   delay(1500); 
 

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  
  

// accel =xxxx;                           // trying to copy to variable

 

 ArduinoCloud.update();
 sensors_event_t accel;
  sensors_event_t gyro;
  sensors_event_t temp;
  mpu_temp->getEvent(&temp);
  mpu_accel->getEvent(&accel);
  mpu_gyro->getEvent(&gyro);

  //.Serial.print("\t\tTemperature ");
  //.Serial.print(temp.temperature);
  //.Serial.println(" deg C");

 // Display the results (acceleration is measured in m/s^2) 
 //. Serial.print("\t\tAccel X: ");
 //. Serial.print(accel.acceleration.x);
 //. Serial.print(" \tY: ");
 //. Serial.print(accel.acceleration.y);
 //. Serial.print(" \tZ: ");
 //. Serial.print(accel.acceleration.z);
  //.'Serial.println(" m/s^2 ");

 // Display the results (rotation is measured in rad/s) 
//  Serial.print("\t\tGyro X: ");
 // Serial.print(gyro.gyro.x);
 // Serial.print(" \tY: ");
 // Serial.print(gyro.gyro.y);
 // Serial.print(" \tZ: ");
 // Serial.print(gyro.gyro.z);
 // Serial.println(" radians/s ");
 // Serial.println();

//  delay(100);

  //serial plotter friendly format
  Serial.print(temp.temperature);
  Serial.print(",");

 //. Serial.print(accel.acceleration.x);
  //.Serial.print(","); Serial.print(accel.acceleration.y);
  //.Serial.print(","); Serial.print(accel.acceleration.z);
  //.Serial.print(",");

  //.Serial.print(gyro.gyro.x);
  //.Serial.print(","); Serial.print(gyro.gyro.y);
  //.Serial.print(","); Serial.print(gyro.gyro.z);
  //.Serial.println();
  //.delay(10);
 
  
  
}




This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.