Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

why my code is wrong? how to solve this problem in MATLAB Step 3. Now, we can begin filling in the rest of the ThingSpeakTutorial()

why my code is wrong? how to solve this problem in MATLAB
imageimageimageimageimage

Step 3. Now, we can begin filling in the rest of the ThingSpeakTutorial() function. All subsequent code you write should go inside the function. Before we begin writing to our own ThingSpeak channel, let's practice reading a public channel. We will use the public channel, WeatherStation, which is used by the MathWorks Weather Station to monitor outdoor conditions in Massachusetts. The channel id is 12397. The function to read a ThingSpeak channel is: data = thingSpeakRead (channelID, 'Fields', fieldNumbers); The values you have to substitute are channelID and fieldNumbers. Here, fieldNumbers is an array of numbers corresponding to the fields you want to read from the channel. Note that you can leave out 'Fields' and fieldNumbers, and the read function will simply read all the fields of the channel. To start off, we want to read fields 1 and 3, which correspond to wind direction and humidity, respectively. Pass the appropriate inputs to the function and call the function. Afterwards, the field values will be stored into the output variable data as an array of numbers. Display this data using disp() and assign the wind direction value to out1 and the humidity value to out2. Step 4. Now, we will try writing data to the Tutorial channel that we created. Since this a private channel, we will need to use the read and write API keys for the channel. The following functions are used to read and write to a ThingSpeak channel using API keys. The API keys should be stored as character vectors. data = thingSpeakRead (channelID, 'ReadKey', readKey, 'Fields', fieldNumbers); thingSpeakWrite(channelID, 'WriteKey', writeKey, 'Fields', fieldNumbers, 'Values', writeValues); Again, the arguments not in quotes are the ones you have to substitute. For thingSpeakWrite(), writeValues is an array that contains the values you want to write. The size of this array must be the same size as fieldNumbers, because one value will be written to each field. Before we can write, we need to pause the application for 1 second. This is due to the 1-second limitation enforced by ThingSpeak on the frequency of writes. If less than a second has passed between two writes, you will get an error saying that the requests are too frequent.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Elements Of Chemical Reaction Engineering

Authors: H. Fogler

6th Edition

013548622X, 978-0135486221

More Books

Students also viewed these Databases questions

Question

Find the derivatives of the function. 9 cot sin t t

Answered: 1 week ago