Đã Đóng

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;

break;

}

}

// 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

samplesRead++;

// 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]();

}

}

//*************************

}

Kĩ năng: Arduino, Điện tử, Vi điều khiển, Kĩ thuật điện, Lập trình C

Về khách hàng:
( 15 nhận xét ) Amsterdam, Netherlands

ID dự án: #35398486

7 freelancer chào giá trung bình€33 cho công việc này

Adeel2k14

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 Thêm

€19 EUR trong 7 ngày
(36 Nhận xét)
5.4
ninja1Developer

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 Thêm

€19 EUR trong 2 ngày
(8 Nhận xét)
4.2
ozdemirmcihad

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 Thêm

€45 EUR trong 7 ngày
(7 Nhận xét)
4.4
Work12345x

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

€19.01 EUR trong 1 ngày
(2 Nhận xét)
1.4
castillajoselui3

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

€50 EUR trong 1 ngày
(1 Nhận xét)
0.6
mushtakh

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

€29 EUR trong 5 ngày
(0 Nhận xét)
0.0
anthonyroo

✔️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 Thêm

€50 EUR trong 1 ngày
(0 Nhận xét)
0.0