Bonus Lab Steps

Add the X-Value of the onboard Acceleromter
Requires importing the MMA8652 library into project
https://os.mbed.com/components/MMA8652-Accelerometer/


// Include MMA8652 header file
#include "MMA8652.h"


// Create an instantiation of the accelerometer
MMA8652 acc(P3_23, P3_24);

// Add an empty callback to support the observability of the GET request
void accel_callback(const M2MBase& object, const NoticationDeliveryStatus status){}

// Add Mbed Cloud Client Resource
MbedCloudClientResource *accel = mbedClient.create_resource("3313/0/5702", "accel_resource"); // Accelerometer / Instance / X Value
accel->set_value("0");
accel->methods(M2MMethod::GET);
accel->observable(true);
accel->attach_notification_callback(accel_callback);
    
    
// Add local variables to main() to handle storing accelerometer data
float acc_data[3];
char buffer[10];


// Add code to main while loop to periodically read and set accelerometer data
acc.ReadXYZ(acc_data);
int size = snprintf(buffer,10,"%1.4f",acc_data[0]);
accel->set_value(buffer);