Ref: Sensor frequency

Namaste

I am glad to be able to submit a query to the Blynk community.

I request assistance with enabing a high refresh frequency for PUSH or PULL methods of obtaining data from a sensor.

Is it possible to obtain 50 Hz?

Following are my project details:
• Arduino UNO with Bluetooth
• Android OS, version 8.1.0
• Using Blynk server
• Blynk Library version 0.6.1

Thank you.

Could I ask what you’re doing that would need such a high refresh rate?

In the app, the maximum PULL rate is once a second (1hz) - to prevent the hardware from being overwhelmed.

It’s very possible to use a higher refresh rate with PUSH, you can just use VirtualWrite more frequently on your hardware. I’ve personally only updated once a second although you will likely be able to update it more frequently

It also depends on which sensor you’re using, DHT11s can only be read up to once every 2 seconds, could you give more details on which sensor you’re using. :slight_smile:

That all depends on what sensor you are wanting to pull data from and why you would need a 50Hz sample?

Many thanks, Martin, for your detailed response. Thanks also to JustBertC for dropping by.

The particular project I am working on has a duration of operation of just 2 seconds, and then it repeats again. Hence, I need to obtain several many readings.

With regards to your query about the sensor I am using, it’s the FlexiForce group of pressure sensors. Here’s a video of me using them on the iOS platform using an off-the-shelf app called BLExAR:

Hope I can acheive the same on the Blynk platform as well.

Best regards,
wirefree

When you say it’s only running for 2 seconds, I presume you mean it’s only recording data for 2 seconds - but the hardware remains powered after this. If this is the case you could always store the values in an array during the recording period, and then upload them at a slower rate after you finished recording?

You could always just try and use the PUSH every 20ms or something, no guarantees as to how stable this would be, but you may as well try :stuck_out_tongue_winking_eye:

An example of code to do this would look something like this:

In your setup:

updateTimer.setInterval(20, updateSensorValue);

This will run the updateSensorValue() function every 20ms (50hz)

Then in that function you would include: reading the sensor; and then posting that data to the app through a virtual pin. In the app I would recommend using a SuperChart attached to the same virtual pin, as that is most similar to what you show in the video.

I am unfamiliar with using BLE with Blynk, as I have only used Wi-Fi but I would assume they would be similar.

1 Like

I don’t think that this is a project that’s suitable for use with Blynk.

Also, if you’re planning to use the Superchart widget to display this data then you’re out of luck as it has a maximum granularity of one data point per minute.

Pete.

Are you sure that’s the case? I though it was much higher than that, in the LIVE / 15m time-base

That’s what the docs say:

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.

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

If Live/15 minutes displays are refreshed faster then this will be limited by the maximum write frequency to the server, which I believe is around 10Hz.
For reporting purposes the data is certainly only stored at 1 minute granularity.

Pete.

Sure, that sounds far more likely.

I had this very simple idea, to save the data at 50hz and then relay that information to the server at a much slower rate.

I quickly slapped together the following code, there is probably a much better way of doing it - please feel free to call it out if there is. But I thought that this could demonstrate the principle.

bool collectingData = false; 
bool sendDat = false
int count = 0;
int data[101]; //Array for storing data with 101 indexes (50hz * 2 secs = 100 [+1 for good luck :P])

void setup() {
  // put your setup code here, to run once:
  readTimer.setInterval(20, readSensorValue);
  sendTimer.setInterval(200, sendSensorValue); // 200 will turn the 2 seconds into 20 || 500 will be 50 seconds etc pick a value most suitable for you
}

void loop() {
  //When you want to start recording data for 2 seconds, call function "startRecording()"

}


void startRecording() {
  collectingData = true;
  sendDat = false;
  count = 0;
}

void readSensorValue() {
  if (collectingData){
    if (count <= 99){
      data[count] = //insert code here to read sensor
      count ++;
    }else{
      collectingData = false;
      sendDat = true;
      count = 0;
    }
  }
}

void sendSensorValue() {
  if (sendDat) {
    if (count <= 99){
      Blynk.virtualWrite(V1, data[count]);
      count ++;
    }else{
      sendDat = false;
      count = 0;
    }
  }
}

This code is obviously not finished and still requires all of the Blynk specific code.