Data Streaming Frequency Limitations

Hello all,

I am new to thinger.io and I am also new to programming Arduino’s so I have been doing a LOT of learning, this is truly a wonderful platform you all have developed.

I currently am working with an MKR1000 and using it as a Data Acquisition device for voltage and current that is in a hard to reach place. I was curious as to what the limitations are on how many times a minute/second I am able to take a reading and send it to a bucket. I am familiar with the web interface allowing me to choose up to as much as once per second, but I also knew that I could write it into my code to update at whatever rate I wanted.

I implemented a very rough code that queried and streamed my sensor data very quickly (many times a second) and my device almost immediately got disconnected and I received an email saying that it has been disabled shown here:

Your device MKR1000 has been disabled due to excessive call fails. This often happens when your device calls your resources (endpoints or buckets) at inappropriate rate. Please, verify your device code.

Now as I’ve researched more and more the uses that people have used this platform for, I realize that I am rather outside of the normal scope of use.

So all of that being said, my question is: what is the absolute quickest I would be allowed to send data pieces to thinger.io. I currently am using free hosting through google, but I am curious what the possibilities would be with paid hosting as well. Any insight into this would be greatly appreciated.

Thanks :slight_smile:

Hello @NathanE,

Thank you so much for using Thinger.io community to resolve your doubts.

I’m not sure but I think this message is only sent with instructions like write_bucket or call_endpoint , but if you send it with thing.stream() there is no problem on sending for a short time period around one data each 100-150ms depending on the device.

I suggest you always include your code so we can help you better

best

Hello!

I apologize for not attaching the code earlier, in truth it was very sloppy and I was slightly embarrassed by it, and was just hoping to find out limitations. That being said after what you have explained I was able to work through it some more so have it send a signal every 5 seconds, and my serial monitor seems to be confirming that, but thinger.io is still only getting a data bit every 60 seconds, and I am not sure why. Here is my existing code:

#undef min
#undef max

#include <ThingerWifi101.h>

#define USERNAME "NathanE"
#define DEVICE_ID "MKR1001"
#define DEVICE_CREDENTIAL "###########"

#define SSID "NathanE"
#define SSID_PASSWORD "Arduino1"

unsigned long timer= 0;
float voltSensorValue = 0;
float Current = 0 ; 
float Strain = 0 ; 
float Voltage = 0;   

ThingerWifi101 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

void setup() {

  //Initialize serial communication (only for debugging)
  Serial.begin(9500);
  
    // configure wifi network
  thing.add_wifi(SSID, SSID_PASSWORD);

    // Setting up 4 outgoing resources to thinger.io
  thing["Time"] >> [=](pson& out){
    out = timer;
   };
  thing["Voltage"] >> [=](pson& out){
    out = Voltage ; 
  };
  thing["Current"] >> [=](pson& out){
    out = Current ;
  } ; 
  thing["Strain"] >> [=](pson& out){
    out = Strain ;  
  };
     
    // more details at http://docs.thinger.io/arduino/
  analogReadResolution(12);
}
void loop() {
  
  
  
  thing.handle();
  
  
  voltSensorValue = analogRead(A0)*(3.3/4095.0);
  Voltage = voltSensorValue*(1.0/(7.5/(7.5+30.0)));

  Serial.print(Voltage, 5);
  Serial.print(" Volts\n");
  
  thing.stream(thing["Voltage"]);
  
  delay(5000) ; 

}

void readSensors() {

//unused, possibly will be a condensed way of calling sensors and sending them
  
}

At first my initial belief was that thing.handle() was causing the loop to slow down, but upon trying to get rid of that I was no longer connecting to my wifi network so I quickly learned that is not the way to go :slight_smile:

I am sure that I am messing several core concepts, so I am open to any and all criticism, but I am specifically looking to understand why the above code is only sending Voltage data every 60 seconds instead of every 5. I have verified that the bucket is set to refresh based on device, and not at a specific sampling interval.

Thank you all for your time.

Today I logged in to continue adjusting this system and found some interesting information that might help someone in diagnosing my issue.

I set my code above with a couple changes shown wrapped in ** here:

void loop() {
  
  
  
  thing.handle();
  
  
  voltSensorValue = analogRead(A0)*(3.3/4095.0);
  Voltage = voltSensorValue*(1.0/(7.5/(7.5+30.0)));

  Serial.print(Voltage, 5);
  Serial.print(" Volts\n");
  
  **thing.stream("Voltage");**
  
  **delay(500) ;** 

}

So this got me some interesting results. As expected my serial monitor shows a reading every .5 seconds. My device connected on thinger.io and even showed a much increased data transmit rate, hard to say for sure, but what looked to be a bit of information every .5 seconds. When I saw this I got excited and checked my voltage bucket, but that bucket still seems to only be updating every minute as shown here:

So I am starting to think that something is restricting my bucket to only update once a minute, even though I am clearly streaming data more than once per minute. Curious to see if anyone has any ideas as to how valid this may be.

Thanks!

Hello @NathanE

At this point it is important to differentiate between getting data and storing data. Freemium accounts have a limitation of 1 data storage each 60 seconds. Of course this limitation is only for the freemium shared server accounts.

Streaming data to the platform is only to force any data to be sent to the server when an asynchronous event happens, instead of subscribing the device resource to be readed each few seconds/minutes and has to be used carefully, because if you call thing.stream() every loop() execution, you’ll be doing some very intensive polling to the platform ant this could saturate the host. So please, never put a thing.stream without a flow control

on the other had, using a 5s delay is not a good idea, because it is breaking the communication with the server, making necessary to re-connect each time. It is interesting not to use any delay() instruction on these codes.

best