Main Content

Results for

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.
I am trying to simulate a 3 phase induction motor on Simulink by using its dynamic model. This is the information in its datasheet:
It also has 4 poles and J = 0.0117 kgm², star connection. After calculate parameters, I get these values:
Lm = 0.176 H; Rr=Rs = 0.613Ω; Llr=Lls = 0.00669 H.
Also in the datasheet, they said that the output torque = 705 Nm at speed 35 rpm, but the model cannot reach that value. The simulation motor run backward if applied torque greater than 70 Nm ( at about 1200 rpm). But in reality, this motor can withstand 705 Nm, I have seen it run.
Can someone help me with this problem? Thank you
/*
* 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.
Hi,
I have two DGs and I want a secondary control between these two DGs using mpc toolbox. I don't know where I am going wrong with it. it is not working. when I am trying to change the load the frequency is still the same. Can anyone please help?
Thanks
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,'-');
Hullo Everyone. I have published a video on the MathWorks YouTube channel that explains active, reactive and apparent power. It is less than 9 minutes and so can be viewed over a coffee break. Here's the link https://www.youtube.com/watch?v=DCUwK6AfzcM
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.
Hi,
I am using matlab fuction block to calculate duty ratio for a MOSFET . How do I incorporate time delay in the calculated duty cycle. Duty cycle of S3 should be delayed by d1 in the picture.Kindly help

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 datasheet of an induction motor (as figure below). I want to simulate it on matlab/simulink, but I don't know it's parameters (Lls, Llr, Lm, Rr, Rs).

I tried to search about open circuit test and blocked rotor test to determine these parameters, but some of information doesn't appear on datasheet and I don't have the real motor to test on it (datasheet is only think I have).

Could someone help me with this?

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