結果:
I have a few ESP8266 running various sensor tasks, and sending GET or POST requests to Thingspeak via api.thingspeak.com. They all connect to the household router.
Recently, I became aware of a problem with the devices occasionally timing out when trying to communicate with Thingspeak. For example, here's a bit of code from a basic water level sensor:
String url = "http://api.thingspeak.com/update?api_key=xxxxxxxxxxxxx&field1=";
url += getdistance();
url += "&field8=";
url += batt;
http.begin(client, url);
int httpcode = http.GET();
Serial.println(httpcode);
String payload = http.getString();
Serial.println(payload);
http.end();
Fairly often, the connection will fail with a -1 httpcode. Sometimes it will run for weeks with no issues and then suddenly stop connecting. If I type the URL in a browser, it will always work immediately. If I connect the ESP to a mobile hotspot, it will also connect immediately with no issues. I can't find any issues at all with the router, and I've fully reset it etc. I've also confirmed the wifi connection between ESP and router is not the problem.
Sometimes one ESP will be running fine, and another will be having connection issues. The next day, the first one will have issues and the other will be fine.
So I added a bit of code to see if I could time the connection:
server = "api.thingspeak.com"
timer= millis();
while(client.connect(server,80)){
delay(10)}
t=millis()-timer;
Serial.print(t);
The devices now connect every time. But the connection can take up to 180 seconds. Some ESP's updating to older channels are much more reliable and connect within a second or two; it seems as though the more recently created channels take longer to connect to.
I'm reaching out here because I can't really think of where to begin trying to fix this. Why does a browser succeed immediately updating a channel with the api.thingspeak url but the ESP takes up to 180 seconds? Why do I not have any problems connecting the ESP via a mobile hotspot? Why does the same device work for weeks then suddenly play up?
I think I've isolated the problem to either the router or the thingspeak api, and I can't find anything wrong with the router.
Might be worth noting that I have an ESP in a heat pump which updates every 15 seconds to thingspeak by MQTT and it hasn't skipped a beat in months so maybe I should upgrade them all to MQTT.
Is the api just that flakey?
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback Error while evaluating Button PrivateButtonPushedFcn.
help to solve this error in face recognition GUI
Hi I have a user defined blocks for my Simulink but whenever I add path of user defined, the error pops up stating I dont have stateflow.
Can anyone please guide me through it.
Hello! I am wondering if it is possible to connect ls-dyna to matlab so that when i enter the parameters on matlab, ls-dyna reads the parameter from and runs the simulation and sends the result to matlab.
let me know if there's any more info needed, good solution or whether it is even possible
Dear all,
I would like to know if "Ridge regularization, i.e., L2" is applicable to the LSBoost regression model or not. After searching the MATLAB documentation, I found code only for "Lasso (L1) regularization."
For example:
t = templateTree(Reproducible=true);
bag = fitrensemble(X,Y,Method="Bag",NumLearningCycles=300,Learners=t);
bag = regularize(bag,Lambda=[0.001 0.1],Verbose=1);
Best regards,
Hello, I have applied the "sobel" edge detection function. However, I am not sure how to segment and single out only the cells that contain the " cross" shape inside of them. These are the cells infected by Babesisos, while the rest are not infected.
Thanks !
Hello everyone,
I am trying to simulate the trajectory of a two-stage rocket in Simulink. I am using the 'Custom Variable Mass 6DOF ECEF (Quaternion) Equation of Motion'. I would like to use a PID controller to control the pitch angle of the rocket (note, pitch angle is the output). The issue is that the above Equation of Motion is non-linear. Is there a way to linearize this EOM for the entire trajectory? the system is time dependent ( as the mass, velocity and trajectory changes with time).
link of the EoM:
https://nl.mathworks.com/help/aeroblks/customvariablemass6dofecefquaternion.html
hi
I have a problem when offline installing the support packages for the zynq on matlab r2019a.
I obtain the following error message:
"Support Software Installer Error
System does not have the required MATLAB version to start the support package installation."
I tried different versions, uninstall/re-install matlab, different ways for installing this package and it does not work
Do you have any suggestions
I'm getting an error error "using tall/cellfun" while doing a project listed in mathworks "Denoise Speech Using Deep Learning Networks". I don't know how to fix this error pr why this error occured in the first place. Seeking explanation for this particuar error. If you know anuthing about it then please consider helping me below this post.

Hello, all!
This is my first post after just joining this discussion, so please forgive me and provide kind assistance if I have posted to the wrong subsection!
I have a good interest in learning sql server course and right now I am taking help from various platforms like https://www.coursera.org/ https://www.udemy.com/
Also I have a doubt that is it a good option to learn from platforms like this or I should go for some sql server online training . I have searched for the solution of my queries in various above platforms which helped me up to some extent only as it was not directly given by any expert or trainer.
Hoping in getting a quick response
Thankyou in advance.
Hello, I am a student and I am working on a neural network for a line follower car and I would like you to recommend a tutorial to implement it in simulink.
Hello, everyone.
I have got the x,y,z coordinates and MagE for a radiation pattern. But when I want to plot it in spherical coordinates using 'patternCustom' function, I found the pattern is incomplete.
I attaced the data and script here. Can someone help me?

Hello everyone !!!!
I try to develop a test bench for cybersecurity in micro grids (Generations, Breakers,...) . I plan to simulate my grid on Simpower. I have a simulated PLC in a VM and a real RTAC. I would like to establish bidirectional communication between my grid simulated on Simpower and the physical RTAC (or the simulated PLC on VM). The RTAC is connected to a SCADA system which should be able to send commands to the grid (Simpower).
RTAC, Simpower, and the SCADA system are located on separate machines.
Any approach to establish a connection between Simpower and the RTAC (or PLC)?
Thanks !!!
Hello! I'm currently working on a heat transfer problem, I don't consider myself to be an expert, therefore I'm still learning how to use this tool.
Here's the thing: I have pretty much everything working, but there's an issue. The ELSE equation is not giving any results and I don't know exactly why. I would appreciate if someone would be interested in helping me learn about this because I'm at a loss righ now
%% Parámetros geométricos del dominio
A=3; %Anchura (en metros)
H=2.5; %Altura (en metros)
Nx= 7; %Número de nodos en la dirección x
Ny=6; %Número de nodos en la dirección y
dx=A/(Nx-1); %Distancia de elemento finito en dirección x (metros)
dy=H/(Ny-1); %Distancia de elemento finito en direccion y (metros)
%% Condiciones iniciales y de frontera
To=1000; %Temperatura interna del horno (en C)
T = ones(Nx,Ny);
Tinf=20; %Temperatura externa (en C)
ho=100; %Coeficiente de transferencia convectiva interior (en W/m^2K)
hinf=10; %Coeficiente de transferencia convectiva exterior (en W/m^2K)
q_dot=8000; %Calor generado por unidad volumétrica
K=1; %Conductividad del material (en W/mK)
epsilon=1e-5;
Error=5;
%% Computación
iter=0;
while (Error>epsilon)
iter=iter+1;
disp(iter);
Told=T;
for j=1:Ny
for i=1:Nx
if i==Nx
for j=2:Ny-1
T(i,j)=(2*T(i-1,j)+T(i,j-1)+T(i,j+1)+(q_dot*dx^2)/K)/4;
end
for j=Ny
T(i,j)=T(i,j-1)+T(i-1,j)+(q_dot*dx^2)/(2*K)+(hinf*dx*Tinf)/K;
end
for j=1
T(i,j)=((q_dot*dx^2)/(2*K)+T(i-1,j)+T(i,j+1));
end
elseif i==1
for j=Ny*4/6:Ny-1
T(i,j)=(2*T(i+1,j)+T(i,j-1)+T(i,j+1)+(q_dot*dx^2)/K)/4;
end
for j=Ny*0.5
T(i,j)=T(i,j+1)+T(i+1,j)+(q_dot*dx^2)/(2*K)+(hinf*dx*Tinf)/K;
end
for j=Ny
T(i,j)=T(i,j-1)+T(i+1,j)+(q_dot*dx^2)/(2*K)+(ho*dx*To)/K;
end
elseif i>1 && i<Nx
for j=Ny
T(i,j)=(T(i-1,j)+T(i+1,j)+2*T(i,j-1)+(q_dot*dx^2)/K+(2*hinf*dx*Tinf)/K)/(4+2*hinf*dx/K);
end
elseif 2<i && i<Nx*3/7
for j=Ny*0.5
T(i,j)=((T(i-1,j)+T(i+1,j)+2*T(i,j+1)+(q_dot*dx^2)/K)+(2*ho*dx*To)/K)/(4+2*hinf*dx/K);
end
elseif i==Nx*4/7
for j=2:Ny*2/6
T(i,j)=((T(i,j-1)+T(i-j+1)+2*T(i+1,j)+(q_dot*dx^2)/K)+(2*ho*dx*To)/K)/(4+2*hinf*dx/K);
end
for j=1
T(i,j)=T(i,j-1)+T(i+1,j)+(q_dot*dx^2)/(2*K)+(ho*dx*To)/K;
end
for j=Ny*0.5
T(i,j)=(T(i,j+1)+2*T(i+1,j)+2*T(i,j+1)+T(i-1,j)+(3*q_dot*dx^2)/(2*K)+(2*ho*dx*To)/K)/(6+(2*ho*dx)/K);
end
else
T(i,j)=(T(i-1,j)+T(i+1,j)+T(i,j-1)+T(i,j+1)+(q_dot*dx^2)/K)/4;
end
end
end
Error=sqrt(sumsqr(T-Told));
disp(Error);
end
T(1:3,1) = To;
T(1:3,2)=To;
%% Graficando el resultado
x=0:dx:A;
y=0:dy:H;
% Definir los límites de color para resaltar variaciones
min_temp = min(min(T)); % Obtener el valor mínimo de temperatura
max_temp = max(max(T)); % Obtener el valor máximo de temperatura
colormap(hot); % Cambiar el colormap (puedes probar otros)
contourf(x, y, T', 'LineWidth', 1); % Añadir un grosor de línea para los contornos
colorbar;
title('Distribución de Temperatura')
xlabel('Dirección en x')
ylabel('Dirección en y')
% Establecer los límites de color para resaltar variaciones
clim([min_temp, max_temp]); % Establecer los límites de color según los valores mínimos y máximos de temperatura
Matlab show me that the next problem.
Tie variable 'Pressure_Transducer_Timpano.p.v' (Voltage) to a definite value, for example by connecting an appropriate domain reference block.
I don't know what I should do in it because I have done an model by hearing and use this object because I want to modelate a Timpanumm membrane. If you could help I really gratefully.
I will include the picture.

Hi, I'm in truble because I have two programs with the same variables and parameters. The main of the study is to change a value and plot the results. The problem is that I want them on the same plot but I use the same name for the variabes in the two different programs so when I use some function to join the figures togheter matlab resets the values obtained in the first program and runs only the second one.
Is there a method to avoid changing all the names of the variables in one of the two programs (because they have something like 500 lines)?
I saw this post on Answers.
I was impressed at the capability of the AI, as I have been at other times when I posed a question to it, at least some of the time. So much so that I wondered...
What if the AI were automatically applied to EVERY question on Answers? Would that be a good or bad thing? For example, suppose the AI automatically offers an answer to every question as soon as it gets posted? Of course, users would still be allowed to post their own, possibly better answers. But would it tend to disincentivise individuals from ansering questions?
Perhaps as bad, would it push Answers into the mode of a homework solving forum? Since if every homework question gets a possibly pretty good automatic AI generated solution, then every student will just post all HW questions, and the forum would quickly become overwhelmed.
I suppose one idea could be to set up the AI to post an answer to all un-answered questions that are at least one month old. Then students would not gain by posting their homework.
Hi everyone,
I would like to ask you if it would be possible to do an HiL simulation using an environment model simulated via Simulink and load in a target computer connected to the hardware needed. The target computer will be simply a laptop with Matlab&Simulink package installed and directly connected to the bench to test.
I have found some solutions about the use of Simulink Real-Time but it implies the use of a Speedgoat unit, so I was wondering if anyone has ever done it without that device.
Thank you very much.
Hi, I'm trying to analyze a .vtk data set from MRI. I already calculate the kinetic energy. Now I'm trying to calculate the viscous energy loss but the result that I found does not respect the reality so I think that I'm doing something wrong.
Can someone help me with this?
%% FUNCTION
function energy_loss = calculateViscousEnergyLossForAllPhases(MRI_Velocity, dynamic_viscosity,interval)
% Preallocate the energy_dissipation array
energy_loss = zeros(1, 30);
for idx_phase = 1:30
% Velocity field
vel_x = MRI_Velocity{1, idx_phase}.velocity(:,1) * 1e-2; % Velocity in X from cm/s to m/s
vel_y = MRI_Velocity{1, idx_phase}.velocity(:,2) * 1e-2; % Velocity in Y in m/s
vel_z = MRI_Velocity{1, idx_phase}.velocity(:,3) * 1e-2; % Velocity in Z in m/s
% Coordinates
x = MRI_Velocity{1, idx_phase}.points(:,1) * 1e-3; % from mm to m
y = MRI_Velocity{1, idx_phase}.points(:,2) * 1e-3;
z = MRI_Velocity{1, idx_phase}.points(:,3) * 1e-3;
% Compute partial derivatives
dUdx = gradient(vel_x, x, 1);
dUdy = gradient(vel_x, y, 2);
dUdz = gradient(vel_x, z, 3);
dVdx = gradient(vel_y, x, 1);
dVdy = gradient(vel_y, y, 2);
dVdz = gradient(vel_y, z, 3);
dWdx = gradient(vel_z, x, 1);
dWdy = gradient(vel_z, y, 2);
dWdz = gradient(vel_z, z, 3);
% Calculate energy dissipation
ED = 2 * (dUdx.^2 + dUdy.^2 + dUdz.^2) + ...
2 * (dVdx.^2 + dVdy.^2 + dVdz.^2) + ...
2 * (dWdx.^2 + dWdy.^2 + dWdz.^2) + ...
(dUdz + dWdx).^2 + (dVdx + dUdy).^2 + (dWdy + dVdz).^2;
% Scale by dynamic viscosity of fluid and store
energy_loss(idx_phase) = sum(ED, 'all', 'omitnan') * dynamic_viscosity * interval.^3;
end
end
%% CODE
dynamic_viscosity_blood = 0.0039;
% human dynamic_viscosity_blood from 0.003 to 0.004; % Approximate value for blood at body temperature
% Call the function to calculate viscous energy loss for blood flow for all phases
energy_loss_RV_J = calculateViscousEnergyLossForAllPhases(MRI_Velocity_RV, dynamic_viscosity_blood,interval/1000);
energy_loss_LV_J = calculateViscousEnergyLossForAllPhases(MRI_Velocity_LV, dynamic_viscosity_blood,interval/1000);
% From Joule to milliwatt (mW)
energy_loss_RV_mW = energy_loss_RV_J.*1e3;
energy_loss_LV_mW = energy_loss_LV_J.*1e3;
figure
plot(time, energy_loss_RV_mW, 'r','LineWidth',1.5);
hold on
plot(time, energy_loss_LV_mW,'b','LineWidth',1.5);
title('Viscous energy loss over Cycle','FontSize',14);
xlabel('Cycle','FontSize',12);
ylabel('Viscous energy loss [mW]','FontSize',12);
legend('RV','LV')