Main Content

Results for

J Slade
J Slade
Last activity on 31 May 2022

After leaving a Thingspeak trend tab dormant for a period of time, when I reopen it, numerous data points are missing:
After I refresh the tab, all the data points fill back in:
Any ideas what causes this and how to prevent it?
Thanks
I found I have to use VPN to access my thingspeak data channels from China. Is this a known problem? if yes, anything I can do to solve the problem?
I am trying to write a table to a TS channel using thingSpeakWrite. The code below results in error but the help documentation indicates that it can be done. Any suggestion on how to fix this?
Function to call:
thingSpeakWrite(channelID,ship1(1,:),'WriteKey',writeAPIKey);
The complete code:
%Initialize table to be written to ThingSpeak
varNames = ["MMSI", "LAT", "LONG", "SOG", "VesselName", "VesselType", "Length", "Width"];
varTypes = ["double", "double", "double", "double", "categorical", "double", "double", "double"];
ship1 = table('Size',[20 8],'VariableTypes',varTypes,'VariableNames',varNames);
ship1.MMSI(:) = 121212;
ship1.SOG(:) = 10;
ship1(:,5) = {'PRIMODY'};
ship1(:,6) = {37};
ship1.Length(:) = 20;
ship1.Width(:) = 12;
thingSpeakWrite(channelID,ship1(1,:),'WriteKey',writeAPIKey);
Hello everyone, I need some help, I am developing a POC for a TCC using the DEMO itself "Example of HTTPS GET with SoftwareSerial and Arduino-SIM800L-driver" and when sending the data I am receiving a 606 error, does anyone have any idea of what it might be and how to solve it, I've validated the string sends through POSTMAN and it's ok.
SIM800L : Receive "AT+HTTPPARA="URL","https://api.thingspeak.com/update?api_key=XXXXXXXXXXXXXXX&field1=-23.5204435&field2=-46.5078319&field3=10&field4=600"
OK
"
SIM800L : Send "AT+HTTPPARA="REDIR",1"
SIM800L : End of transmission
SIM800L : Receive "AT+HTTPPARA="REDIR",1
OK
"
SIM800L : Send "ATI"
SIM800L : End of transmission
SIM800L : Receive "ATI
SIM800 R14.18
"
SIM800L : initiateHTTP() - Support of SSL enabled
SIM800L : Send "AT+HTTPSSL=1"
SIM800L : End of transmission
SIM800L : Receive "AT+HTTPSSL=1
OK
"
SIM800L : Send "AT+HTTPACTION=0"
SIM800L : End of transmission
SIM800L : Receive "AT+HTTPACTION=0
OK
"
SIM800L : End of transmission
SIM800L : Receive "
+HTTPACTION: 0,606,0
"
SIM800L : readHTTP() - HTTP status 606
SIM800L : Send "AT+HTTPTERM"
SIM800L : End of transmission
SIM800L : Receive "AT+HTTPTERM
OK
All my mqtt python thingspeak publish programs are stop sending values to thingspeak cloud today. is that issue with thingspeak cloud or any other issue.
/*
* Use software serial for the PZEM
* Pin gpio2 Rx (Connects to the Tx pin on the PZEM)
* Pin gpio0 Tx (Connects to the Rx pin on the PZEM)
*/
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <PZEM004Tv30.h>
#include "credentials.h" //this file keeps some private settings
WiFiClient wificlient;
WiFiClient glient; //Google client
//PZEM004Tv30 pzem(11, 12); //original config
PZEM004Tv30 pzem(4, 5); //Rx,Tx,(D2,D1) on nodeMCU
//PZEM004Tv30 pzem(13, 15); //Rx,Tx,(D7,D8) another config
//PZEM004Tv30 pzem(2, 0); //Rx,Tx,(gpio2,gpio0) on ESP-01
String tsStatus; //ThingSpeak, 255 char, null terminated
String status;
int error = 0; //0 no error; 1,2,4,8,16,32 -> errors for each parameter
float voltage, current, power, energy, frequency, pf;
float Vmax = 120.0;
float Vmin = 120.0;
float Pmax = 0.0;
int readAvg = 29; //nr of measurements averaged and sent to TS
int hour, minute, second, day, month, year;
//==============================================================================
// Functions
//==============================================================================
void wifiConnect(int n)
// "n" is the max number of tries to connect to SSID. If "n" reaches zero then
// wait for 15min and tries again for k (=100) cycles (100 * 15min ~ 25 hours)
{
WiFi.disconnect();
WiFi.mode(WIFI_STA);
WiFi.begin(ssid,password);
int nn = n;
int k = 100; // [_] to put this at the beginning
while (k > 0)
{
while ((WiFi.status() != WL_CONNECTED) && (n > 0))
{
delay(1000);
Serial.print(n);Serial.print(" >");
//Serial.print(F(":"));
n--;
}//while
//either connected or n = 0
//if connected -> break
if (WiFi.status() == WL_CONNECTED)
{
Serial.print(F("\nWiFi connected to IP address: ")); //@
Serial.println(WiFi.localIP()); //@
break;//exit from outward while
//return;
}
if (n == 0) //not connected to wifi during n*1000ms
{
n = nn; //start over with initial n
k--;
if (k != 0)
{
delay(300000); // 5 min
}
else //-> k == 0
{
Serial.println(F("Restart"));
delay(50);//to allow the serial to finish
ESP.restart();
}
}
}//while
return;//this point is reached only from the above 'break'
}
String getTime()
{
//in the main prog is defined the client to access google as "glient"
Serial.println(F("connecting to google"));//@
//Serial.println(google); //@
if (!glient.connect(ghost, httpPort))
{
Serial.println(F("connection failed"));
return "google_fail";
}
// This will send the request to the server
glient.println("HEAD / HTTP/1.1");
glient.println("Host: www.google.com"); // "Host: www.google.com"
glient.println("Accept: */*");
glient.println("User-Agent: Mozilla/4.0 (compatible; esp8266 Arduino;)");
glient.println("Connection: close");
glient.println();
delay(500);
// Read all the characters of the reply from server and print them to Serial
String reply = String("");
while(glient.available())
{
char c = glient.read();
reply = reply + String(c);
}
//Serial.print(reply); //@
String d = reply.substring(reply.indexOf("Date: ")+11,reply.indexOf("Date: ")+23);
String t = reply.substring(reply.indexOf("Date: ")+23,reply.indexOf("Date: ")+35);
hour = t.substring(0, 2).toInt();
minute = t.substring(3, 5).toInt();
second = t.substring(6, 8).toInt();
day = d.substring(0, 2).toInt();
month = d.substring(3, 5).toInt();
year = d.substring(6, 8).toInt();
hour = hour + 16;//for summer is 16, for winter is 15
if (hour >= 24)
{
hour = hour % 24; //This is GMT - 4 -> Mtl hour
}
if(!glient.connected())
{
//Serial.println("disconnecting");
glient.stop();
}
Serial.println("connection closed"); //@
return t;
}
void setup()
{
Serial.begin(115200);
tsStatus = String("");
Serial.println(F("\nFilename: PZEM_SoftSerial.ino/30jun2020 "));
//WiFi.persistent(false);
//Wifi.persistent(false) is used for deep-sleep, to keep wifi param in ram
wifiConnect(60); //try for 60 seconds
glient.setTimeout(5000);
getTime();
}
void loop()
{
/*
the time is got first in setup(). The loop is parsed each two seconds so
I need a counter variable (or a time variable) to check the local time (millis)
to know when to ask again google for date&time.
I need also a procedure to sync on zero seconds.
The data is sent each minute.
*/
if ((WiFi.status() != WL_CONNECTED))
{
wifiConnect(60);
}
float Voltage = 0.0, Current = 0.0, Power = 0.0, Energy = 0.0, Frequency = 0.0, PF = 0.0;
for (int i = 0; i < readAvg; i++)
{
error = 0;
voltage = pzem.voltage();
if( !isnan(voltage) )
{
Serial.print("Voltage: "); Serial.print(voltage); Serial.println("V");
Voltage += voltage;
//check for Max and Min values
if (voltage > Vmax)
{
Vmax = voltage;
}
if (voltage < Vmin)
{
Vmin = voltage;
}
//send Vmax and Vmin as tsStatus
Serial.print("\tVmax = ");Serial.print(Vmax);Serial.println("V");
Serial.print("\tVmin = ");Serial.print(Vmin);Serial.println("V");
}
else
{
Serial.println(F("Error reading voltage"));
error = error + 1;
}
current = pzem.current();
if( !isnan(current) )
{
Serial.print("Current: "); Serial.print(current); Serial.println("A");
Current += current;
}
else
{
Serial.println(F("Error reading current"));
error = error + 2;
}
power = pzem.power();
if( !isnan(power) )
{
Serial.print("Power: "); Serial.print(power); Serial.println("W");
Power += power;
//check for Max value
if (power > Pmax)
{
Pmax = power;
}//--> to send Pmax as tsStatus
Serial.print("\tPmax = ");Serial.print(Pmax);Serial.println("W");
}
else
{
Serial.println(F("Error reading power"));
error = error + 4;
}
energy = pzem.energy();
if( !isnan(energy) )
{
Serial.print("Energy: "); Serial.print(energy,3); Serial.println("kWh");
Energy += energy;
}
else
{
Serial.println(F("Error reading energy"));
error = error + 8;
}
frequency = pzem.frequency();
if( !isnan(frequency) )
{
Serial.print("Frequency: "); Serial.print(frequency, 1); Serial.println("Hz");
Frequency += frequency;
}
else
{
Serial.println(F("Error reading frequency"));
error = error + 16;
}
pf = pzem.pf();
if( !isnan(pf) )
{
Serial.print("PF: "); Serial.println(pf);
PF += pf;
}
else
{
Serial.println(F("Error reading power factor"));
error = error + 32;
}
Serial.println();
if (error > 0)
{
Serial.print("--> Error: "); Serial.println(error);Serial.println();
}
delay(1950);
}//for
voltage = Voltage / readAvg;
current = Current / readAvg;
power = Power / readAvg;
energy = Energy / readAvg;
frequency = Frequency / readAvg;
pf = PF / readAvg;
status = "Error = " + String(error) + " / Pmax = " + String(Pmax) + " / Vmax = " + String(Vmax) + " / Vmin = " + String(Vmin);
tsStatus = String(status).c_str();
//Serial.println(status);
Serial.println(tsStatus);
//delay(2000);
transferData();
Vmax = 120.0;
Vmin = 120.0;
Pmax = 0.0;
}
//------------------------------------------------------------------------------
void transferData()
//transfer data to ThingSpeak
{
Serial.println(F("transferData()")); //@
String url = "/update?api_key=" + ThingSpeak_key +
"&field1=" + energy +
"&field2=" + power +
"&field3=" + voltage +
"&field4=" + current +
"&field5=" + frequency +
"&field6=" + pf +
"&status=" + tsStatus; //String(tsStatus).c_str();
//see the notes at the top of this file.
if (!wificlient.connect(ThingSpeak, 80))
{
Serial.println(F("connection to ThingSpeak failed"));
}
else
{
wificlient.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " +
ThingSpeak + "\r\n" + "Connection: keep-alive\r\n\r\n");
while (!wificlient.available())
{
//waiting...
}
delay(200);
}
if (gettsStatus()) Serial.println(F("Data transfer OK to ThingSpeak")); //@
}
boolean gettsStatus()
{
Serial.println(F("getStatus()")); //@
bool stat;
String _line;
_line = wificlient.readStringUntil('\n');
int separatorPosition = _line.indexOf("HTTP/1.1");
if (separatorPosition >= 0)
{
if (_line.substring(9, 12) == "200")
stat = true;
else
stat = false;
return stat;
}
}
const char* ssid = " ssid";
const char* password = " password";
const char* ThingSpeak = "api.thingspeak.com";
const String ThingSpeak_key = "xxxxxxxxxxxxxxxx"; //
unsigned long ThingSpeak_channel = ; //99999999999;
const char* ghost = "www.google.com";
const int httpPort = 80;
i want to send temperature read to field1 and ecg read to field2
how can i write the code
and i have another problem that i don't have ecg code to thingspeak

I wanted to ask of 3M messages of thingspeak free account will renew every year? Thank You

I want code for plotting windrose in matlab
I have 2 type of data for plot that is wind speed and wind direction
pls I want it quickly .
Kirito23
Kirito23
Last activity on 14 May 2022

Hi, How can I draw windrose on matlab,I have attached sample data for you, sorry for the inconvenience

WHAT DOES THIS MEAN PLS?
Need help :(
Warning: 'Unable to read 500 points as requested. Only 0 points available in the channel.
Good morning,
I'm working with an Arduino MKR 1010 which takes information about weather from the website "api.openweathermap.org". On a ThingSpeak dashboard I displayed the main numbers (float) information like: temperature, wind speed, humidity, etc. Moreover, from the openweathermap I can also get string sentence (e.g. "light rain" or "broken clouds" etc.). I'm wondering if there is a way to display on the ThingSpeak dashboard string fields. Indeed, in the ThingSpeak Channel Settings I added an extra Field in order to store these string words but I don't know how to print them in the dashboard.
Someone can help me?
Thanks in advance,
Lorenzo
Hey guys, I am trying to get a certain value from this webpage (wave height in metres) and store it in a variable. whenever I test my API, I get this error. I have even tried existing examples that other people claim are working for them and they do not work for me.
Error parsing document, try a different parse string.
This is the webpage I am taking the information from.
This is the current Xpath that I am using for the swell height value I want.
/html/body/div[3]/div/main/div[3]/div[1]/mhl-datatables/div/div[1]/div/ngx-datatable/div/datatable-body/datatable-selection/datatable-scroller/datatable-row-wrapper/datatable-body-row/div[2]/datatable-body-cell[2]/div/span
IK
IK
Last activity on 6 May 2022

Hello,
I wanna make a figure that has one image and three plots.
So, I tried to put an image the first column next to three plots, but it didn't work.
what should I do?
and, I need to make 30 figures according to my images.
how should I make code with 'for' syntex?
figure(1);
subplot(3,2,[1,5]);
width = 1;
height = 1;
img = imread('MYIAMGES.png');
image(img)
set(gca, 'units','normalized','position',[0 0 width height]) %'XTick',zeros(1,0),'YTick',zeros(1,0));
subplot(3,2,2);
plot(date,A,'-');
subplot(3,2,4);
plot(date,B,'-');
hold on
plot(date,C,'-');
plot(date,D,'-');
subplot(3,2,6);
plot(date,E,'-');
hold on
plot(date,F,'-');
Hello
I am trying to run the example code for "Calculate and display average humidity" using my channel data. I filled in the blanks:
  1. readChannelID
  2. humidityFieldID
  3. NumMinutes=720
The program returns display(avgHumidity,'Average Humidity') with "NAN" instead of the correct average. I have a free ThingSpeak account but have been following temperature & humidity every hour for the last 9 months. I would also like to store this average value on the same channel on a new field. Can anyone help me?
Thank You
Hello,
I need an endpoint to retrive my file with data from my channel. Do you think is this possible?
Notice that i do not want to press export data button, i want an endpoint to use in a personal project.
Thank you.

Hello, I am currently working on a simple android app for a smart irrigation system. Basically the app lets the user enter the name of the plant and then lists all the plants of the garden. Then, I have divided plants into three categories depending on their watering needs and I have created three int values for the amount of plants per group. Essentially I want to send these three values to a thingspeak channel I created, to 3 separated fields. I am not familiar at all with server programming in Java so I would really appreciate any kind of help in how to do this.

Can not pick just a single field for "No data check", just the whole channel. Is there any way to change?

I have a personal account which I use for my home projects, along with a paid license which I use for monitoring a set of sensors in a remote building.

All my sensors went offline at about the same time, but I am only just noticing this now, because I have been focused on why the remote location went offline, thinking that it was an issue with the internet or WiFi at that location, rather than a problem with posting the data!

All my monitoring setups are using electricImp devices to post data to ThinkSpeak and have been in some cases, running for several years without any issues. All the devices are now returning a 400 - invalid constant string error.

See logs below.

|2022-04-19T13:30:07.017 +00:00	[Agent]	https://api.thingspeak.com/update?api_key=XXXXXXX&status=OK&created_at=2022-04-19 13:30:01 UTC&field4=0.00&field3=0.00&field6=0.00&field5=0.00&field2=14.65&field1=2022-04-19%2013%3A30%3A01%20UTC&status=OK&field8=0.6129&field7=0.00&created_at=2022-04-19%2013%3A30%3A01%20UTC
    2022-04-19T13:30:07.086 +00:00	[Agent]	PUSH: 400 - invalid constant string

I modified a device to not send the date in field 1 on one device because I thought that might be causing the problem, but it is not clear to me what changed. I have been sending data like this for a long time.

Any ideas appreciated.

Thanks

Hi... I managed to work out both the pub & sub parts of MQTT with my esp8266. I did the example from over here ... and all works fine. The publishing happens every 15secs... and it received the published values back almost immediately. see Img1.png

Now using flutter from my mobile app I did the same thing... and I was able to pub & sub... and also checked the Field1 values in my Thingspeak account that i am writing to and reading as an MQTTclient. It all works correctly.

HOWEVER... heres the problem================ When I only publish from the mobile a value for Field1. And subscribing at the same time from my esp8266 to receive the updated value of Field1... something weird happens... My Field1 in the channel, in my Thingspeak account has been updated correctly... but my esp8266 doesnt receive the updated value. INSTEAD, at the same time I can see in the serial monitor logs, the esp8266 reconnects back to our MQTT server!! No update was received. It felt as if everytime I published a value from my mobile, it made my esp8266 disconnect and hence it needed to reconnect to the MQTT server. i checked this 10 times and it happened without a coincidence. I ran the same code on the esp8266, except that I never let it publish every 15secs. So all it did was stay subscribed and await an update from my mobile app. please see img2.png

and this is the flutters connection code

 client.logging(on: false);
    client.setProtocolV311();
    client.keepAlivePeriod = 10;
    client.onDisconnected = onDisconnected;  //....callbacks
    client.onConnected = onConnected;  //....callbacks
    client.pongCallback = pong;  //....callbacks
    final connMess = MqttConnectMessage()
        .withClientIdentifier('xxxxxxxxxxxxxxxx')
        .withWillTopic('willtopic') // If you set this you must set a will message
        .withWillMessage('My Will message')
        .startClean() // Non persistent session for testing
        .authenticateAs('xxxxxxxxxxxxxxxx', 'aaaaaaaaaaaa')
        .withWillQos(MqttQos.atMostOnce); // means = 0
    print('client connecting....');

Any help will be appreciated. Just wanted to iterate that individually they both work fine. Just that i need the updated value... and i dont receive it. Any ideas?? thanks, YOhan