Hi! I just started with Blynk, I really love the app. Beautiful design and functional!
I have a setup with a Adafruit Feather nrf52382 and a Myoware EMG sensor. I’ve gotten all to work seamlessly in connecting to my android thanks to great guides, but the trouble is that when I use the super chart, and export I only get one registered value per minute, sent in the .CSV files.
The sensor is sampling much more which I can see at the pin and the super chart. Is there some possibility to sample and export at a higher rate? It does not have to be in a CSV, but one value per minute is not enough to sample muscle contractions. I have the super chart set at “live”.
Thank you very much I would really like to use Blynk for the app. I am new to programming in Arduino/C. Here is my Script:
#include <BlynkSimpleSerialBLE.h>
#define BLYNK_USE_DIRECT_CONNECT
#define BLYNK_PRINT Serial
char auth[] = "95f0807f7c0d4addaa5b59d899f1c005";
int sensorData = 0; // value read from the pot
#include <bluefruit.h>
// BLE Service
BLEDis bledis; // device information
BLEUart bleuart; // uart over ble
BLEBas blebas; // battery
BlynkTimer timer; // Announcing the timer
void myTimerEvent()
{
sensorData = analogRead(A1);
Blynk.virtualWrite(V5, sensorData*(5.0 / 1023.0));
}
// Use Virtual pin 5 for uptime display
#define PIN_UPTIME V5
// This function tells Arduino what to do if there is a Widget
// which is requesting data for Virtual Pin (5)
BLYNK_READ(PIN_UPTIME)
{
// This command writes Arduino's uptime in seconds to Virtual Pin (5)
Blynk.virtualWrite(PIN_UPTIME, millis() / 1000);
}
void setup()
{
Serial.begin(9600);
// while ( !Serial ) delay(10); // for nrf52840 with native usb
Serial.println("Blynk Bluefruit52 Example");
Serial.println("---------------------------\n");
// Setup the BLE LED to be enabled on CONNECT
// Note: This is actually the default behaviour, but provided
// here in case you want to control this LED manually via PIN 19
Bluefruit.autoConnLed(true);
// Config the peripheral connection with maximum bandwidth
// more SRAM required by SoftDevice
// Note: All config***() function must be called before begin()
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
Bluefruit.begin();
// Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
Bluefruit.setTxPower(4);
Bluefruit.setName("Bluefruit52");
//Bluefruit.setName(getMcuUniqueID()); // useful testing with multiple central connections
Bluefruit.setConnectCallback(connect_callback);
Bluefruit.setDisconnectCallback(disconnect_callback);
// Configure and Start Device Information Service
bledis.setManufacturer("Adafruit Industries");
bledis.setModel("Bluefruit Feather52");
bledis.begin();
// Configure and Start BLE Uart Service
bleuart.begin();
// Start BLE Battery Service
blebas.begin();
blebas.write(100);
timer.setInterval(0.05L, myTimerEvent);
// Set up and start advertising
startAdv();
// Init Blynk
Blynk.begin(auth,bleuart);
}
void startAdv(void)
{
// Advertising packet
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
Bluefruit.Advertising.addTxPower();
// Include bleuart 128-bit uuid
Bluefruit.Advertising.addService(bleuart);
// Secondary Scan Response packet (optional)
// Since there is no room for 'Name' in Advertising packet
Bluefruit.ScanResponse.addName();
/* Start Advertising
* - Enable auto advertising if disconnected
* - Interval: fast mode = 20 ms, slow mode = 152.5 ms
* - Timeout for fast mode is 30 seconds
* - Start(timeout) with timeout = 0 will advertise forever (until connected)
*
* For recommended advertising interval
* https://developer.apple.com/library/content/qa/qa1931/_index.html
*/
Bluefruit.Advertising.restartOnDisconnect(true);
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
}
void loop()
{
Blynk.run();
timer.run(); // running timer every second
}
// callback invoked when central connects
void connect_callback(uint16_t conn_handle)
{
char central_name[32] = { 0 };
Bluefruit.Gap.getPeerName(conn_handle, central_name, sizeof(central_name));
Serial.print("Connected to ");
Serial.println(central_name);
}
/**
* Callback invoked when a connection is dropped
* @param conn_handle connection where this event happens
* @param reason is a BLE_HCI_STATUS_CODE which can be found in ble_hci.h
* https://github.com/adafruit/Adafruit_nRF52_Arduino/blob/master/cores/nRF5/nordic/softdevice/s140_nrf52_6.1.1_API/include/ble_hci.h
*/
void disconnect_callback(uint16_t conn_handle, uint8_t reason)
{
(void) conn_handle;
(void) reason;
Serial.println();
Serial.println("Disconnected");
Blynk.run();
}