Tanusree in MATLAB Answers
최근 활동: 2024년 4월 30일

Everytime I want to execute the following programming on ThingSpeak Matlab Analysis, facing problem with thingSpeakWrite, and it is showing ''Expected a string scalar or character vector for the parameter name'' error. Also how can I write every data instead of single data to write channel on ThingSpeak? % Read the most recent data from the source channel data = thingSpeakRead(readChannelID, 'ReadKey', readAPIKey, 'Fields', [1, 2], 'NumPoints', 7); % Extract the values from the read data values1 = data(:, 1) % Values from field 1 values2 = data(:, 2) % Values from field 2 % Write the data to the destination channel thingSpeakWrite(writeChannelID, 'WriteKey', writeAPIKey, [values1, values2], 'Fields', [1, 2]);
Manfred in MATLAB Answers
최근 활동: 2023년 5월 4일

In the thingSpeakWrite documentation is an example, how to upload a table of data .... thingSpeakWrite(writeChannelID,dataTable,'WriteKey',writeAPIKey); This works, but the data are uploaded in Field1. How can i specifie the field - for example field 5? thingSpeakWrite(writeChannelID,'Fields',[5],dataTable,'WriteKey',writeAPIKey); or thingSpeakWrite(writeChannelID,'Fields',[5],'Values',dataTable,'WriteKey',writeAPIKey); did not work.
AC31LT in Discussions
최근 활동: 2021년 9월 16일

Afternoon Everyone, Looking for some help with my Arduino/Thingspeak sketch. To give you an idea I have a Lora Sensor sending data to a Lora/Uno receiver, the data I receive is two strings, one for DO and one for Temp, in the parsepacket section below I convert the string to floats and use these as my fields for Thingspeak. Currently the code allows a connection to Thingspeak, it also correctly associates the DO and Temp float variables with corresponding graphs on the channel. However after the initial WiFi connection all that happens is zero is written to both graphs and only once, another write will not happen untill I reboot the Arduino. I'm pretty certain that the order of my Loop is wrong. My expected results are to write Temp and DO to Thingspeak every 30 seconds, with actual values, not 0. Currently a write happens once and Temp and DO are Zero, despite the packets being received correctly with actual values. If I can clarify anything or better explain then please feel free to ask, I'm fairly new to this. TIA. AC if true #include <ESP8266WiFi.h> #include <ThingSpeak.h> #include <LoRa.h> #include <SoftwareSerial.h> #define nss D10 #define rst D14 #define dio0 D2 // WiFiClient client; // const char* ssid = "myssid"; const char* password = "mypassword"; // char thingSpeakAddress[] = "api.thingspeak.com"; unsigned long channelID = mychannelid; char* readAPIKey = "myapi"; char* writeAPIKey = "myapi"; unsigned long lastTime = 0; unsigned long timerDelay = 30000; unsigned int dataFieldOne = 1; unsigned int dataFieldTwo = 2; // float DO; float temp; // void setup() { WiFi.mode(WIFI_STA); ThingSpeak.begin(client); LoRa.setPins(nss, rst, dio0); Serial.begin(115200); while (!Serial); if (!LoRa.begin(868E6)) {//914E6 Serial.println("Starting LoRa failed!"); while (1); } } // void loop() { int packetSize = LoRa.parsePacket(); if (WiFi.status() != WL_CONNECTED) { Serial.print("Attempting to connect"); while (WiFi.status() != WL_CONNECTED) { WiFi.begin(ssid, password); delay(5000); if (packetSize) { Serial.print("packetSize = "); Serial.println(packetSize); parseLoRaPacket(); } ThingSpeak.setField(1, DO); ThingSpeak.setField(2, temp); int x = ThingSpeak.writeFields(channelID, writeAPIKey); // if (x == 200) { Serial.println("channel update succesful."); } else { Serial.println("Problem updating channel."); } } } } // void parseLoRaPacket() { String lora_data; // String as local variable // while (LoRa.available()) { lora_data = LoRa.readString(); Serial.print(lora_data); // int strIndex = lora_data.indexOf("TEMP: "); if (strIndex > -1) { int startPos = strIndex + strlen("TEMP: "); temp = lora_data.substring(startPos).toFloat(); Serial.println(temp); } strIndex = lora_data.indexOf("DO: "); if (strIndex > -1) { int startPos = strIndex + strlen("DO: "); DO = lora_data.substring(startPos).toFloat(); Serial.println(DO); } } } end Arduino connecting to ThingSpeak but writing data provides a zero value and only writes once. I would start by adding more delay in your loop. This code would repeatedly slam the ThingSpeak server, all updates except one every 15 seconds will be rejected. Please look at the examples provided with the ThingSpeak library. You can see them under the file > Examples > ThingSpeak menu in the Arduino IDE. There are also some other errors in the code above, with your wifi connect routine, and placement of some braces. I suggest starting over with the examples, and then add the Lora stuff in once you are successfully able to send a static value or a random number to ThingSpeak. Hi Christopher, Thanks for the response and critique, that is actually a really good suggestion. I took the opposite approach I took something that worked and tried to force thingspeak into it without understanding thingspeak itself. I'll start from the ground up as you say get a working thingspeak sketch and implement the other stuff. Thanks again. Happy to help, I hope you get your project working. Can you share any more information about the LORA receiver connected to the UNO (and what is sending the packet)? I'm intrigued. arduino sketch help thingspeak write
Gonçalo Santos in Discussions
최근 활동: 2021년 7월 2일

Hi. I am a begginer. I did a sample "Calculate high and low temperatures" with matlab analysis. I want to write data in a specified field in the new channel. I do not know how to do that. I already replace the empty spaces with channel ID and Api key. Then, when i try to set the field that i want to, it returns an error. Is it right doing like I mention here: thingSpeakWrite(writeChannelID,'Fields',[2],maxTempF,'timestamp',timeMaxTemp,'WriteKey',writeAPIKey); Write Data in a specified field of the channel I think you need to specify the name value pair 'values' when you use 'fields' Have a look at the examples on the <https://www.mathworks.com/help/thingspeak/thingspeakwrite.html doc page for thingSpeakWrite>. If you get an error, it helps to provide the text of your error with the question. thingspeakwrite
Denis Lukashevich in MATLAB Answers
최근 활동: 2020년 12월 29일

Hi. I want to use matlab to calculate some data from my channel and send it ti new field. But even simple code cannot be done. What i do wrong? Every time i getting error : "URL is incorrectly formed, or the requested feature is not supported in this version of ThingSpeak". Here it is (channel is private): readChannelID = 1071866; writeChannelID = 1071866; humidityFieldID = 1; readAPIKey = 'xxxx'; writeAPIKey = 'yyyyy'; [hum1,time] = thingSpeakRead(readChannelID,'Fields',[humidityFieldID],'ReadKey',readAPIKey); thingSpeakWrite(writeChannelID, hum1,'Fields',5,... 'TimeStamps', timestamps,'WriteKey',writeAPIKey);
Mostafa Ibrahim in MATLAB Answers
최근 활동: 2020년 12월 16일

I'm trying to upload data to a field in my ThingSpeak channel. So far I have been able to upload a single number to the field. But when I tried to upload array like x = [1,2,3,4] it would give me this error: "'Values' must be a scalar, a 1-by-n numeric vector, or a cell array and must have the same dimensions as the 'Fields' value." I'm using thingspeakwrite function like this : thingSpeakWrite(id,'Fields',1,'Values',x,'WriteKey',apikey).

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.