Edward in MATLAB Answers
上次活动时间: 2024-7-3

I am sending data from sensors on a XIAO esp32 S3 - there are 6 fields of data - I have timed to send every 5 minutes. When I initiate the code it sends 2 or 3 sets, but then I get an error message saying 'Error sending data to ThingSpeak' - and it doesnt send any more data unless I reset the esp , yet the data is being collected as shown on the serial monitor. I have played around witht the time intervals but no joy. Is it a function of thinkspeak or should I investigate the code?
Edgar in Discussions
上次活动时间: 2024-2-13

I need to copy Channel field data from a specific data range (e.g. January 2024) from field 6 of channel A(see sample attached) to field 1 of channel B. I have tried to adopt the Template "Get data from private channel" in the Matlab analysis area of Thingspeak. The last data can be copied according the sample, but I cannot manage to copy the complete datarange. My channel field contains half empty data in field 6, because I have posted data asynchrously from 2 devices to 1 channel up to now. Any advice for proper Matlab code sample or the like is welcome! Need to copy Channel field data from a specific data range (e.g. January 2024) from field 6 of channel A to field 1 of channel B Can you put your code inline or try the attachment again? It did not come through. Attached the source channel data extract and the adopted basic script for coping the last data only. Any modification to copy complete datarange (e.g. January data) from source to target channel very welcome! Thanks in advance! Have a look at the documentation for thingSpeakRead. You can specify the number of days to read with numdays or if you have more then 8000 points to read, you might want to use daterange input argument in order to specify the range of interest. thingSpeakRead(12397,NumDays=2); Thanks for prompt reply! I already passed the documentation for thingSpeakRead and thingSpeakWrite: Obviously there is no problem reading the January array from below thingSpeakRead command. But the thingSpeakWrite end in : "Error using Copy Data from one channel to another Second input must be either a named parameter or data specified as numeric scalars or arrays or cell arrays or tables." Can you help me to adapt the thingSpeakWrite command to write the January Data Array in the writeChannelID ? %% Read Data %% readField = 6; % Specify the field to read [data,timestamps,channelInfo] = thingSpeakRead(readChannelID, 'Fields', readField, 'ReadKey', readAPIKey, DateRange=[datetime(2024,1,1,00,00,01),datetime(2024,1,31,23,59,52)]); %% Write Data %% writeField = 1; % Specify the field to write % Write the table to the new channel thingSpeakWrite(writeChannelID, data, 'TimeStamp', timestamps, 'Fields', writeField, 'WriteKey', writeAPIKey); I was able to read and write data with similar code. %% Read Data %% readField = 2; % Specify the field to read [data,timestamps,channelInfo] = thingSpeakRead(12397, 'Fields', readField,numminutes=2); %% Write Data %% writeField = 1; % Specify the field to write % Write the table to the new channel thingSpeakWrite(nnn, data, 'TimeStamp', timestamps, 'Fields', writeField, 'WriteKey', 'xxx'); The issue comes when you read a field with no data in it. When I read a channel that has no data in the time period specified, I got the error you did. I would inspect data to make sure its not empty, for example like this if size(data,1)>0 %do the thingSpeak write end If you still want to write to the new channel even if 'readfield' has empty data, than dont specify the field number in the thingSpeakread command and you will get an array of data with all fields. But then you will get timestamps for the empty data (assuming there is data in some field). Then you can write the empty data using the timestamps and nulls or zeros() function to create empty data. Programming in ThingSpeak can be harder without a MATLAB license. You can inspect vatiables by leaving the semicolon off for example just adding the line data to your code will allow you to inspect it. You can also access MATLAB intepreters at MATLAB online and at the MATLAB AI chat playground (on the right hand side.) These will help you write your MATLAB code for ThingSpeak, and you can even ask the AI for help too if you wish. copy fields
Abbas in MATLAB Answers
上次活动时间: 2023-7-28

Hi, I have purchased a ThingSpeak license. I need to save 11 fields per channel. What is the maximum number of fields per channel? If it is limited to 8 fields (which I can see in my account now), is it a way to increase it? How can I solve this issue? Thanks for any help in advance. Abbas
Fabian Boruta in MATLAB Answers
上次活动时间: 2023-2-6

Hello, I am still quite new at Thingspeak and do not yet have the idea where to look exactly. As a result, I spent the last few hours trying to find a solution to my problem, unfortunately without success. My problem is, we have 8 fields per channel, but I have a sensor package with 10 parameters. Can I insert several parameters into one single field using an Arduino code or do I have to create a new channel separately and then merge them using the example you provided? For example, I wanted to send the dust fractions for p10 and p25 in a field. I hope you can help me:)
BEHNAM MOBARAKI . in MATLAB Answers
上次活动时间: 2021-6-1

Hi. I have to modify my question. I am sending temperature data from 2 sensor installed on NODEMCU ESP8266. (I am using I2C comunication). Each sensor data is being sent to a single field of a channnel. On the serial monitor of Arduino IDE everything is fine. However, data of the fields are not the same of those in serial monitor. For installation of the these sensor on NODEMCU, I have used multiplexet TCA9548 and both sensors are defined on ports 0 and 1 ( tcaselect(0) and tcaselect(1)). By these two lines of the codes, I am trying to send the temperatures on two fields of ThingSpeak: ThingSpeak.writeField(myChannelNumber, 1, String(mlx1.readAmbientTempC()), apiKey); ThingSpeak.writeField(myChannelNumber, 2, String(mlx2.readAmbientTempC()), apiKey); I do not understand where the problem is. Kindly check the below code and let me know your idea..... #include <SPI.h> //Load SPI comunication library #include <Arduino.h> #include <Wire.h> #include <Adafruit_MLX90614.h> #include <SoftwareSerial.h> // import the serial library #include <ESP8266WiFi.h> #include "ThingSpeak.h" Adafruit_MLX90614 mlx1 = Adafruit_MLX90614(); Adafruit_MLX90614 mlx2 = Adafruit_MLX90614(); const char * apiKey = "S9GZsefweszxcQ21XP"; // Enter your Write API key from ThingSpeak unsigned long myChannelNumber = 123456789; const char *ssid = "iBehnam"; // replace with your wifi ssid and wpa2 key const char *pass = "behnam555"; const char* server = "api.thingspeak.com"; #define TCAADDR0 0x70 // you need to conec nothing WiFiClient client; //OPENING THE FIRST MUX IN THE PORTS void tcaselect(uint8_t i) { if (i > 7) return; Wire.beginTransmission(TCAADDR0); Wire.write(1 << i); Wire.endTransmission(); } ////////////CLOSING THE FIRST MUX IN THE PORTS void endtcaselect(){ Wire.beginTransmission(TCAADDR0); Wire.write(0); // no channel selected Wire.endTransmission(); } void setup() { // put your setup code here, to run once: Serial.println("Adafruit MLX90614 test"); Serial.begin(115200); ThingSpeak.begin(client); Serial.println("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, pass); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); //*************INITIALIZING FIRST SENSOR MUX1******************************* endtcaselect(); tcaselect(0); mlx1.begin(); endtcaselect(); //*************INITIALIZING 2nd SENSOR MUX1******************************* tcaselect(1); mlx2.begin(); endtcaselect(); //*************INITIALIZING 2nd SENSOR MUX1******************************* // tcaselect(2); // mlx2.begin(); // endtcaselect(); } void loop() { // tcaselect(3); // Send Day-of-Week Serial.print("HEAT-SET--6 "); if (client.connect(server,80)) // api.thingspeak.com { ThingSpeak.writeField(myChannelNumber, 1, String(mlx1.readAmbientTempC()), apiKey); ThingSpeak.writeField(myChannelNumber, 2, String(mlx2.readAmbientTempC()), apiKey); //*************INITIALIZING 2nd SENSOR MUX1******************************* endtcaselect(); tcaselect(0); Serial.print("Amb-1 = "); Serial.print(mlx1.readAmbientTempC()); Serial.print("*C\tObj-1 = "); Serial.print(mlx1.readObjectTempC()); Serial.print("*C "); endtcaselect(); tcaselect(1); Serial.print(" Amb-2 = "); Serial.print(mlx2.readAmbientTempC()); Serial.print("*C Obj-2 = "); Serial.print(mlx2.readObjectTempC()); Serial.println("*C "); } client.stop(); Serial.println("Waiting..."); delay(60000); // delay 1 minute }
theo koster in MATLAB Answers
上次活动时间: 2021-2-17

Using google app script I want to post measurements from my home domotics to a thingspeak channel. The chart has several charts. I am using the following code POST https://api.thingspeak.com/update.json api_key=XXXXXXXXXXXXXXXX field1=73 and after a few seconds POST https://api.thingspeak.com/update.json api_key=XXXXXXXXXXXXXXXX field2=100. In the channel it only updates the chart for field1. When I introduce a sleep of 15 seconds between the 2 posts, it will show both charts (field1 and field2). It seems not possible to send both posts with short intermediant times to update the both charts. Or should I use another way to achieve almost simultaneous updates of multiple charts ?
Christopher Stapels in Discussions
上次活动时间: 2021-1-15

Right now ThingSpeak supports up to 8 fields of data plus the status and three position fields. If you could have more fields, how many would you want? I have one channel of control settings for a project that I would have used up to 12, but no more than that. How many fields is enough? I might be biased, but I have always considered eight fields a good number of fields. My mental model has been that a channel represents a device (or system) and the fields are dimensions. For example, a weather station (channel) could have four sensors (fields) and a power source (another field for measuring the power). This system would use 5 fields of the 8 that ThingSpeak currently provides. I also use tags to relate channels together. I wrote a <https://blogs.mathworks.com/iot/2018/04/13/organize-your-thingspeak-iot-channels-with-tags/ blog post> about using tags to organize your channels and relate them to projects. This all being said... I think there is room for more fields or have a flexible field model that allows an IoT engineer to describe a device (or system) with n number of fields and/or dimensions. fields iot thingspeak 8 fields data structure

关于 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.