Tanusree in MATLAB Answers
Letzte Aktivitätam 28 Mai 2024

We collect the real time data from read channel and want process it before sending it to write channel, but the data values in the write channel replicate the read channel values for the following code. Could anyone give suggession how to get the processed data? % Source ThingSpeak Channel ID for reading data readChannelID = 2522808; % Replace with your source channel ID % Destination ThingSpeak Channel ID for writing data writeChannelID = 2522810; % Replace with your destination channel ID % ThingSpeak Read API Key for the source channel readAPIKey = 'XXX'; % Replace with your read API key % ThingSpeak Write API Key for the destination channel writeAPIKey = 'XXX'; % Replace with your write API key %% Read Data %% % Read all available data from the source channel data = thingSpeakRead(readChannelID, 'ReadKey', readAPIKey, 'Fields', [1, 2]); % Extract the values from the read data values1 = data(:, 1); % Values from field 1 i.e. Estimated Voltage values2 = data(:, 2); % Values from field 2 i.e. Input Current % Determine the number of data points retrieved numPoints = size(data, 1); % Assign the number of rows in the variable 'data' to the variable 'numPoints' % Generate timestamps for the data timeStamps = datetime('now') - minutes(numPoints:-1:1); % Initialize Y arrays Y1 = zeros(size(values1)); % Create a new array 'Y1' filled with zeros that has same size as the array 'values1' Y2 = zeros(size(values2)); % Create a new array 'Y2' filled with zeros that has same size as the array 'values2' % Perform the operation Y(i) = i * I(i) for each value in the read data for i = 1:length(values1) disp(['Processing index ', num2str(i)]); disp(['values1(', num2str(i), ') = ', num2str(values1(i))]); disp(['values2(', num2str(i), ') = ', num2str(values2(i))]); Y1(i) = i * values1(i); Y2(i) = i * values2(i); disp(['Y1(', num2str(i), ') = ', num2str(Y1(i))]); disp(['Y2(', num2str(i), ') = ', num2str(Y2(i))]); end % Write the data to the destination channel with timestamps thingSpeakWrite(writeChannelID, 'WriteKey', writeAPIKey, 'Values', [Y1', Y2'], 'Fields', [1, 2], 'Timestamps', timeStamps);
Sandeep Agashe in MATLAB Answers
Letzte Aktivitätam 15 Feb. 2022

I am reading a field for data of last 45 minutes. The query given is as follows on the browser. https://api.thingspeak.com/channels/*******/fields/6.json?api_key=****************&minutes=45 *** represent my channel id and api key. I expect that last 45 minutes readings should be available. The response is as follows. {"channel":{"id":*******,"name":"Pump Parameters","description":"Starting Date, Starting Time, No of working hours.","latitude":"0.0","longitude":"0.0","field1":"Starting Date","field2":"Starting Time","field3":"Working Hours","field4":"Remaining Hours","field5":"User Request","field6":"Pump Status","created_at":"2021-12-03T04:20:52Z","updated_at":"2022-01-20T10:02:50Z","last_entry_id":206},"feeds":[{"created_at":"2022-07-04T01:02:03Z","entry_id":40,"field6":"7"},{"created_at":"2022-07-18T01:02:03Z","entry_id":39,"field6":"7"}]} Last 2 readings are incorrect. entry_id: 40 and entry_id:39 How to avoid these two readings. I also had valid readings in this time span but still id39 and id40 is appearing in the response. date shown for these id's in not correct. Please advice about getting correct response. It is not possible to use Matlab as I am using Web Page integration. this is free and private channel.

Info zu ThingSpeak

The community for students, researchers, and engineers looking to use MATLAB, Simulink, and ThingSpeak for Internet of Things applications. You can find the latest ThingSpeak news, tutorials to jump-start your next IoT project, and a forum to engage in a discussion on your latest cloud-based project. You can see answers to problems other users have solved and share how you solved a problem.