Main Content

Results for

I followed the instructions here: Bulk-Update Using an Arduino or an ESP8266

And came up the following code for GSM module:

      const char apn[] = "www";
      const char gprsUser[] = "";
      const char gprsPass[] = "";
      const char simPIN[] = "";
      const char server[] = "api.thinkspeak.com";
      const int port = 80;
      char jsonBuffer[500] = "["; // Initialize the jsonBuffer to hold data
      // TTGO T-Call pins
      #define MODEM_RST            5
      #define MODEM_PWKEY          4
      #define MODEM_POWER_ON       23
      #define MODEM_TX             27
      #define MODEM_RX             26
      #define SerialMon Serial
      #define SerialAT Serial1
      #define TIMEOUT  5000 
      // Configure TinyGSM library
      #define TINY_GSM_MODEM_SIM800      // Modem is SIM800
      #define TINY_GSM_RX_BUFFER   1024  // Set RX buffer to 1Kb
      #include <TinyGsmClient.h>
      #ifdef DUMP_AT_COMMANDS
        #include <StreamDebugger.h>
        StreamDebugger debugger(SerialAT, SerialMon);
        TinyGsm modem(debugger);
      #else
        TinyGsm modem(SerialAT);
      #endif
      TinyGsmClient client(modem);
      #define IP5306_ADDR          0x75
      #define IP5306_REG_SYS_CTL0  0x00
      /* Collect data once every 15 seconds and post data to ThingSpeak channel once every 2 minutes */
      unsigned long lastConnectionTime = 0; // Track the last connection time
      unsigned long lastUpdateTime = 0; // Track the last update time
      const unsigned long postingInterval = 60L * 1000L; // Post data every 2 minutes
      const unsigned long updateInterval = 15L * 1000L; // Update once every 15 seconds
      void setup() {
        SerialMon.begin(115200);
        // Set modem reset, enable, power pins
        pinMode(MODEM_PWKEY, OUTPUT);
        pinMode(MODEM_RST, OUTPUT);
        pinMode(MODEM_POWER_ON, OUTPUT);
        digitalWrite(MODEM_PWKEY, LOW);
        digitalWrite(MODEM_RST, HIGH);
        digitalWrite(MODEM_POWER_ON, HIGH);
        // Set GSM module baud rate and UART pins
        SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);
        delay(3000);
        SerialMon.println("Initializing modem...");
        modem.init();
        // Configure the wake up source as timer wake up  
        SerialMon.print("Connecting to APN: ");
        SerialMon.print(apn);
        if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
          SerialMon.println(" fail");
        }
        else {
          SerialMon.println(" OK");
          SerialMon.print("Connecting to ");
          SerialMon.print(server);
          if (!client.connect(server, port)) {
            SerialMon.println(" Fail");
          }
          else {
            SerialMon.println(" OK");
          }
        }
      }
      void loop() {
        // If update time has reached 1 second, then update the jsonBuffer
        if (millis() - lastUpdateTime >=  updateInterval) {
          updatesJson(jsonBuffer);
        }
      }
      // Updates the josnBuffer with data
      void updatesJson(char* jsonBuffer){
        /* JSON format for updates paramter in the API
         *  This examples uses the relative timestamp as it uses the "delta_t". You can also provide the absolute timestamp using the "created_at" parameter
         *  instead of "delta_t".
         *   "[{\"delta_t\":0,\"field1\":-70},{\"delta_t\":3,\"field1\":-66}]"
         */
        // Format the jsonBuffer as noted above
        strcat(jsonBuffer,"{\"delta_t\":");
        unsigned long deltaT = (millis() - lastUpdateTime)/1000;
        size_t lengthT = String(deltaT).length();
        char temp[4];
        String(deltaT).toCharArray(temp,lengthT+1);
        strcat(jsonBuffer,temp);
        strcat(jsonBuffer,",");
        int h = hallRead(); 
        strcat(jsonBuffer, "\"field1\":");
        lengthT = String(h).length();
        String(h).toCharArray(temp,lengthT+1);
        strcat(jsonBuffer,temp);
        strcat(jsonBuffer,"},");
        // If posting interval time has reached 2 minutes, update the ThingSpeak channel with your data
        if (millis() - lastConnectionTime >=  postingInterval) {
              size_t len = strlen(jsonBuffer);
              jsonBuffer[len-1] = ']';
              httpRequest(jsonBuffer);
        }
        lastUpdateTime = millis(); // Update the last update time
      }
      // Updates the ThingSpeakchannel with data
      void httpRequest(char* jsonBuffer) {
        /* JSON format for data buffer in the API
         *  This examples uses the relative timestamp as it uses the "delta_t". You can also provide the absolute timestamp using the "created_at" parameter
         *  instead of "delta_t".
         *   "{\"write_api_key\":\"YOUR-CHANNEL-WRITEAPIKEY\",\"updates\":[{\"delta_t\":0,\"field1\":-60},{\"delta_t\":15,\"field1\":200},{\"delta_t\":15,\"field1\":-66}]
         */
        // Format the data buffer as noted above
        char data[500] = "{\"write_api_key\":\"XXXXXXXXXXXXXXXX\",\"updates\":"; // Replace YOUR-CHANNEL-WRITEAPIKEY with your ThingSpeak channel write API key
        strcat(data,jsonBuffer);
        strcat(data,"}");
        // Close any connection before sending a new request
        client.stop();
        String data_length = String(strlen(data)+1); //Compute the data buffer length
        Serial.println(data);
        // POST data to ThingSpeak
        if (client.connect(server, 80)) {
          client.println("POST /channels/1300373/bulk_update.json HTTP/1.1"); // Replace YOUR-CHANNEL-ID with your ThingSpeak channel ID
          client.println("Host: api.thingspeak.com");
          client.println("User-Agent: mw.doc.bulk-update (ESP8266)");
          client.println("Connection: close");
          client.println("Content-Type: application/json");
          client.println("Content-Length: "+data_length);
          client.println();
          client.println(data);
          String answer=getResponse();
          Serial.println( answer );
        }
        else {
          Serial.println("Failure: Failed to connect to ThingSpeak");
        }
        delay(250); //Wait to receive the response
        client.parseFloat();
        String resp = String(client.parseInt());
        Serial.println("Response code:"+resp); // Print the response code. 202 indicates that the server has accepted the response
        jsonBuffer[0] = '['; //Reinitialize the jsonBuffer for next batch of data
        jsonBuffer[1] = '\0';
        lastConnectionTime = millis(); //Update the last conenction time
      }
      String getResponse(){
        String response;
        long startTime = millis();
        delay( 200 );
        while ( client.available() < 1 && (( millis() - startTime ) < TIMEOUT ) ){
              delay( 5 );
        }
        if( client.available() > 0 ){ // Get response from server.
           char charIn;
           do {
               charIn = client.read(); // Read a char from the buffer.
               response += charIn;     // Append the char to the string response.
              } while ( client.available() > 0 );
          }
        client.stop();
        return response;
      }

The Response code I was getting initially was "0" Upon consulting the forum I added a new function to get response and here is the message it produced:

HTTP/1.1 405 Not Allowed
Server: nginx
Date: Wed, 17 Feb 2021 06:27:54 GMT
Content-Type: text/html
Content-Length: 8911
Connection: close
ETag: "5e5304fb-22cf"
X-DIS-Request-ID: 82c8c8535e18295aaeec025d18d14375
Set-Cookie: dis-remote-addr=1.39.31.10
Set-Cookie: dis-timestamp=2021-02-16T22:27:54-08:00
Set-Cookie: dis-request-id=82c8c8535e18295aaeec025d18d14375
X-Frame-Options: sameorigin

Please help me understand this error and rectify the code. P.S. I was able to run the code using WiFi module of the ESP32, so is this something to do with 256 limit? If so, how do I rectify it?

After I give the commands I get a response like this

AT+CIPSTART="TCP","api.thingspeak.com","80" OK

CONNECT OK AT+CIPSEND > GET https://api.thingspeak.com/update?api_key=Q03CA55P7NVGA8S8&field1=23 SEND OK

CLOSED

But the field charts are not updated in the website. And the data widget shows "no data available to show". And the number of entries remains 0. kindly help me out why I didn't get the values.

I have an Esp8266 weather station and I want the graphs in thingspeak to display customary units instead of metric. How do I do it?

Hello,

I would like to share a channel with some users, but when I do it, they can see the channel in "Channels share with me" but when they open the channel the can not see the data inside. There is a message saying: You don't have permission to view that channel! Do you know why is that? Thank you.

Hi there, my PI submitted some (3) wrong values to my channel. I didn't find am opportunity to remove them. Can anoyone help or give me a hint? Those 3 wrong values are killing my statistic and let the chart look very wrog due to those peaks Thanx to you

ok I want to extract all those rows in a table where one column has strings in which it shall contain the word "change" specifically after the word "terms" . text is : May not be redeemed for cash or combined with any other offer or coupon. Not valid on clearance (merchandise ending in .98). May not be applied to taxes, previous purchases, or the purchase of gift cards. Non-transferable. Terms are subject to change at any time. Product styles are subject to availability. See store associate for details.

Hello, I am interested in creating an IoT academic project, but I have encountered two difficulties: 1- It is necessary that in the ThingSpeak interface you can see a live camera. I have not found documentation or any information on how to do it. Yes, I know that you can import data from other websites (copy XPath), but I have not achieved it with traffic cameras from local websites. 2- I also need to act remotely on actuators, is this possible in ThingSpeak?

I would appreciate an honest answer, since in case of not being able to implement these solutions, I will have to find another platform or method to carry out this. Regards!

Hi,

I would like to export data from my channel. My channel receives data every 15 minutes but I would like to export the data similar to what I can see when I change the chart/field's timescale to 60 minutes.

Thanks!

Hi everyone,

I have been using Thingspeak for quite some time now for monitoring data for my wife‘s greenhouse. She accesses those data via the public view of the channel. So far, so good.

Now someone has used the „feature“ to add a comment to that view. Nothing serious, but my wife isn‘t happy. Therefore she asked me to remove the comment, and to set things up in such a way that comments can no longer be added.

Thus my two questions: 1. How can I delete the comment? 2. How can I disable comments made by not signed on users?

The channel in question is https://thingspeak.com/channels/971602

With best regards

Volker Bandke

I'm presently working on an Air Quality monitor to be able to check the status of my environment and remote environments on ThingSpeak. I was planning on using the BME680 sensor. Does anyone have any experience with this or other air quality sensors? I'm looking probably for CO2 and the like (Volatile Organics), not so much particle sensors, though a combination may be best.

Hi,

I set at the Chart Options Results on 40320, what should be one week. But the graph shows only 36 hours (and some minutes). I also try to set it results on 7 day, but still I get only 36 hours.

Why it is not showing 7 days graph?

Frank

https://thingspeak.com/channels/1222127

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.

Did you know you can change your user id? We went through a short time where everyone was auto assigned a long user id with 'mwa' and a bunch of numbers that couldn't be changed. You can now make it something more relevant to your actual IoT persona. Click on your user picture or icon on the upper right. Select 'My Profile' and click the Edit button under username. Share your interesting IoT themed names here.

Rik
Rik
Last activity on 4 Nov 2022

There are multiple ways to create a graphical user interface (GUI) in Matlab. Which method is the best depends on multiple factors: the complexity of the project, to what extent it should be a long-term solution, on what releases your GUI should work, your available time, your skill level, and probably other factors I'm forgetting.
To keep the thread clear I'll attempt to provide a short outline a few ways in this question, and leave the details for the answers. (@anyone with editing privileges: feel free to update the section below if I missed something important and am slow in editing this question)
---------------------------------------------------------------------------------------------------
GUIDE
GUIDE is probably the first tool new users will encounter. It is very useful for quickly putting something together, but it is otherwise fairly limited. It requires maintaining (and distributing) both a .m and a .fig file. Note that the GUIDE environment will be removed in a future release. After GUIDE is removed, existing GUIDE apps will continue to run in Matlab but they will not be editable in GUIDE. If you're starting a new GUI, don't use GUIDE. If you're updating an existing GUIDE GUI, migrate it to AppDesigner. In R2021a the first step for this removal was taken: all templates except the blank template have been removed.
GUILT
Although I haven't had a detailed look myself, it seems a list like this is not complete without at least mentioning the GUI Layout Toolbox, which is available on the file exchange and offers a lot of customization options.
Programmatic GUIs
You can bypass GUIDE and use the normal figures and functions like uicontrol to build GUIs from code. This makes the design less visual, but more flexible for future additions.
App Designer
The official successor to GUIDE, AppDesigner is not based on functions, but works similar to a class. It uses uifigure and mostly uses graphical elements that are incompatible with 'normal' GUIs that are created with a figure (or .fig).
Summary:
Dynamically accessing variable names can negatively impact the readability of your code and can cause it to run slower by preventing MATLAB from optimizing it as well as it could if you used alternate techniques. The most common alternative is to use simple and efficient indexing.
Explanation:
Sometimes beginners (and some self-taught professors) think it would be a good idea to dynamically create or access variable names, the variables are often named something like these:
  • matrix1, matrix2, matrix3, matrix4, ...
  • test_20kmh, test_50kmh, test_80kmh, ...
  • nameA, nameB, nameC, nameD,...
Good reasons why dynamic variable names should be avoided:
There are much better alternatives to accessing dynamic variable names:
Note that avoiding eval (and assignin, etc.) is not some esoteric MATLAB restriction, it also applies to many other programming languages as well:
MATLAB Documentation:
If you are not interested in reading the answers below then at least read MATLAB's own documentation on this topic Alternatives to the eval Function, which states "A frequent use of the eval function is to create sets of variables such as A1, A2, ..., An, but this approach does not use the array processing power of MATLAB and is not recommended. The preferred method is to store related data in a single array." Data in a single array can be accessed very efficiently using indexing.
Note that all of these problems and disadvantages also apply to functions load (without an output variable), assignin, evalin, and evalc, and the MATLAB documentation explicitly recommends to "Avoid functions such as eval, evalc, evalin, and feval(fname)".
The official MATLAB blogs explain why eval should be avoided, the better alternatives to eval, and clearly recommend against magically creating variables. Using eval comes out at position number one on this list of Top 10 MATLAB Code Practices That Make Me Cry. Experienced MATLAB users recommend avoiding using eval for trivial code, and have written extensively on this topic.
The community is very helpful, yet I feel really powerless that I cannot find the appropriate way to code, nor find the problems with the codes I have written. I have read numerous books on MATLAB, mostly related with science and engineering applications. Any advice to improve would be greatly appreciated. Thanks.
Hello all,
Please explain good MATLAB programming practice methods. It will help to the guys who are new to programming like me.
Previously I used
for i=1:10
after following some suggestions from this answers pages I learnt to use
for i1=1:100
This is the good way to write programs.
Like this, as a professional programmer, please mention some good programming practice techniques.
It will useful to all!
Capital letters are obtained by capitalizing the LaTeX command for the lowercase version. Capital letters in grey are exceptions which have no LaTeX commands. For example, to produce a capital chi simply type X (this also applies for the lowercase omicron).
When two versions of the lowercase letter are available, a var prefix can be added to obtain the second version. For example, the two versions of epsilon are \epsilon and \varepsilon.
--------------------------------------------------------------------------------------------------------------------------------------------------------
The code used to generate the table:
greeks = ...
{'ALPHA' 'A' '\alpha'
'BETA' 'B' '\beta'
'GAMMA' '\Gamma' '\gamma'
'DELTA' '\Delta' '\delta'
'EPSILON' 'E' {'\epsilon','\varepsilon'}
'ZETA' 'Z' '\zeta'
'ETA' 'H' '\eta'
'THETA' '\Theta' {'\theta','\vartheta'}
'IOTA' 'I' '\iota'
'KAPPA' 'K' '\kappa'
'LAMBDA' '\Lambda' '\lambda'
'MU' 'M' '\mu'
'NU' 'N' '\nu'
'XI' '\Xi' '\xi'
'OMICRON' 'O' 'o'
'PI' '\Pi' {'\pi','\varpi'}
'RHO' 'P' {'\rho','\varrho'}
'SIGMA' '\Sigma' {'\sigma','\varsigma'}
'TAU' 'T' '\tau'
'UPSILON' '\Upsilon' '\upsilon'
'PHI' '\Phi' {'\phi','\varphi'}
'CHI' 'X' '\chi'
'PSI' '\Psi' '\psi'
'OMEGA' '\Omega' '\omega'};
h = figure('units','pixels','pos',[300,100,620,620],'Color','w');
axes('units','pixels','pos',[10,10,600,600],'Xcol','w','Ycol','w',...
'Xtick',[],'Ytick',[],'Xlim',[0 6],'Ylim',[0,4]);
% Loop by column and row
for r = 1:4
for c = 1:6
el = (r-1)*6 + c;
% Title
text(c-0.5,5-r,greeks{el,1},'Fonts',14,'FontN','FixedWidth',...
'Hor','center','Ver','cap')
% Color cap latter in grey or black
if strcmp(greeks{el,2}(1),'\')
clr = [0, 0, 0];
else
clr = [0.65, 0.65, 0.65];
end
% Cap letter
text(c-0.5,4.87-r,['$\rm{' greeks{el,2} '}$'],'Fonts',40,...
'Hor','center','Ver','cap','Interp','Latex','Color',clr)
% Lowercase letter/s (if two variants)
if iscell(greeks{el,3})
text(c-0.75,4.48-r,['$' greeks{el,3}{1} '$'],'Fonts',20,...
'Hor','center','Interp','Latex')
text(c-0.25,4.48-r,['$' greeks{el,3}{2} '$'],'Fonts',20,...
'Hor','center','Interp','Latex')
% Latex command
text(c-0.5,4.3-r,['\' greeks{el,3}{1}],'Fonts',12,'FontN','FixedWidth',...
'Hor','center','Ver','base')
else
text(c-0.5,4.48-r,['$' greeks{el,3} '$'],'Fonts',20,...
'Hor','center','Interp','Latex')
text(c-0.5,4.3-r,['\' greeks{el,3}],'Fonts',12,'FontN','FixedWidth',...
'Hor','center','Ver','base')
end
end
end
% Print to pdf
export_fig greeks.pdf
The link to export_fig.
And here is the link to the pdf on scribd: http://www.scribd.com/doc/159011120/Greek-alphabet-in-latex
[INDEX]
--------------------------------------------------------------------------------------------------------------------------------------
[MOTIVATION]
Why should we use markups in the body of our questions?
The answer is a question: which of the two versions is more likely to be understood in a glimpse and has more chances to be answered by our readers?
.
< Consider the following question >
I have a vector of weights W=[10,20,30,50,23434,1,2.4,2] and a matrix A=rand(100,8) and I would like to find the row-wise weighted sum of A. I am proceeding in the following way: B=zeros(size(A)); for c=1:numel(W) B(:,c)=A(:,c)*W(c); end B=sum(B,2); Somehow I get huge numbers can you please help?
.
< Now, consider its formatted version >
I have a vector of weights W = [10,20,30,50,23434,1,2.4,2] and a matrix A = rand(100,8) and I would like to find the row-wise weighted sum of A.
I am proceeding in the following way:
B = zeros(size(A));
for c = 1:numel(W)
B(:,c) = A(:,c)*W(c);
end
B = sum(B,2);
Somehow I get huge numbers can you please help?
--------------------------------------------------------------------------------------------------------------------------------------
[AKNOWLEDGMENTS]
In alphabetical order by nickname, thanks for their suggestions to:
Walter Roberson
--------------------------------------------------------------------------------------------------------------------------------------
[LOG]
  • 06 Aug 2011, 13:17 BST - created and added boldface.gif
  • 06 Aug 2011, 14:59 BST - added italic.gif
  • 06 Aug 2011, 18:58 BST - added index section
  • 07 Aug 2011, 00:03 BST - added code.gif and tutorial series section
  • 07 Aug 2011, 01:50 BST - added monospaced.gif, numlist.gif, bullist.gif and hyperlink.gif
  • 13 Aug 2011, 14:27 BST - added motivation section
  • 18 Aug 2011, 01:44 BST - added aknowledgments section and link to wish-list
--------------------------------------------------------------------------------------------------------------------------------------
[TUTORIAL Series]
Do not forget to read the Markup help (located on the top-right corner of the Body pane)
Vote on Wish-list for MATLAB Answer sections my post if you think that a tutorial section on top of Answers could be useful.
Now, I am still a novice when it comes to programming. I believe MATLAB is definitely a great programming tool, one that I can play with, particularly, when I have free time.
I would love to hear from all answerers, what are the ways that can make one proficient in this field?