メインコンテンツ

結果:

Alastair Gilmore
Alastair Gilmore
最後のアクティビティ: 2021 年 9 月 17 日

Hi, I've been using ThingSpeak now for a number of years capturing temperature data from a Pi zero and Python. I currently use the Unsecured TCP option, but the recent email about moving to mqtt3 server suggests websockets. I've looked at the example and understand username, password and channel ID, but not what the Client ID is. Can someone tell me what this is please.

Many thanks Alastair

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
Mufudzi Moses Tembo
Mufudzi Moses Tembo
最後のアクティビティ: 2021 年 9 月 21 日

Kindly assist I have been trying to create a small weather station with with DHT11 sensor and CC3200 launchpad and connect it to ThingSpeak but the code won't compile as I am using an Arduino code.

Anyone to please help

    if true
      #include <SPI.h>
      #include <WiFi.h>
      #include <WiFiClient.h>
      #include <DHT.h>  // Including library for dht
      String apiKey = "";     //  Enter your Write API key from ThingSpeak
      const char *ssid =  "Virus";     // replace with your wifi ssid and wpa2 key
      const char *pass =  "";
      const char* server = "api.thingspeak.com";
      #define DHTPIN 11          //pin where the dht11 is connected
      #define DHT dht(DHTPIN, DHT11);
      WiFiClient client;
      void setup() 
      {
         Serial.begin(115200);
         delay(10);
         dht.begin();
         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");
      }
      void loop() 
      {
        float h = dht.readHumidity();
        float t = dht.readTemperature();
                if (isnan(h) || isnan(t)) 
                   {
                       Serial.println("Failed to read from DHT sensor!");
                        return;
                   }
                           if (client.connect(server,80))   //   "184.106.153.149" or api.thingspeak.com
                        {  
                               String postStr = apiKey;
                               postStr +="&field1=";
                               postStr += String(t);
                               postStr +="&field2=";
                               postStr += String(h);
                               postStr += "\r\n\r\n";
                               client.print("POST /update HTTP/1.1\n");
                               client.print("Host: api.thingspeak.com\n");
                               client.print("Connection: close\n");
                               client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
                               client.print("Content-Type: application/x-www-form-urlencoded\n");
                               client.print("Content-Length: ");
                               client.print(postStr.length());
                               client.print("\n\n");
                               client.print(postStr);
                               Serial.print("Temperature: ");
                               Serial.print(t);
                               Serial.print(" degrees Celcius, Humidity: ");
                               Serial.print(h);
                               Serial.println("%. Send to Thingspeak.");
                          }
            client.stop();
            Serial.println("Waiting...");
        // thingspeak needs minimum 15 sec delay between updates
        delay(1000);
      }
    end

Join our celebration of the 20th anniversary of MATLAB Central community! You are invited to enter 2 contests - A Treasure Hunt and a MATLAB Mini Hack - to have fun and win prizes.

How to Play

  • In the Treasure Hunt, complete 10 fun tasks to explore the ‘treasures’ in the community.
  • In the MATLAB Mini Hack, use up to 280 characters of MATLAB code to generate an interesting image. Simply vote for the entries that you like or share your own entries to gain votes.

Prizes

You will have opportunities to win compelling prizes, including special edition T-shirts, customized T-shirts, Amazon gift cards, and virtual badges. Your participation will also bump up our charity donations.

Ready to participate?

Visit the community contests space and choose the contest you’d like to enter. Note that:

  • You need a MathWorks account to participate. If you don’t have a MathWorks account, you can create one at MathWorks sign in .
  • Make sure you follow the contests (click the ‘follow the contests’ button on the top) to get notified for prize information and important announcements.

For the full contest rules, prizes, and terms, see details here .

We hope you enjoy the contests and win big prizes. NOW, LET THE CELEBRATION BEGIN!

Goura Pani
Goura Pani
最後のアクティビティ: 2021 年 9 月 16 日

Hi, I am using SIM800 for transferring data to the ThingSpeak server. After send OK, I am not getting acknowledgment from ThingSpeak. Also, the field is not getting updated in ThingSpeak. Let me know what has gone wrong. The commands and response in teraterm is as below.

AT+CIPSHUT

SHUT OK

AT

OK

AT+CIPMUX=0

OK

AT+CGATT=1

OK

AT+CSTT="airtelgprs.com","",""

OK

AT+CIICR

OK

AT+CIFSR

100.67.75.225

AT+CIPSTART="TCP","184.106.153.149","80"

OK

CONNECT OK

AT+CIPSEND

> GET /update?api_key=81XXXXXXXXXXXXX4&field1=32

SEND OK

CLOSED

Andrew Janke
Andrew Janke
最後のアクティビティ: 2025 年 8 月 16 日

Let's say MathWorks decides to create a MATLAB X release, which takes a big one-time breaking change that abandons back-compatibility and creates a more modern MATLAB language, ditching the unfortunate stuff that's around for historical reasons. What would you like to see in it?
I'm thinking stuff like syntax and semantics tweaks, changes to function behavior and interfaces in the standard library and Toolboxes, and so on.
(The "X" is for major version 10, like in "OS X". Matlab is still on version 9.x even though we use "R20xxa" release names now.)
What should you post where?
Wishlist threads (#1 #2 #3 #4 #5): bugs and feature requests for Matlab Answers
Frustation threads (#1 #2): frustrations about usage and capabilities of Matlab itself
Missing feature threads (#1 #2): features that you whish Matlab would have had
Next Gen threads (#1): features that would break compatibility with previous versions, but would be nice to have
@anyone posting a new thread when the last one gets too large (about 50 answers seems a reasonable limit per thread), please update this list in all last threads. (if you don't have editing privileges, just post a comment asking someone to do the edit)

MATLAB Mobile makes it convenient to learn and teach in disciplines requiring computational thinking, such as mathematics, science, and engineering. It can also be used for virtual labs by acquiring smartphone sensor data. As an instructor, you can author examples in MATLAB and demonstrate them on your smartphone or tablet. Students can follow along on their mobile device or tablet to instantly connect results to the concepts they are learning. This is especially relevant for distance learning, where some students may have limited or no access to a full-fledged computer.

Educators make their course material more interactive, promote self-directed learning, and increase student engagement through Live Editor. You can now run and edit live scripts on iOS and Android devices.

Get MATLAB Mobile on the Play Store or App Store, or learn how to teach using Live Scripts.

Tushar Raut
Tushar Raut
最後のアクティビティ: 2021 年 9 月 6 日

Hello! I am a 3rd year mechanical engineering student from IIT Ropar. We are participating in EBAJA 2022. I thank Mathworks for providing the customisable vehicle template https://www.mathworks.com/matlabcentral/fileexchange/79484-simscape-vehicle-templates

I have learnt to customise the models parameters of Bus, Sedan, Trucks, etc using the UI provided. However the vehicle models does not include the BAJA ATV in it which we required the most for the animations and simulation results. I needed some assistance for replacing the given vehicle model with a BAJA ATV.

-Tushar Raut LinkedIn: https://www.linkedin.com/in/tushar-raut-73ba75194/

Colin kerr
Colin kerr
最後のアクティビティ: 2021 年 9 月 8 日

I'd appreciate comment on whether I understand the limitations with MQTT and low power. Using deep sleep the ESP12 consumes microamps and my sensor is insignificant. The big drain on the battery is WiFi. Sending an MQTT message is taking around 10ms which seems at first sight promising. Unfortunately it looks to me like deep sleep ends the connection, and reconnection takes 4 or more seconds. I'd thought that deep sleep, static IP, and MQTT were the way to get very low power consumption but it looks to me like they don't solve the problem.

Unrecognized function or variable 'snopt'.

Error in Untitledidk (line 362) [x, f, inform, xmul, fmul] = snopt(xg, xlwr, xupr, xmul, xstate, ...

Hi , I am using M66 GSM Module to send and recv data over Thingspeak , TCP Connection : "api.thingspeak.com"; : Working Fine "GET /update?api_key=xxxxxxxxxxxxxxxx&field1=14"; : Send data to Server No Issue "GET https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=12"; : Send sata to server No Issue .

But not able to see data in thingspeak view , it means thingspeak server not collecting data from M66 Module .

Could you please help the same .

Nowadays, many instructors are integrating AI to their courses. In a distance learning setting, the hardware students use to train their models vary. Training time of the deep learning models can be shortened with a pool of GPUs, CPUs or a pool of CPUs and GPUs locally or in the cloud. Accuracy of the results can depend on the hyperparameters used to train the models.

In MATLAB, Experiment Manager (introduced in R2020a) makes it easy to train networks with various hyperparameters and compare the results. Different models can be run in parallel by clicking on “Use Parallel” button in Experiment Manager App. But what if your computer has multiple CPU cores and a GPU? Would you be able to use Experiment Manager with a pool of CPUs and a GPU? The answer is “yes”. For example, my computer has 1 NVIDIA GPU and an 8 core CPU. To use all these computational resources, I typed these lines in my command window in MATLAB:

parpool(9);
spmd
if labindex==1
gpuDevice(1); %select GPU on worker 1
else
gpuDevice([]); %deselect GPU on remaining workers
end

Then, I clicked on “Use Parallel” button in Experiment Manager and used a modified setup function in Experiment Manager to change the execution environment from CPU to GPU:

if isempty(parallel.gpu.GPUDeviceManager.instance.SelectedDevice)
options=trainingOptions(~,"ExecutionEnvironment",'cpu');
else
options=trainingOptions(~,"ExecutionEnvironment",'gpu');
end 

Default training options automatically use an NVIDIA GPU if there is one, and specific hardware can be selected using “ExecutionEnvironment” in the trainingOptions.

If you like to learn more about the fundamentals of parallel computing, check out “Parallel Computing Fundamentals” on our documentation and gain some hands-on experience with Parallel Computing through "Parallel Computing Hands-On Workshop" .

Josiah Lawrence
Josiah Lawrence
最後のアクティビティ: 2021 年 8 月 25 日

Please can I run my MATLAB code on the cloud? The code involves calling the fuzzy logic toolbox for irrigation control and also collecting sensor data from farm.

Rick McLeod
Rick McLeod
最後のアクティビティ: 2021 年 8 月 25 日

Using the gauge widget works good, and the current value shows up below the gauge. But I've seen articles where the value is shown inside the gauge, not below it. It that possible to do? If so, how?

I do really like the ability of applying colors to ranges of the gauge's values. I'm plotting Air Quality AQI numbers and this works really well for that.

Thanks,

Rick

I am a new user to ThingSpeak. Generally things are going well. I've been able to create channels and use widgets. I am embedding charts into my own web site (using Google Sites) and that is working fine.

My question has to do with labels that I put on the charts in the 'public view'. I can change the title and the X and Y axis text and this shows up as I want. But when I click on the 'export URL' button and a new tab opens up with the chart, the title and X & Y labels are not what I put in (and yes, I did 'save' after changing them). Is this a bug, or is there some other thing I need to do here?

Thanks,

Rick

Im posting data every 10 minutes to this field as you can see, yet when i pull the data back down there are 2 timestamps in between each post with 'nothing' in them which in tern screws up any matlab script trying to average the data. Why is this happening? thanks see below

created_at,entry_id,field2
2021-08-21 09:54:27 -0600,38811,5.416666666666667
2021-08-21 09:57:02 -0600,38812,
2021-08-21 10:03:59 -0600,38813,
2021-08-21 10:04:27 -0600,38814,5.0
2021-08-21 10:07:02 -0600,38815,
2021-08-21 10:13:59 -0600,38816,
2021-08-21 10:14:28 -0600,38817,5.0
2021-08-21 10:17:03 -0600,38818,
2021-08-21 10:23:59 -0600,38819,
2021-08-21 10:24:28 -0600,38820,5.416666666666667
2021-08-21 10:27:03 -0600,38821,
2021-08-21 10:34:00 -0600,38822,
2021-08-21 10:34:29 -0600,38823,8.333333333333334
2021-08-21 10:37:04 -0600,38824,
2021-08-21 10:44:00 -0600,38825,
2021-08-21 10:44:29 -0600,38826,6.25
2021-08-21 10:47:09 -0600,38827,
2021-08-21 10:54:01 -0600,38828,
2021-08-21 10:54:30 -0600,38829,6.666666666666667
2021-08-21 10:57:10 -0600,38830,
2021-08-21 11:04:01 -0600,38831,
2021-08-21 11:04:34 -0600,38832,7.083333333333334
2021-08-21 11:07:10 -0600,38833,
2021-08-21 11:14:01 -0600,38834,
2021-08-21 11:14:35 -0600,38835,9.583333333333334
2021-08-21 11:17:11 -0600,38836,
2021-08-21 11:24:02 -0600,38837,
2021-08-21 11:24:35 -0600,38838,7.083333333333334

Educators use MATLAB Grader to automatically grade MATLAB code, to provide feedback to their students and to scale assessments for large lectures. If you use MATLAB Grader in our browser-based environment at grader.mathworks.com you can view various individual and aggregate student performance analytics. You can export the MATLAB Grader Assignment Report to analyze your student’s performance in more detail:

To make things easy for you, we provide a utility to create customizable assignment reports from the MATLAB Grader Assignment Report. With this utility you can quickly make lists of students with a metric that defines how well they solved the problems within the assignment. You can explore the number of problems each student solved correctly, calculate the mean percentage score they received for the problems or specify points per problem and calculate the points they scored on the assignment.

Please download the utility Customizable Assignment Report for MATLAB Grader from File Exchange. If you are new to MATLAB Grader, watch the MATLAB Grader Overview video and try the interactive Teaching with MATLAB online course (Section 6 is about MATLAB Grader).

The ThingSpeak Communication Library for Arduino, ESP8266 and ESP32 enables an Arduino or other compatible hardware to write or read data to or from ThingSpeak, an open data platform for the Internet of Things with MATLAB analytics and visualization.

Link: https://github.com/mathworks/thingspeak-arduino

Installation: In the Arduino IDE, choose Sketch/Include Library/Manage Libraries. Click the ThingSpeak Library from the list, and click the Install button.

Compatible Hardware:

  • Arduino/Genuino or compatible using a WiFi Shield
  • Arduino/Genuino or compatible using a WiFi Shield 101 (Use the WiFi101 library version 0.13.0 or older.)
  • Arduino/Genuino or compatible using an Ethernet Shield
  • Arduino/Genuino or compatible using a MKR ETH Shield
  • Arduino MKR1000
  • Arduino MKR1010
  • Arduino VIDOR 4000
  • Arduino GSM 14000
  • Arduino Uno WiFi Rev2
  • Arduino Yún (Rev1 and Rev2)
  • ESP8266 programming directly (tested with SparkFun ESP8266 Thing - Dev Board and NodeMCU 1.0 module)
  • ESP8266 via AT commands
  • ESP32 (tested with SparkFun ESP32 Thing)

Tutorial: https://nothans.com/thingspeak-tutorials/arduino/send-data-to-thingspeak-with-arduino

SHUAI TAN
SHUAI TAN
最後のアクティビティ: 2021 年 8 月 16 日

Hi I got MatLab license for thingspeak. But I am not sure this MatLab is also valid for thingspeak or not? Do i need to buy add-on license for thingspeak?

An earlier tip suggested using MATLAB Drive to share and collaborate with others using MATLAB Online or MATLAB on desktop systems. Starting in MATLAB R2021a, there is yet another advantage of using this approach – the 'matlabdrive' function returns the path to the folder that contains the content of your MATLAB Drive.

After sharing their files, instructors sometimes direct students to navigate to a specified folder or add certain folders to the MATLAB search path. This ensures that MATLAB can discover the scripts, functions, and other files contained within. Since the MATLAB Drive folder may be installed in different locations on each users’ computer, this could not be done programmatically. Unfortunately, students may miss these instructions and encounter errors. The same can happen between peers working in groups.

Add the matlabdrive function in your code to obtain the path of the MATLAB Drive folder. You can then use functions cd and fullfile to navigate directly to that location or a subfolder. With addpath, you can also add these to the MATLAB search path. For example,

>> drivePath = matlabdrive 
drivePath = 'C:\Users\username\MATLAB Drive' 
>> folderPath = fullfile(matlabdrive, ‘myfolder’) 
folderPath = 'C:\Users\username\MATLAB Drive\myfolder’ 
>> cd(folderPath)	% Change current folder to ‘myfolder’ in MATLAB Drive 

You can run matlabdrive from your desktop or from other MATLAB environments such as MATLAB Online. On desktop systems, you must have MATLAB Drive Connector installed. If MATLAB is unable to find the MATLAB Drive folder, matlabdrive returns an error.