Results for
Hello guys:
I am having a problem with something I'm doing, I don't know whether it is something related to thingspeak or to my program. I am using Curl library in c to make Get requests to send data to my channel, those data are are measurments of my Analog Discovery 2 device and they are instantaneous, (using the AD2 SDK library which was uploaded recently, and in it they use thingspeak to send the measurments too) . However, the updating to my channel is happenning very slowly (every new sample update happens each 15 seconds). What do you think is causing the problem? is the updating to the channels is usually slow and you can't do thing kind of fast uploading? or is it something that my code fails to communicate with the channel properly. I attached a photo to my program which shows the status of the Curl Get requests (which demonstrates the connectivity problem). Appreciating any help.
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?
You've spent hours designing the perfect figure and now it's time to add it to a presentation or publication but the font sizes in the figure are too small to see for the people in the back of the room or too large for the figure space in the publication. You've got titles, subtitles, axis labels, legends, text objects, and other labels but their handles are inaccessible or scattered between several blocks of code. Making your figure readable no longer requires digging through your code and setting each text object's font size manually.
Starting in MATLAB R2022a, you have full control over a figure's font sizes and font units using the new fontsize function (see release notes ).
Use fontsize() to
- Set FontSize and FontUnits properties for all text within specified graphics objects
- Incrementally increase or decrease font sizes
- Specify a scaling factor to maintain relative font sizes
- Reset font sizes and font units to their default values . Note that the default font size and units may not be the same as the font sizes/units set directly with your code.
When specifying an object handle or an array of object handles, fontsize affects the font sizes and font units of text within all nested objects.
While you're at it, also check out the new fontname function that allows you to change the font name of objects in a figure!
Give the new fontsize function a test drive using the following demo figure in MATLAB R2022a or later and try the following commands:
% Increase all font sizes within the figure by a factor of 1.5 fontsize(fig, scale=1.5)
% Set all font sizes in the uipanel to 16 fontsize(uip, 16, "pixels")
% Incrementally increase the font sizes of the left two axes (x1.1) % and incrementally decrease the font size of the legend (x0.9) fontsize([ax1, ax2], "increase") fontsize(leg, "decrease")
% Reset the font sizes within the entire figure to default values fontsize(fig, "default")
% Create fake behavioral data
rng('default')
fy = @(a,x)a*exp(-(((x-8).^2)/(2*3.^2)));
x = 1 : 0.5 : 20;
y = fy(32,x);
ynoise = y+8*rand(size(y))-4;
selectedTrial = 13;
% Plot behavioral data
fig = figure('Units','normalized','Position',[0.1, 0.1, 0.4, 0.5]);
movegui(fig, 'center')
tcl = tiledlayout(fig,2,2);
ax1 = nexttile(tcl);
hold(ax1,'on')
h1 = plot(ax1, x, ynoise, 'bo', 'DisplayName', 'Response');
h2 = plot(ax1, x, y, 'r-', 'DisplayName', 'Expected');
grid(ax1, 'on')
title(ax1, 'Behavioral Results')
subtitle(ax1, sprintf('Trial %d', selectedTrial))
xlabel(ax1, 'Time (seconds)','Interpreter','Latex')
ylabel(ax1, 'Responds ($\frac{deg}{sec}$)','Interpreter','Latex')
leg = legend([h1,h2]);
% Plot behavioral error
ax2 = nexttile(tcl,3);
behavioralError = ynoise-y;
stem(ax2, x, behavioralError)
yline(ax2, mean(behavioralError), 'r--', 'Mean', ...
'LabelVerticalAlignment','bottom')
grid(ax2, 'on')
title(ax2, 'Behavioral Error')
subtitle(ax2, ax1.Subtitle.String)
xlabel(ax2, ax1.XLabel.String,'Interpreter','Latex')
ylabel(ax2, 'Response - Expected ($\frac{deg}{sec}$)','Interpreter','Latex')
% Simulate spike train data ntrials = 25; nSamplesPerSecond = 3; nSeconds = max(x) - min(x); nSamples = ceil(nSeconds*nSamplesPerSecond); xTime = linspace(min(x),max(x), nSamples); spiketrain = round(fy(1, xTime)+(rand(ntrials,nSamples)-.5)); [trial, sample] = find(spiketrain); time = xTime(sample);
% Spike raster plot
axTemp = nexttile(tcl, 2, [2,1]);
uip = uipanel(fig, 'Units', axTemp.Units, ...
'Position', axTemp.Position, ...
'Title', 'Neural activity', ...
'BackgroundColor', 'W');
delete(axTemp)
tcl2 = tiledlayout(uip, 3, 1);
pax1 = nexttile(tcl2);
plot(pax1, time, trial, 'b.', 'MarkerSize', 4)
yline(pax1, selectedTrial-0.5, 'r-', ...
['\leftarrow Trial ',num2str(selectedTrial)], ...
'LabelHorizontalAlignment','right', ...
'FontSize', 8);
linkaxes([ax1, ax2, pax1], 'x')
pax1.YLimitMethod = 'tight';
title(pax1, 'Spike train')
xlabel(pax1, ax1.XLabel.String)
ylabel(pax1, 'Trial #')
% Show MRI
pax2 = nexttile(tcl2,2,[2,1]);
[I, cmap] = imread('mri.tif');
imshow(I,cmap,'Parent',pax2)
hold(pax2, 'on')
th = 0:0.1:2*pi;
plot(pax2, 7*sin(th)+84, 5*cos(th)+90, 'r-','LineWidth',2)
text(pax2, pax2.XLim(2), pax2.YLim(1), 'ML22a',...
'FontWeight', 'bold', ...
'Color','r', ...
'VerticalAlignment', 'top', ...
'HorizontalAlignment', 'right', ...
'BackgroundColor',[1 0.95 0.95])
title(pax2, 'Area of activation')
% Overall figure title title(tcl, 'Single trial responses')
This Community Highlight is attached as a live script.
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,
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
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.
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?
Several major updates have been introduced to Answers’ reputation system! The updates include a new User Levels system, a new Editor indicator, and updated badges series.
1. User Levels
User Levels have become a best practice for many community sites to adopt. They help build trust in the community and provide recognition to contributors. There are 10 levels in the system and the labels will display next to users’ names throughout MATLAB Answers and on your community profile. We hope to see more users climb the ladder and level up!
2. Editor Indicators
Becoming an Editor (upon earning 3,000 points) is a huge milestone in Answers. Therefore, we introduced the Editor indicator to show our appreciation. From the screenshot below, you will notice a user can have both a User Level and an Editor indicator.
3. Updated Badge Series
Based on our analysis of existing badges, we decided to introduce 2 new badges into existing series and retire an entire badge series.
- The Knowledgeable badge series and the Thankful badge series now have 5 levels.
- The Revival badge series has been archived and is no longer being awarded. If you earned one of these badges, it would still show up in your community profile.
You will find more information on Answers help page . If you have any questions, comments or feedback, free feel to leave a comment below.
Cody is a useful tool to practice MATLAB skills not only by solving the problems but also learn from each other’s solutions. Sometimes you see subpar solutions that are cheats and hacks. With the flagging feature we released recently, you can help us identify solutions that administrators, including Community Advisory Board members, can review and delete.
How to flag?
Flag Options - Only available on solutions
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;
}