Bluetooth data logger for Arduino (Serial plotter)The purpose of the application is to collect and visualize data from Arduino platforms (Arduino NANO, MEGA, UNO et al.). Data transfer takes place via Bluetooth and requires a Bluetooth module that supports Bluetooth 4.0 LE (HM-10 Bluetooth module). HC-06, HC-05 modules CANNOT be used. The "float" type is used for data transfer. A single data stream achieves a sampling rate of approximately 245 Hz. If a greater sampling rate is required, the Vibration analysis application can be used. It achieves a sampling rate of approximately 1867 Hz. ![]() ![]()
Sketch 1:
///////////////////////////////
// © 2017 Dmitriy Kharutskiy //
///////////////////////////////
byte ByteArr[20];
int i = 0;
int ii = 0;
int X = 0;
float C;
float Y1;
float Y2;
float Y3;
float Y4;
float Y5;
void setup()
{
// put your setup code here, to run once:
Serial.begin(9600);
//Serial.begin(115200);
//D4 => GND
pinMode(4, OUTPUT);
digitalWrite(4, LOW);
}
void loop()
{
// put your main code here, to run repeatedly:
X++;
C = 2*PI*(1/100.0); // PI = Pi = 3.14159...
Y1 = sin(C * X);
C = 2*PI*(1/2000.0);
Y2 = 10 + sin(C * X) * 7;
Y3 = Y1 * Y2;
C = 2*PI*(1/90.0);
Y4 = sin(C * X);
Y5 = Y1 + Y4;
if (X == 30000) X = 0;
Marking();
//WriteToByteArr(Y1);
//WriteToByteArr(Y2);
WriteToByteArr(Y3);
//WriteToByteArr(Y4);
//WriteToByteArr(Y5);
//Serial.begin(9600);
delay(8); // 1: 124Hz
//delay(17); // 2: 58Hz
//delay(20); // 3: 50Hz
//delay(32); // 4: 31Hz
//delay(35); // 5: 28Hz
//Serial.begin(115200);
//delay(4); // 1: 245Hz
//delay(7); // 2: 140Hz
//delay(8); // 3: 122Hz
//delay(13); // 4: 75Hz
//delay(20); // 5: 48Hz
}
void Marking()
{
if (i >= 100)
{
for (int iii = 0; iii < 4; iii++)
{
ByteArr[ii] = 255;
i++;
ii++;
WriteFunction();
}
i = 0;
}
}
void WriteToByteArr(float value)
{
byte *p = (byte *)(&value);
for (int iii = 0; iii < 4; iii++)
{
ByteArr[ii] = *p++;
i++;
ii++;
WriteFunction();
}
}
void WriteFunction()
{
if (ii == 20)
{
Serial.write(ByteArr, ii);
ii = 0;
}
}
Setting up the HM-10 Bluetooth module to increase the data transmission rateThe Bluetooth module can be connected to a PC via a USB-UART adapter. However, this involves extra expenses and possibly unnecessary work of search for drivers and their installation. The Bluetooth module can also be configured via the Arduino Nano. However, the data transmission rate can be changed only up to 115200 bps, because SoftwareSerial does not support the 230400 bps transmission rate. Moreover, the actual increase in the transmission rate at 230400 bps is not observed, as compared to 115200 bps. And, unfortunately, SoftwareSerial cannot be used during operations of the Bluetooth accelerometer (if the sampling rate is over 500 Hz), because data sending via SoftwareSerial stops the main program for about 2 ms. SoftwareSerial Library Sketch 2: #include ![]() ![]() ![]()
Check if the command terminal work normally: AT ![]()
List all the commands: AT+HELP ![]()
Get firmware, bluetooth, HCI and LMP version: AT+VERSION ![]()
Get/Set baud rate: AT+BAUD (AT+BAUD8 => 115200 bps, AT+BAUD4 => 9600 bps) ![]()
|



Vibration analysis
BLE accelerometer
Tachometers
Video tachometer
Speedometers
DIY anemometer
DIY metal detector
Sound analysis
Turns counter
Photo Storage








