pass data from DHT11 sensor using Arduino software to constant block in simulink

hello everyone . I am now working on a project that is the regulation of the temperautre and humidity with the help of the Arduino + DHT11 sensor and Simulink , I connected a script matlab in series with the Arduino software to extract values humidity and temperature to plots them in a graph. I’d like to display these values ​​in Simulik for the regulation of these values ,matlab code (exemple Temperature ):
s = serial ( ‘COM5’);

temps=1000;

i=1;

fopen(s);

while(i<temps)

fprintf(s, ‘information de communication série’);

out = fscanf(s)

Temp(i) = str2num(out(1:4));

subplot(211);

plot(Temp,‘g’);

axis([0,temps,20,50]);

title(‘DHT11 Température’);

xlabel(’—> temps (secondes)’);

ylabel(’—> Température’);

grid

And Arduino code (with LCD):

/*

The circuit:

  • LCD RS pin to digital pin 12
  • LCD Enable pin to digital pin 11
  • LCD D4 pin to digital pin 5
  • LCD D5 pin to digital pin 4
  • LCD D6 pin to digital pin 3
  • LCD D7 pin to digital pin 2
  • LCD R/W pin to ground
  • 10K resistor:
  • ends to +5V and ground
  • wiper to LCD VO pin (pin 3)

*/

// include the library code:
#include “DHT11.h”
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int pin=8;
DHT11 dht11(pin);
void setup()
{
lcd.begin(16, 2);
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
}

void loop()
{
int err;
float temp, humi;

if((err=dht11.read(humi, temp))==0)
{
//Serial.print(“temperature:”);
Serial.print(temp);
lcd.setCursor(0, 1);
lcd.print(“T:”);
lcd.print(temp);
lcd.print(“C”);

//Serial.print(" humidity:");
Serial.print(humi);
lcd.setCursor(8,1);
lcd.print(“H:”);
lcd.print(humi);
lcd.print("%");
Serial.println();
}
else
{
Serial.println();
Serial.print(“Error No :”);
lcd.print(“Error No:”);
Serial.print(err);
lcd.print(err);
Serial.println();
}
delay(DHT11_RETRY_DELAY); //delay for reread
}
Simulink model :
Please help me

The matlab code expects to read temperature data. You are confusing it sending it humidity data, too.

The code you posted, incorrectly, does something. I refuse to guess what it does.

You expect it to do something. I refuse to guess what you want it to do.

Explain these things.

(deleted)

spycatcher2k:
And this really is NOT an Arduino Question.

It belongs in Interfacing with software on the PC, not Programming, but it IS related to the Arduino.

PaulS:
It belongs in Interfacing with software on the PC, not Programming, but it IS related to the Arduino.

The Arduino is very simple. It is RS232. Lots of Serial.println( ) and Serial.print()
Not rocket science as I have written before.

Most of the issue probably lies with Simulink. Those questions belongs elsewhere.

Most of the issue probably lies with Simulink.

Most, but not all. Serial communication requires sending data that the other end expects, when it expects that.

Now that this has been moved to Interfacing with Software on the PC, we can discuss the obvious problems with the communications that involve the app on the PC.

I will agree that if the question involves ONLY the one end of the link that the question is inappropriate here.

Hello everyone
I know the question may not be 100% appropriate to be asked here. But it involves ARDUINO though.
The question is simple: How to pass data from the ARDUINO software to the simulink block in Matlab?
If someone here can help us that would be great
Thank you for your understanding

mehdi-km:
Hello everyone
I know the question may not be 100% appropriate to be asked here. But it involves ARDUINO though.
The question is simple: How to pass data from the ARDUINO software to the simulink block in Matlab?
If someone here can help us that would be great
Thank you for your understanding

I have already told you --- Serial.print() and Serial.println() is how you send from the Arduino.
We know absolutely about Simulink. That is YOUR problem!!!!!

Your problem is you know nothing about either. But that is not our problem either.

You can continue to insist that this involves the Arduino until Doomsday, but that won't get you anywhere.

I know about the Arduino serial, so to interface with C#, Java, VBA, VB6, LabVIEW, I would simply write the code for those languages.

P.S. This looks to be some sort of school project as you mentioned "we". It is not our job to do your work. period.

Instead of answering me clearly and precisely you escape the question . It's not a big deal if you say i dont know just let the adult people answring me , even if i was student or not you should answer me Mr.Sherlock holmes of course if you know the answer if not just be quite .

While ieee488 could have used a bit more tact, the answer given is correct. Only Serial.write(), Serial.print(), and Serial.println() can be used to send data from the Arduino to the PC.

The simulink software runs on the PC, so those are the only functions that can be used to send data to it.

I pointed out that you were sending it data that it does not expect. You have been extremely rude in not addressing that comment.

You have been rude in not saying what the Arduino software actually does. You have been rude in not saying what the simulink software actually does.

So, get over it.

mehdi-km:
Instead of answering me clearly and precisely you escape the question . It's not a big deal if you say i dont know just let the adult people answring me , even if i was student or not you should answer me Mr.Sherlock holmes of course if you know the answer if not just be quite .

I already told you what I do know and what I do not know.

So let me repeat it here yet again.

I do know how to send data from the Arduino and that is Serial.print() and Serial.println() which I have already written above.

I do not know anything about Simulink. And I have already written that above.

So you are incredibly obtuse.

PaulS Thank you ! It seems to me that the whole thing is a misunderstanding
I ll sum up to you
The DHT11 send to ARDUINO software from ONE PING TWO INFORMATIONS ( Temperature and Humidity) and i want your help if you know how i can acces to them separately in SIMULINK

and i want your help if you know how i can acces to them separately in SIMULINK

If I start reading off a series of numbers, that represent temperature and humidity, can YOU determine which characters represent a temperature and which represent a humidity?

Here is the stream of digits: 12.343.512.043.312.445.6

Is it possible to send the data so that it is OBVIOUS? Of course it is. So, why aren't you?

PaulS:
If I start reading off a series of numbers, that represent temperature and humidity, can YOU determine which characters represent a temperature and which represent a humidity?

Here is the stream of digits: 12.343.512.043.312.445.6

Is it possible to send the data so that it is OBVIOUS? Of course it is. So, why aren't you?

In the ARDUINO software i can read the values of temperature and humidity separately thanks to the DHT11 library. No problem here
The problem occurs to me whem i want to send them to SIMULINK
Is it somehow clearer to you now?

Is it somehow clearer to you now?

It is absolutely crystal clear to me that you do not understand that ONLY Serial.write(), Serial.print() and Serial.println() can be used. Since that is not crystal clear to you, we can not help you.

They are correct by saying that only Serial.print and Serial.println functions should be used to send data from the arduino. Those are how you send data anywhere through the USB cable.

The simulink side becomes more complicated and you are missing things. First of all there is no input block in your model to get data externally.

The only way to do it is use the real time toolbox and set that up to run at the same baud rate as the arduino. Once you have data streaming in you need to receive it, parse it, and display it.

Tutorials on serial communication basics will be your best friends.