Can you analogRead, save it in array, and the virtualwrite?

Hi, I am using a nodeMCU ESP8266 to upload ECG signal data to a superchart.

In order to have better output for the graph. Is it possible to save the analogRead(A0) values in an array and then virtual write it after 10ms?

Really need help with this. I am just using the basic virtualwrite. Can you suggest modifications?

/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************

  This example shows how value can be pushed from Arduino to
  the Blynk App.

  WARNING :
  For this example you'll need Adafruit DHT sensor libraries:
    https://github.com/adafruit/Adafruit_Sensor
    https://github.com/adafruit/DHT-sensor-library

  App project setup:
    Value Display widget attached to V5
    Value Display widget attached to V6
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>


// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "5dc460059a4a4136b74d55231e2cf359";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";

#define ANALOGIN A0          // What digital pin we're connected to



BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
  
  int h = analogRead(A0)/10;  
  


  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, A0);
  
}


void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);


  // Setup a function to be called every second
  timer.setInterval(100L, sendSensor);
}

void loop()
{
  Blynk.run();
  timer.run();
}

Not AFAIK and not sure what benefit you would get.

You could read the value say 1000 times per second and then take an average for upload to Superchart.

What data is the ECG collecting and over what time period does it prove useful?

An ECG signal completes a whole cycle in 1.2 seconds. So even 100ms does not get the best shape for the graph.
For now, we are getting something like this. If we could upload arrays then more data points could be added hence a better graph. Do you have suggestions to make it better? How do you suggest to average the data?

For your project I would check these guys out

1 Like

Hmmm… I admit I am not experienced with Arrays… so I don’t know how to “write and store” data to them… but if not possible then I suppose you could also use EEPROM or even a SD card? for fast storring of high throughput analog data.

Then, after a predetermined time, process the data and send it out to a virtual pin on the chart at a rate suitable for visual purposes.

The thing is, 99% of that is all in the hardware/code and not Blynk specific… so you need that first.

Unfortunately, batch data upload is not yet implemented, though planned.

Check out “smoothing data”, there are example in the forum.