Main Content

Results for

I have submitted a problem in cody some days back. Now it is not showing in my profile. Initially it was accepted and some people submitted the solutions also, however It has been removed after that, are there some guidelines which I am not following?

Hello, I see a difference in the number of elements returned by: https://api.thingspeak.com/channels/1389063/status.json?offset=0&results=2500&api_key=XXXXXXXXXXXXXX and https://api.thingspeak.com/channels/1389063/feeds.json?offset=0&results=2500&status=true&api_key=XXXXXXXX The first returns only 271 elements, the second 2500 as requested. Why is that?

I am working with an Arduino nodemcu board and a Tmp36 sensor. My channel updates fine if I use my browser with the following: https://api.thingspeak.com/update?api_key=xxxxxxxxx&field1=71, but does not update with the following sketch, although the serial monitor shows the commands are executed:

//Source code to the Temperature Sensor and ThingSPeak Server Blog
String ssid     = "XXX";  // SSID to connect to
String password = "XXX"; // Our virtual wifi has no password (so dont do your banking stuff on this network)
String host     = "api.thingspeak.com"; // Open Weather Map API
const int httpPort   = 443;
String uri     = "/update?api_key=XXXX&field1=";
int setupESP8266(void) {
  // Start our ESP8266 Serial Communication
  Serial.begin(115200);   // Serial connection over USB to computer
  Serial.println("AT");   // Serial connection on Tx / Rx port to ESP8266
  delay(10);        // Wait a little for the ESP to respond
  if (!Serial.find("OK")) return 1;
    // Connect to 123D Circuits Simulator Wifi
    Serial.println("AT+CWJAP=\"" + ssid + "\",\"" + password + "\"");
    delay(10);        // Wait a little for the ESP to respond
    if (!Serial.find("OK")) return 2;
    // Open TCP connection to the host:
    Serial.println("AT+CIPSTART=\"TCP\",\"" + host + "\"," + httpPort);
    delay(50);        // Wait a little for the ESP to respond
    if (!Serial.find("OK")) return 3;
    return 0;
  }
void anydata(void) {
    int temp = map(analogRead(A0),20,358,-40,125);
    // Construct our HTTP call
    String httpPacket = "GET " + uri + String(temp) + " HTTP/1.1\r\nHost: " + host + "\r\n\r\n";
    int length = httpPacket.length();
    // Send our message length
    Serial.print("AT+CIPSEND=");
    Serial.println(length);
    delay(10); // Wait a little for the ESP to respond if (!Serial.find(">")) return -1;
    // Send our http request
    Serial.print(httpPacket);
    delay(1000); // Wait a little for the ESP to respond
    if (!Serial.find("SEND OK\r\n")) return;
}
void setup() {
    setupESP8266();
}
void loop() {
   anydata();
    delay(10000);
  }

hello, i have done my iot project using thingspeak as the monitoring source and its working well and good.But now i need get text message to a mobile when the field value gets reached to given threshold value and i have to get a alert text message.Is there any way to resolve my problem from thigspeak data to alert text message.

Thankyou.

Hi,

I am using Ublox SARA-R410M to send (cellular) data to ThingSpeak cloud. I found in the Ublox manual that AT+UHTTPC (POST data command) can do the job. The link below is the location which my data will be saved on ThingSpeak (field1):

"https://api.thingspeak.com/update?api_key=WRITE_API_KEY&field1="

Note that the "WRITE_API_KEY" is 16 characters (combination of letters and numbers).

AT command: AT+UHTTPC=<profile_id>,5, path,<filename>,<data>,<HTTP_content_type>

Based on the information above, which items should I use for path and filename? And how can I use this command in Arduino code?

I appreciate any help in advance.

Abbas

Hi everyone
I am a new of this community and I very interested in this forum and Matlab.I am trying to submit a soultion but as tiltle my code has a built-in function so the test systerm dont reconisie it.It run completely ok on my computer.
This is problem
This is my solution
function [boOut] = BoIfPointInPoly(PolyMatrix,p_test)
%Summary of this function goes here
%{
if we draw a line from test point to a central point of a side of The polygon
then we extend that line to the furthest point of the polygon ensure that
line go through all side of Polygon in 1 direction.I call that line is line_test
Next find number of intersert of line test and all sides w polyxpoly
function
num interset point is odd mean p_test inside
num interset point is even mean p_test outside
this solution go from the concept that if a line go in from a side it has go out
from other side.So if it go in but not go out that mean it start from
inside.
%}
% Detailed explanation goes here
%line from p test throuh central of a side to furthest point of polygon
%find vector
V = ((PolyMatrix(1,:) + PolyMatrix(2,:)) /2) - p_test ;
%draw that vector to furtest point
pend = p_test + V * max(PolyMatrix(:));
%with multi of V and biggest element I assume that line will go all out the
%polygon which ensure out logic will right
line_test = [p_test ; pend];
disp('Our line test\n');
disp(line_test);
%find interst point
p_inter = polyxpoly(PolyMatrix(:,1),PolyMatrix(:,2),line_test(:,1),line_test(:,2));
%find number of interset (row)
[numIntere,trash] = size(p_inter);
disp('Number of interest point:');
disp(numIntere);
%determine in or out
if (rem(numIntere,2) == 0)
boOut = 0;
else
boOut = 1;
end
end
Can anyone has solution.

Hi,

I am using a Sparkfun LTE Shield with a SARA-R410M-02B-01 cellular module, an Arduino UNO, and an AT&T simcard to send data to ThingSpeak. I used "AT+UDNSRN" on Arduino code (below) to find IP address of "api.thingspeak.com". I found two different IPs using this command: "3.224.210.136","3.213.58.187" (also, nslookup command on CMD Windows gives me these IPs). Moreover, I found that some websites report "184.106.153.149" as ThingSpeak's IP. I used the "AT+USOCO" on Arduino code (below) for TCP connection using these three IPs:

Example of the Arduino codes:

lteSerial.println("AT+UDNSRN=0,\"api.thingspeak.com\""); //Find IP address
lteSerial.println("AT+USOCO=0,\"184.106.153.149\",\"80\""); //TCP Connection to ThingSpeak using IP address 

But I got this error (for "AT+USOCO" command):

+CME ERROR: Operation not allowed

Any idea regarding which IP address should I use for "api.thingspeak.com"?

I appreciate any help in advance.

Abbas

Introduction
Comma-separated lists are really very simple. You use them all the time. Here is one:
a,b,c,d
That is a comma-separated list containing four variables, the variables a, b, c, and d. Every time you write a list separated by commas then you are writing a comma-separated list. Most commonly you would write a comma-separated list as inputs when calling a function:
fun(a,b,c,d)
or as arguments to the concatenation operator or cell construction operator:
[a,b,c,d]
{a,b,c,d}
or as function outputs:
[a,b,c,d] = fun();
It is very important to understand that in general a comma-separated list is NOT one variable (but it could be). However, sometimes it is useful to create a comma-separated list from one variable (or define one variable from a comma-separated list), and MATLAB has several ways of doing this from various container array types:
1) from a field of a structure array using dot-indexing:
struct_array.field % all elements
struct_array(idx).field % selected elements
2) from a cell array using curly-braces:
cell_array{:} % all elements
cell_array{idx} % selected elements
3) from a string array using curly-braces:
string_array{:} % all elements
string_array{idx} % selected elements
Note that in all cases, the comma-separated list consists of the content of the container array, not subsets (or "slices") of the container array itself (use parentheses to "slice" any array). In other words, they will be equivalent to writing this comma-separated list of the container array content:
content1, content2, content3, .. , contentN
and will return as many content arrays as the original container array has elements (or that you select using indexing, in the requested order). A comma-separated list of one element is just one array, but in general there can be any number of separate arrays in the comma-separated list (zero, one, two, three, four, or more). Here is an example showing that a comma-separated list generated from the content of a cell array is the same as a comma-separated list written explicitly:
>> C = {1,0,Inf};
>> C{:}
ans =
1
ans =
0
ans =
Inf
>> 1,0,Inf
ans =
1
ans =
0
ans =
Inf
How to Use Comma-Separated Lists
Function Inputs: Remember that every time you call a function with multiple input arguments you are using a comma-separated list:
fun(a,b,c,d)
and this is exactly why they are useful: because you can specify the arguments for a function or operator without knowing anything about the arguments (even how many there are). Using the example cell array from above:
>> vertcat(C{:})
ans =
1
0
Inf
which, as we should know by now, is exactly equivalent to writing the same comma-separated list directly into the function call:
>> vertcat(1,0,Inf)
ans =
1
0
Inf
How can we use this? Commonly these are used to generate vectors of values from a structure or cell array, e.g. to concatenate the filenames which are in the output structure of dir:
S = dir(..);
F = {S.name}
which is simply equivalent to
F = {S(1).name, S(2).name, S(3).name, .. , S(end).name}
Or, consider a function with multiple optional input arguments:
opt = {'HeaderLines',2, 'Delimiter',',', 'CollectOutputs',true);
fid = fopen(..);
C = textscan(fid,'%f%f',opt{:});
fclose(fid);
Note how we can pass the optional arguments as a comma-separated list. Remember how a comma-separated list is equivalent to writing var1,var2,var3,..., then the above example is really just this:
C = textscan(fid,'%f%f', 'HeaderLines',2, 'Delimiter',',', 'CollectOutputs',true)
with the added advantage that we can specify all of the optional arguments elsewhere and handle them as one cell array (e.g. as a function input, or at the top of the file). Or we could select which options we want simply by using indexing on that cell array. Note that varargin and varargout can also be useful here.
Function Outputs: In much the same way that the input arguments can be specified, so can an arbitrary number of output arguments. This is commonly used for functions which return a variable number of output arguments, specifically ind2sub and gradient and ndgrid. For example we can easily get all outputs of ndgrid, for any number of inputs (in this example three inputs and three outputs, determined by the number of elements in the cell array):
C = {1:3,4:7,8:9};
[C{:}] = ndgrid(C{:});
which is thus equivalent to:
[C{1},C{2},C{3}] = ndgrid(C{1},C{2},C{3});
Further Topics:
MATLAB documentation:
Click on these links to jump to relevant comments below:
Dynamic Indexing (indexing into arrays with arbitrary numbers of dimensions)
Nested Structures (why you get an error trying to index into a comma-separated list)
Summary
Just remember that in general a comma-separated list is not one variable (although they can be), and that they are exactly what they say: a list (of arrays) separated with commas. You use them all the time without even realizing it, every time you write this:
fun(a,b,c,d)

I visualise my data with ThingSpeak (data from The Thing Network) and I would like to have something like a button to send a command (downlink). I can send downlink with the thing network but I would like : The thing speak (for interface) -> the thing network (for lora gateway management) -> my device I see talkback and some example with wifi node but it is not my case... Thank you for your reply

I have a fish feeder project running on an Arduino esp 32, it checks various parameter and feeds according to temperature. Unfortunately it has stopped, it no-longer talks to thingspeak and hence cannot upload data. I believe I have a free licence (according to thingspeak) I was only using 1 channel, hence 4 sufficient at this moment. How can I get it working again, ps feeding starts May!. I have googled and understand notice may have been given. Help please- relatively new to Arduino's and first project to us thingspeak. at the moment wireless communication appears more reliable.

If you are interested in live script lecture notes in the following areas, take a look at the short course ( Advanced MATLAB for Scientific Computing ) developed at Stanford. You can also download the required data for the examples from the course GitHub page.

  • MATLAB Fundamentals
  • Graphics and Data Visualization
  • Efficient Code Writing
  • System and File Manipulation
  • Big Data Handling
  • Numerical Linear Algebra
  • Numerical Optimization
  • Symbolic Toolbox, ODE, and PDE
  • Statistical and Machine Learning
  • Deep Learning
  • Object-Oriented Programming
  • Using MATLAB with Other Programming Languages
  • Image Processing, Computer Vision, and Image Acquisition
  • Signal Processing, Audio, and DSP System

Hola, mi proyecto es con NodeMcu ESP8266, en el puerto serial obtengo datos cada 2 minutos asi esta programado, en la grafica salta datos y algunas veces durante una hora o mas, Qoe podria hacer?

In many universities, introductory programming is taught as a foundation course. Students from different departments are usually brought together to learn to program in these foundation courses. Their home departments may have a programming language preference and that preference may change from department to department. Some universities either strictly teach one language in a single course, some of them teach multiple languages in the same course and give students the flexibility to choose their language for the assignments and projects. How can we make students multilingual when it comes to programming? Is there a way to teach multiple languages in a fair light, side by side without creating a new course or sacrificing one language to teach the other one? Dr. Nathan Kutz from the University of Washington found a creative way to teach MATLAB and Python side by side in his AMATH 301 course. This course is an introductory programming course at the University of Washington and almost all engineering students take it. Do you wonder how Dr. Kutz taught this course? Check out these recordings and course resources! They can be utilized in an in-person or a distance learning setting:

I'm monitoring a temp and humidity sensor outside of my house using a ESP32. I have it update every 15 minutes. On my channel I have a chart and numeric readout. The readout shows me that it is updating every 15 minutes but the chart's last update was 2 hours ago. This was working until I went into the properties of the chart and changed the time base from daily to 12 hours. I have tried refreshing the page, signing out and back in as well as reboot the computer, still 2 hours behind. Is there something else I have to do to reestablish the chart?

Thanks John

If you are a student or researcher looking for a project idea, have a look at the MathWorks Excellence in Innovation site. There is at least one IoT-based project for a Smart watering system, and a project with a Digital twin of a pneumatic system. If you ask me, most of the other projects could also be enhanced with an IoT based component shared on ThingSpeak!

#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
SoftwareSerial ESP01(2, 3);
const byte ROWS = 4; // four rows
const byte COLS = 3; // three columns
char keys[ROWS][COLS] = { // keypad labels
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};
byte rowPins[ROWS] = {12, 7, 8, 10};          //connect to keypad pins 12, 7, 8, 10
byte colPins[COLS] = {11, 13, 9};             // connect to keypad pins 11, 13, 9 column pinouts
Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
#define Password_Length 5
#define DEBUG true
#define IP "184.106.153.149"
// define pin numbers
int buzzer = 5; // buzzer is connected to pin 5
int PIR = 6;    // PIR is connected to pin 6
// intruder alarm password
char Data[Password_Length];
char Master[Password_Length] = "1234";
byte data_count = 0, master_count = 0;
bool Pass_is_good;
char customKey;
int val = 0;
// thingspeak & WiFi
String apiKey = "xxxxxxxxxxxxxxxx"; // thingspeak API key
void setup() {
lcd.init(); 
lcd.backlight();
pinMode(buzzer, OUTPUT);
pinMode(PIR, INPUT);
Serial.begin(9600); 
while (!Serial){
}
Serial.println("Starting...");
ESP01.begin(9600);
// Reset ESP8266, put it into mode 1 i.e. STA only, make it join hotspot / AP, 
// establish single connection
ESP01.println();
sendData("AT+RST\r\n",2000,DEBUG);
sendData("AT+CWMODE=1\r\n",2000,DEBUG);
sendData("AT+CWJAP=\"AiPhone\",\"123889\"\r\n",20000,DEBUG);  
sendData("AT+CIPMUX=0\r\n",4000,DEBUG);
// Make TCP connection
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += "184.106.153.149"; // Thingspeak.com's IP address  
cmd += "\",80\r\n";
sendData(cmd,4000,DEBUG);  
// Read PIR sensor value 
  val = digitalRead(PIR);
  // check if there was a state transition
    String val1 = String(val);
    if (val == HIGH)
    {
      Serial.println("Motion detected!");
      delay(10);
      Serial.println(val1);
    }
    else
    {
      Serial.println("Asleep");
      delay(10);
      //String val1 = String(val);
      Serial.println(val1);
    }
      //String val1 = String(val);
      //Serial.println(val1);
//Prepare GET string
String getStr = "GET /update?api_key=";
getStr += apiKey;
getStr += "&field1=";
getStr += val1;
getStr +="\r\n";
// Send data length & GET string
ESP01.print("AT+CIPSEND=");
ESP01.println (getStr.length());
Serial.print("AT+CIPSEND=");
Serial.println(getStr.length());
delay(500);
if(ESP01.find (">"))
{
  Serial.print(">");
  sendData(getStr, 2000, DEBUG);
}
//Close connection, wait a while before repeating
sendData("AT+CIPCLOSE", 16000, DEBUG); // 15 seconds delay between updates
}
if true
  % code
endvoid loop() {
if (digitalRead(PIR) == HIGH)
{
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Enter Password: ");
    customKey = customKeypad.getKey();
    if (customKey)
    {
      Data[data_count] = customKey;
      lcd.setCursor(data_count, 1);
      lcd.print(Data[data_count]);
      data_count++;
    }
    if (data_count == Password_Length - 1)
    {
      lcd.clear();
      if (!strcmp(Data, Master))
      {
        lcd.print("OK");
        digitalWrite(buzzer, HIGH);
        delay(200);
        digitalWrite(buzzer, LOW);
        delay(200);
        digitalWrite(buzzer, HIGH);
        delay(200);
        digitalWrite(buzzer, LOW);
      }
      else
      {
        lcd.print("Wrong Password");
        digitalWrite(buzzer, HIGH);
        delay(1000);
        digitalWrite(buzzer, LOW);
      }
      lcd.clear();
      clearData();
    }
  }
  else
    {
      lcd.noBacklight();      // turn backlight off
      lcd.clear();            // clear display
      delay(250);
    }
}
String sendData(String command, const int timeout, boolean debug)
{
  String response = "";
  ESP01.print(command);
  long int time = millis();
    while( (time+timeout) > millis())
    {
      while(ESP01.available())
      {
        // "Construct" response from ESP01 as follows 
         // - this is to be displayed on Serial Monitor. 
        char c = ESP01.read(); // read the next character.
        response+=c;
      }  
    }
    if(debug)
    {
      Serial.print(response);
    }
    return (response);
}
void clearData() {
  while (data_count != 0)
{
  Data[data_count--] = 0;
  }
  return;
}

I built a safe entry mechanism and i would like the matlab to send an email alert when arduino is not communicating or sending any data to thingspeak. How do i write the program to detect system down and to send email alert?

Hi, I want to send an alert to multiple email ids when a channel event occurs(for example:sensor temperature exceeds a threshold value).How can I do it?Help is highly appreciated. Thanks in Advance!

EL TERMÓMETRO QUEDO CLAVADO EN -127°, LO RESETEE PERO AUN NO FUNCIONA, POSRA SER LA ZONDA Y SI FUESE ASÍ COMO ADQUIRIRLA-

Are you looking for ways to keep your students engaged in a virtual setting? Would you like to spice up your courses with hands-on projects? Using Arduino Engineering Kit, you can achieve these. Due to COVID-19, many instructors started to look for creative ways of giving students a lab experience. Some of them chose to create virtual labs, some of them designed hardware projects with low-cost hardware or integrated hardware projects kits to their curriculum. If you are interested in how Dr. Azadi from San Francisco State University used Arduino Engineering Kit during the pandemic to teach his Mechatronics course, check out these articles: