Main Content

Results for

Hello everyone,
I am currently working on a project to simulate an autonomous energy production plant integrating renewable sources and a hydroelectric generator using MATLAB.
If anyone has experience in this area or can provide advice I would be extremely grateful. Thank you in advance for your precious help !
Hello, I am using an Arduino UNO R3 with an ESP8266 WiFi Shield to connect 2 DHT-11 sensors to upload their data to ThingSpeak. Sometimes ThingSpeak would only post data on a certain sensor for a bit and then upload to the other randomly. I want ThingSpeak to pick up the sensors within 30-40 seconds of each other consistently. I believe there might be something wrong with my code. I was hoping to get some help on it. Anything is appreciated.
Below is provided code
SoftwareSerial esp8266(RX,TX);
void setup() {
Serial.begin(9600);
esp8266.begin(38400);
sendCommand("AT",5,"OK");
sendCommand("AT+CWMODE=1",5,"OK");
sendCommand("AT+CWJAP=\""+ AP +"\",\""+ PASS +"\"",20,"OK");
}
void loop() {
String getData = "GET /update?api_key="+ API +"&field1="+getTemperatureValue()+"&field2="+getHumidityValue();
sendCommand("AT+CIPMUX=1",5,"OK");
sendCommand("AT+CIPSTART=0,\"TCP\",\""+ HOST +"\","+ PORT,15,"OK");
sendCommand("AT+CIPSEND=0," +String(getData.length()+4),4,">");
esp8266.println(getData);delay(6000);countTrueCommand++;
String getData2 = "GET /update?api_key="+ API +"&field3="+getTemperatureValue2()+"&field4="+getHumidityValue2();
sendCommand("AT+CIPMUX=1",5,"OK");
sendCommand("AT+CIPSTART=0,\"TCP\",\""+ HOST +"\","+ PORT,15,"OK");
sendCommand("AT+CIPSEND=0," +String(getData2.length()+4),4,">");
esp8266.println(getData2);delay(6000);countTrueCommand++;
sendCommand("AT+CIPCLOSE=0",5,"OK");
}
String getTemperatureValue(){
dhtObject.read(dht_apin);
Serial.print(" Temperature(C)= ");
int temp = dhtObject.temperature;
Serial.println(temp);
delay(50);
return String(temp);
}
String getHumidityValue(){
dhtObject.read(dht_apin);
Serial.print(" Humidity in %= ");
int humidity = dhtObject.humidity;
Serial.println(humidity);
delay(50);
return String(humidity);
}
String getTemperatureValue2(){
dhtObject2.read(dht_bpin);
Serial.print(" Temperature(C)= ");
int temp2 = dhtObject2.temperature;
Serial.println(temp2);
delay(50);
return String(temp2);
}
String getHumidityValue2(){
dhtObject2.read(dht_bpin);
Serial.print(" Humidity in %= ");
int humidity2 = dhtObject2.humidity;
Serial.println(humidity2);
delay(50);
return String(humidity2);
}
void sendCommand(String command, int maxTime, char readReplay[]) {
Serial.print(countTrueCommand);
Serial.print(". at command => ");
Serial.print(command);
Serial.print(" ");
while(countTimeCommand < (maxTime*1))
{
esp8266.println(command);//at+cipsend
if(esp8266.find(readReplay))//ok
{
found = true;
break;
}
countTimeCommand++;
}
if(found == true)
{
Serial.println("Pass");
countTrueCommand++;
countTimeCommand = 0;
}
if(found == false)
{
Serial.println("Fail");
countTrueCommand = 0;
countTimeCommand = 0;
}
found = false;
}
Sarati
Sarati
Last activity on 29 Feb 2024

Due to temporary problem MathWorks account was unable to login. Kindly resolve this issue.

KAVYA
KAVYA
Last activity on 29 Feb 2024

how to generate CA signed certificate for mqtt
I asked my question in the general forum and a few minutes later it was deleted. Perhaps this is a better place?
Rather than using my German regional forum (as I do not speak German), I want to ask questions in an international English-speaking forum. Presumably there should be an international English forum for everyone around the world, as English is the first or second language of everyone who has gone to school. Where is it?
When I embed Matlab windows into C#, I use C# to call the mouse functions such as drawline() and getpts() which are encapsulated in Matlab's dll, and then the program crashes, how can I solve this problem?
ps : The functions that I call in C# can be executed in Matlab.
ps : If I don't embed the window into C#, but just let C# call the Matlab function, it can execute the mouse control normally in the window, but once embedded into the C# window, it will crash when execute the mouse command.
I have a channel updating every 10 minutes. The last 8000 entries therefore go back to late December (around 55 days). I want to extend the range of data downloaded by setting a timescale between results, so say if I request a timescale of 20 minutes should I not be able to get data from twice as long ago? e.g.
https://api.thingspeak.com/channels/xxxxxx/fields/1.json?api_key=XXXXXXXXXXX&timescale=20&start=2022-12-30%2022:00:00
No matter what timescale or averaging I use, the last 8000 entries are the only ones processed for the downloaded data, so I just get fewer results. Unless I use a timescale of 1440; then I can download results from the very first entry in 2022. A timescale of 720 or lower however will only go back 55 days.
So I see the desired result when I use a timescale of 1440, but no other timescale will work. Is this a bug?
New to ThingsSpeak. I have a Photon 2 and vreated a webhook with simple code to send random numbers reprsented as 'temp' to a channel in ThingSpeak. All good with the code and my device shows the webhook is sending data and the events corespond to the same number of entries received in my channel. However, I do not see any visual graph of the data. What am i missing?
Hi Everyone. I am facing a problem while connecting the FMU to the buses. I have one FMU which expects 9 inputs and I did clarify the same while using bus creator. But in the end i am getting this error which i am trying to solve for couple of hours but didn't get any solution. So if any knows about the same please help me. I would give details as well if you need any other information.
Komal Memon
Komal Memon
Last activity on 15 Feb 2024

Hello Im tring to connect my master node to thingspeak but it gives error like:
Data received from slave - Temperature: 25.90, Humidity: 46.00, Soil Moisture: 0, pH: 4.26
Failed to send data to ThingSpeak, status code: -301
Data received from slave - Temperature: 25.90, Humidity: 46.00, Soil Moisture: 0, pH: 4.26
Failed to send data to ThingSpeak, status code: -301
What should I do?
Chen Lin
Chen Lin
Last activity on 14 Feb 2024

See code here in our community contest area. (author: @Zhaoxu Liu / slandarer)
And what do you do for Valentine's Day?
I need to copy Channel field data from a specific data range (e.g. January 2024) from field 6 of channel A(see sample attached) to field 1 of channel B.
I have tried to adopt the Template "Get data from private channel" in the Matlab analysis area of Thingspeak. The last data can be copied according the sample, but I cannot manage to copy the complete datarange. My channel field contains half empty data in field 6, because I have posted data asynchrously from 2 devices to 1 channel up to now.
Any advice for proper Matlab code sample or the like is welcome!
K
K
Last activity on 10 Feb 2024

which technical support should I contact/ask for the published Simscape example?
Is anyone having issues downloading the entire data from a channel? I usually include this line to the url but it no longer works: /feed.csv?days=1000000. Any suggestions on a way forward?
Hannah
Hannah
Last activity on 8 Feb 2024

I was looking into the possibility of making a spin-to-win prize wheel in MATLAB. I was looking around, and if someone has made one before they haven't shared. A labeled colored spinning wheel, that would slow down and stop (or I would take just stopping) at a random spot each time. I would love any tips or links to helpful resources!
Greetings to all MATLAB users,
Although the MATLAB Flipbook contest has concluded, the pursuit of ‘learning while having fun’ continues. I would like to take this opportunity to highlight some recent insightful technical articles from a standout contest participant – Zhaoxu Liu / slandarer.
Zhaoxu has contributed eight informative articles to both the Tips & Tricks and Fun channels in our new Discussions area. His articles offer practical advice on topics such as customizing legends, constructing chord charts, and adding color to axes. Additionally, he has shared engaging content, like using MATLAB to create an interactive dragon that follows your mouse cursor, a nod to the upcoming Year of the Dragon in 2024!
I invite you to explore these articles for both enjoyment and education, and I hope you'll find new techniques to incorporate into your work.
Our community is full of individuals skilled in MATLAB, and we're always eager to learn from one another. Who would you like to see featured next? Or perhaps you have some tips & tricks of your own to contribute. Remember, sharing knowledge is a collaborative effort, as Confucius wisely stated, 'When I walk along with two others, they may serve me as my teachers.'
Let's maintain our commitment to a continuous learning journey. This could be the perfect warm-up for the upcoming 2024 contest.
Many of the examples in the MATLAB documentation are extremely high quality articles, often worthy of attention in their own right. Time to start celebrating them! Today's is how to increase Image Resolution using deep learning
Struct is an easy way to combine different types of variants. But now MATLAB supports classes well, and I think class is always a better alternative than struct. I can't find a single scenario that struct is necessary. There are many shortcomings using structs in a project, e.g. uncontrollable field names, unexamined values, etc. What's your opinion?
Umar Khan
Umar Khan
Last activity on 22 Feb 2024

I am confused, is the matlab answer better or Julia’s?