ARduino BLE sketch send dynamic data

Job Description:

Hi I want to send if there is motion measured with the accelometer. I use the BLE sense with integrated accelometer.

The accelometer is working . also send advert data is working. Only I am nog able to send dynamic values for this one: completeRawAdvertisingData[] = {0x02,0x01};

So need the sketch changed so I can send both 0x02,0x01 (if motion) and 0x01,0x02, (if no motion)

See code below:

#include <ArduinoBLE.h>


#include <LSM6DS3.h>

#include <Wire.h>

//Create a instance of class LSM6DS3

LSM6DS3 myIMU(I2C_MODE, 0x6A); //I2C device address 0x6A

float aX, aY, aZ, gX, gY, gZ;

const float accelerationThreshold = 1.5; // threshold of significant in G's

const int numSamples = 60;

int samplesRead = numSamples;


BLEService myService("fff0");

BLEIntCharacteristic myCharacteristic("fff1", BLERead | BLEBroadcast);

// Advertising parameters should have a global scope. Do NOT define them in 'setup' or in 'loop'

uint8_t completeRawAdvertisingData[] = {0x02,0x01};

void setup() {

[login to view URL](9600);

// while (!Serial);


if ([login to view URL]() != 0) {

[login to view URL]("Device error");

} else {

[login to view URL]("aX,aY,aZ,gX,gY,gZ");



if (![login to view URL]()) {

[login to view URL]("failed to initialize BLE!");

while (1);


[login to view URL](myCharacteristic);

[login to view URL](myService);

// Build advertising data packet

BLEAdvertisingData advData;

// If a packet has a raw data parameter, then all the other parameters of the packet will be ignored

// [login to view URL](completeRawAdvertisingData, sizeof(completeRawAdvertisingData));

[login to view URL](completeRawAdvertisingData, sizeof(completeRawAdvertisingData));

// Copy set parameters in the actual advertising packet

[login to view URL](advData);

// Build scan response data packet

BLEAdvertisingData scanData;

[login to view URL]("Test advertising raw data");

// Copy set parameters in the actual scan response packet

[login to view URL](scanData);

[login to view URL]();

[login to view URL]("advertising ...");


void loop() {

[login to view URL]();

// Here I want the variable completeRawAdvertisingData be filled with

//0x01,0x02 . then I kniow that there is no motion.


// wait for significant motion

while (samplesRead == numSamples) {

// read the acceleration data

aX = [login to view URL]();

aY = [login to view URL]();

aZ = [login to view URL]();

// sum up the absolutes

float aSum = fabs(aX) + fabs(aY) + fabs(aZ);

// check if it's above the threshold

if (aSum >= accelerationThreshold) {

// reset the sample read count

samplesRead = 0;




// check if the all the required samples have been read since

// the last time the significant motion was detected

while (samplesRead < numSamples) {

// check if both new acceleration and gyroscope data is

// available

// read the acceleration and gyroscope data


// Here I want the variable completeRawAdvertisingData be filled with

//0x02,0x01 .then I know that there is motion.

// print the data in CSV format

[login to view URL]([login to view URL](), 3);

[login to view URL](',');

[login to view URL]([login to view URL](), 3);

[login to view URL](',');

[login to view URL]([login to view URL](), 3);

[login to view URL](',');

[login to view URL]([login to view URL](), 3);

[login to view URL](',');

[login to view URL]([login to view URL](), 3);

[login to view URL](',');

[login to view URL]([login to view URL](), 3);

[login to view URL]();

if (samplesRead == numSamples) {

// add an empty line if it's the last sample

[login to view URL]();





Compétences : Arduino, Electronique, Microcontrôleur, Génie Électrique, Programmation C

Concernant le client :
( 15 commentaires ) Amsterdam, Netherlands

Nº du projet : #35398486

7 freelances font une offre moyenne de 33 € pour ce travail


Greetings thanks for posting the project here i am electrical engineer i have expertise in analog electronics systems, PCB designing and circuit designing. I can work on latest engineering tools to accomplish your task Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% EUR en 7 jours
(36 Commentaires)

Hi there, I am Ahmed an embedded systems developer, with a Master degree on EE. I have read your project requirements and I understand that you want to detect motion using LMS6DS3 sensor and report that via BLE, I thi Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% EUR en 2 jours
(8 Commentaires)

HELLO; I am working as a research and development manager in a private company. I have more than 5 years of experience in embedded system software and hardware. As for software, I am proficient in microcontrollers such Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% EUR en 7 jours
(7 Commentaires)

I can do this for you. Please view my past submitted work in my portfolio's Portfolio Items section.

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(2 Commentaires)

Hello I have checked your project description I will complete within 3hours. Please ping me. All the best.

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(1 Évaluation)

I understand the working of both IMU sensors and BLE. So if you five this project to me I can do it

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% EUR en 5 jours
(0 Commentaires)

✔️hello sir, how are you.✔️ I read your proposal and i am interested in this project. I have much experience on Circuit design, Hardware design, PCB design, Firmware, C/C++, Micro Python development. Let us discuss t Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(0 Commentaires)