What determines the sampling rate of an Arduino MKR1000 when connected over wifi?
10 views (last 30 days)
I have recently inherited a project in which I have an Arduino MKR1000 that is connecting to Matlab over wifi. It is then given a code that records the condition of a voltage sensor and a current sensor that are attached to the arduino. This code and arduino setup was all given to me as is, so I am trying to understand where it is all coming from. As of right now, the sampling rate is around 12.5 Hz, but we would like to get it up to ~200 Hz. The code that was given to me is shown below.
title('Voltage vs. Time')
title('Current vs. Time')
title('Power vs. Time')
My initial guess was that the code that was querying the sensors was not optimized, but from what I can tell, it's about as lean as possible. So my next guess was that it's possible the wifi is what is slowing down the sample rate?
The other question that I had was what is determining this sampling rate? As far as I can tell, the only thing that determines the sampling rate would be how quickly the loop can process 250 iterations.
I am new to data acquisition with using an Arduino and Matlab, but from what I understand the Arduino is capable of 1000 Hz sampling and Matlab is only limited by script speed, which should be well above the 200 Hz that we are looking for. I would appreciate any help and direction for this. There is a lot of data resources out there for sampling with a serial connection with an Arduino, but I haven't been able to find much in connection to the Wifi. Again, any help is appreciated. Thanks.
Madhu Govindarajan on 20 Nov 2019
This approach limits the speed in a variety of ways including lack of something close to a real-time OS, Wi-Fi communication speed etc. The speeds of 200 Hz would be more realistic for Simulink Hardware Support for Arduino. There is an equivalent Analog Read block there where in you can set a much higher sampling time to get desired results.