Requests are too frequent. For further information, see Limitations in the documentation.

Carsten on 5 Jun 2023 (Edited on 6 Jun 2023)
Latest activity Reply by Carsten on 6 Jun 2023

Hi all,
I am so far on a free account.
I have setup 1 channel. I am sending 3 values from a bitShake SmartMeterReader every 20 seconds to this channel.
When trying to send additional data from my solar inverter every 5min! and calculate some data coming from my bitShake (e.g. once per hour) and send it back to the channel I receive the following error:
Requests are too frequent. For further information, see Limitations in the documentation.
Now I understand that my messages (write orperations) to my channel are limited to 3 Mio / year or 8200/day. With my current setup I am at little more than 4K messages per day and since I just recently started my account I have still 2.840.531 messages left.
How come I get that error even if I switch even if my message limit is far from reached?
Thanks in advance for your time! Much appreciated!
btw. The link "Limitations" where it is supposed to be explained is not working (for me)
Carsten
Carsten on 6 Jun 2023 (Edited on 6 Jun 2023)
Hi, thank you for your response.
The first code basically imitates the 2.8.0 (Einspeisung) of my solar power. I receive the value every 30 seconds. If it is negative I calculate the watt seconds (basically assume the value was constant fopr the last 30 seconds). After that I transform it into kWh and write it back to the channel once per hour via TimeControl.
% Definieren Sie den gewünschten Zeitraum
startDate = datetime('today'); % Startdatum
endDate = datetime('now'); % Aktuelles Datum
% Daten vom Stromverbrauch im gewünschten Zeitraum abrufen
consumptionTotal = thingSpeakRead(stromzaehlerChannelID, 'ReadKey', readAPIKey, 'Fields', 2, 'DateRange', [startDate, endDate]);
%disp(size(consumptionTotal));
% Rufen Sie die Funktion zur Berechnung des Energieverbrauchs auf
energyConsumption = calculateEnergyConsumption(consumptionTotal);
% Zeigen Sie das Ergebnis an
disp(energyConsumption);
thingSpeakWrite(writeChannelID,energyConsumption,'WriteKey',writeAPIKey, 'Fields', 6);
function energyConsumption = calculateEnergyConsumption(data)
timeInterval = 30; % Zeitintervall in Sekunden
% Initialisierung der Summe
totalEnergy = 0;
% Durchlaufen der Datenpunkte
for i = 1:length(data)
%disp(['data:',data(i)]);
if data(i) < 0 % Überprüfung auf Negativität
energy = data(i) * timeInterval; % Berechnung der Energie in Wattsekunden
totalEnergy = totalEnergy + energy; % Summierung der Energie
%disp(totalEnergy);
else %disp(int2str(data(i)));
end
end
energyConsumption = totalEnergy / 7200000; % Umrechnung in Kilowattstunden
end
The second code is simply receiving data from my Solax Inverter. Also via TimeControl every 10 minutes
api_url = 'https://www.solaxcloud.com/proxyApp/proxy/api/getRealtimeInfo.do?tokenId=XXXXXXXXXXXXXX&sn=XXXXXXXXXX';
api_call = webread(api_url)
writeChID = 1234567;
writeAPIKey = 'XXXXXXXXXXX';
res = struct(api_call.result)
acpower = res.acpower
yieldtoday = res.yieldtoday
getData = thingSpeakWrite(writeChID, [acpower,yieldtoday],'Fields',[4,5],'writeKey',writeAPIKey);
*sorry for the DE comments
Christopher Stapels
Christopher Stapels on 6 Jun 2023
Thats a good start, but the code you have shown has no delay or timing information in it, so I am unable to estimate how often the writes are happening. You do mention that you are writing back to the same channel, that may possibly be a source of overwriting. I suggest using a seperate channel for the derived information.
Can you show how you determine when (or how often) to write to thingspeak?
Carsten
Carsten on 6 Jun 2023
as mentioned I am using the "TimeControl" function ("Every 10 Min" & "Every 1 hour(s)).
I already played aroundn with these settings but no improvement.
I am new to MATLAB so I was under the impression that this is some kind of scheduler to run the script and it is being written to the channel once per script run?
Christopher Stapels
Christopher Stapels on 6 Jun 2023
I would encourage you to use more descriptive names for your TimeControls. It is clear you are running the TimeControl every 10 minutes, but I think the code you wrote may be writing to a ThngSpeak channel more than once very time it is run. That could lead to the error you are seeing.
Perhaps you could share the full text of the code that you selected to be run by the TimeControl? (feel free to redact api keys and channel id's)
Carsten
Carsten on 6 Jun 2023 (Edited on 6 Jun 2023)
That is the full code...First one runs every hour, second one every 10 minutes....
Will name more descriptive though :-)
First script only misses the channel definitions
% ThingSpeak Channel-ID für den Stromverbrauch
stromzaehlerChannelID = 1234567; % Ersetzen Sie dies mit Ihrer tatsächlichen Channel-ID für den Stromverbrauch
% ThingSpeak Authentifizierungsschlüssel
readAPIKey = 'XXXXXXXXXX'; % Ersetzen Sie dies mit Ihrem tatsächlichen Lese-API-Schlüssel
writeAPIKey = 'XXXXXXXXX';
writeChannelID = 123456789;
Carsten
Carsten on 6 Jun 2023
Here is my usage so far..
Christopher Stapels
Christopher Stapels on 6 Jun 2023
So both scripts have writes to channel in them. One runs every hour. When it runs, the 10 minute code is also run. Our servers are very fast, so they are running both scripts within 15 seconds, thus you are writing to the same channel twice in under 15 seconds. This is not allowed with a free license. Thus the "requests are too frequent" error message.
Things you can do to fix it:
  1. Change the second time (60 minutes) to a prime number.
  2. Use two different channels to write to (or more )
  3. Change the run time to "fuzzy" Which will work most of the time but may still randomly overlap and cause the error occasionally.
  4. other, more complicated fixes
Carsten
Carsten on 6 Jun 2023
Thanks a lot. I have now changed (combination of 1 & 3).
Now when you say it it makes total sense that it is highly possible that the three write operations will conflict each other when only one write operation is allowed every 15 seconds.
Will observe it not and see if it improved. Thanks again!
Christopher Stapels
Christopher Stapels on 5 Jun 2023
Can you show a sample of the code where you are writing to ThingSpeak? You would not get the 429 error (requests too frequent) from overuse of messages, so I would guess that you may be sending messages faster than you think somehow.