Register more than one value per minute?

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();
    }

You should read the documentation…

Superchart supports currently 2 types of granularity:

  • Minute granularity - 1h , 6h , 1d ;
  • Hour granularity - 1w , 1m , 3m ;

This means that minimum chart update interval is 1 minute for 1h , 6h , 1d periods. 1 hour for 1w , 1m and 3m periods. As Blynk Cloud is free to use we have a limit on how many data you can store. At the moment Blynk Cloud accepts 1 message per minute per pin. In case you send your data more frequently your values will be averaged. For example, in case you send value 10 at 12:12:05 and than again 12 at 12:12:45 as result in chart you’ll see value 11 for 12:12.

In order to see data in chart you need to use either widgets with “Frequency reading” interval (in that case your app should be open and running) or you can use Blynk.virtualWrite on hardware side. Every Blynk.virtualWrite command is stored on server automatically. In that case you don’t need application to be up and running.

https://docs.blynk.cc/#widgets-displays-superchart

Pete.

Thank you for your response. I have tried to figure out what to do. If I for example send data with the webhook widget I can only send one value per second. What is your suggestion for me to use instead to access all my datapoints? Do I need to use the local server, I don’t have experiecne working with servers so just saving the data on device storage or send to CSV would be very nice.

I don’t use local server, or have a need to have a greater granularity than one data point per minute, so don’t know the answer to that.

If you don’t want to use a local server the you could use a service like Adafruit IO:

Their free service allows 30 data points per minute to be recorded and they’ll save the last 30 days of data. or, for $99 per year you can have 60 data points per minute and 60 days of storage.

I use the free service via Node-Red to log some data that I want to be easily visible outside of Blynk and it works well for me.

Pete.

What’s your ideal sampling frequency? Is this running continuously, 24-hours a day?

I just wanted to add a few thoughts regarding Adafruit IO. Adafruit IO is actually what lead me to Blynk.

Adafruit IO is simple and elegant, much like Blynk. However, unlike Blynk, I think Adafruit IO is a little too simple.

Adafruit IO doesn’t have an effective way of dealing with multiple devices … no device tiles, no device selector, no nothing.

Adafruit IO is based on the notion of “feeds”. A feed is analogous to a virtual pin. However, based on my experience, feeds are specific to a device. With Blynk, each device has 256 virtual pins. I can associate a widget with a virtual pin and then dynamically associate the widget with a device. With Adafruit IO, the association is static. You manually associate feeds with widgets. You add a new device, you manually associate new feeds with more widgets. Personally, unlike Blynk, I don’t consider Adafruit IO to be a viable, scalable IoT solution. That’s not to say it won’t satisfy some IoT applications (e.g., those involving a handful of devices).

I’m not sure Adafruit IO is any better suited than Blynk to continuously log per-second data points. Although the Adafruit IO paid service will support 60 data points per minute, I really don’t think it was intended to be used that way. Over short durations / bursts, sure. I think you’ll run into problems in attempting to sustain this. I think you’d be better off with a micro SD card Adalogger FeatherWing. Store the data points locally and then periodically off-load them.

I signed up for the Adafruit IO+ (paid month-to-month service). If I remember correctly, I wasn’t billed for the first few months. That gave a good chance to experiment with it. However, I found it lacking and went in search of an IoT platform that handled multiple devices. And I found Blynk. Of course, Blynk has its own shortcomings in this regard, however, it’s a major improvement over Adafruit IO.

Blynk and Adafruit IO are somewhat apples and oranges. I don’t have hands-on experience with Node-red, however, I assume that’s more apples and apples. I’ll defer that comparison to @PeteKnight. Of course, as part of the next major release, I think we’re all expecting a Blynk dashboard.

I wasn’t meaning to suggest that the Adafruit IO service is any way a replacement for Blynk - it’s not!

I actually have situation where I’m using a table in the Blynk app to show some data. It’s actually a log of when the front gate in Spain is released, and to make life easy for myself I created a button in the app to clear the data from the table. It’s handy when we have visitors to be able to quickly check if they’ve arrived back at the house without calling them to check. The less data in the table the better most of the time.
However, I also wanted to have an archive that couldn’t be cleared by a quick slip of the thumb, to monitor the comings and goings of keyholders and contractors while we’re away. I could have handled it all within Blynk, but decided that it was easier just to offload the data stream to Adafruit. That’s really easy from Node-Red - you just set-up an outbound websocket node to Adafruit with the Adafruit key and squirt the data at it.
It also has the advantage that I can either view the data in a data feeds app on my phone, or via the website on my desktop screen.

The Adafruit solution was really just something I’d stumbled across and decided to give it a try. It’s fine for what it is - a data logging service, but with the introduction of Blynk’s reporting widget it’s only real advantage is that it logs raw data in real time rather than doing the one minute average thing that Superchart does.

I’ve used SD cards for data logging in the past and they’re okay, until they decide to die on you without any warning. Even top quality cards don’t seem to like having data written to them repeatedly.
Also you lose data when you pull the card to retrieve the data, and trying to do once per second writes and at the same time extract historic data and squirt it out over some other interface inst my idea of a fun program to write!

Pete.

Adafruit IO is more than just a data logging service. It has pretty switches, buttons, sliders, color pickers, number pads, … much like Blynk,

It can control as well as monitor / log … control and monitor from any Internet-connected, browser-enabled device without the need for a special “app”. However, I agree. Adafruit IO is not a replacement for Blynk. Blynk is multi-dimensional. Once we have a Blynk dashboard, that’ll be yet another dimension.

Ohhh, an actual number pad “block/widget”, like I have been requesting for Blynk :wink:

2 Likes

I was thinking of you, @Gunner, as I cut-n-pasted that Adafruit UI screenshot.

2 Likes

Yes, I’d forgotten about that.
I did look at it briefly and it seemed less useful that the dashboard built in to Node-Red (which I dislike, so don’t use). By that point I was using Blynk, which was a much better solution, so I promptly forgot about the Adafruit “widgets”.

Pete.