DHT11 arduino and app designer

16 views (last 30 days)
Saad Oussaada
Saad Oussaada on 8 Mar 2020
Answered: Aravind on 16 May 2025
I took those instructions from DHT11 bloc simulink and it doesn't work on app designer
should I include library of dht or what
could anyone help me please
ps : I am not a good programmer
a = arduino('com8','uno');
while true
coder.cinclude('dht_arduino.h');
coder.ceval('setDHT', uint8(obj.Pin), uint8(obj.Sensor));
H = coder.ceval('readHumidity');
T = coder.ceval('readTemp');
app.tempEditField.Value = T;
app.humiEditField.Value = H;
pause(0.5);
end
  3 Comments
Saad Oussaada
Saad Oussaada on 9 Mar 2020
Could you help me please write a code that can read dht11 temp and humidity data and print it in EditField on app designer ?
Walter Roberson
Walter Roberson on 9 Mar 2020
https://circuitdigest.com/microcontroller-projects/matlab-data-logging-analysis-and-visualization-plotting-dht11-sensor-readings-on-matlab

Sign in to comment.

Answers (1)

Aravind
Aravind on 16 May 2025
If you want to read data from a DHT11 temperature and humidity sensor using MATLAB and Simulink, there are a couple of approaches you can consider, depending on your workflow and requirements.
Using the IO Device Builder with Simulink:
The recommended approach in Simulink is to use the "IO Device Builder" app, which is part of the Simulink Support Package for Arduino. This tool allows you to integrate custom Arduino C++ libraries (such as those used for the DHT11 sensor) and create a custom block that can be used directly in your Simulink models. You can deploy your Simulink model to the Arduino hardware, which will handle reading the sensor data during simulation. Data logged from Simulink can then be imported into the MATLAB workspace for further analysis or visualization. Once in the MATLAB workspace, you can display the data in an EditField in the MATLAB App Designer. Here are some useful resources:
Directly from MATLAB using Serial Communication:
Alternatively, you can read data from the DHT11 sensor directly in MATLAB by uploading an Arduino sketch that reads the sensor values and sends them over the serial port. In MATLAB (including App Designer), you can use the "serialport" function to receive and parse this data in real time. This approach requires two scripts: one in C++ to upload to the Arduino (reading the temperature and humidity from the DHT11 sensor and printing the values to the serial port), and one MATLAB script that creates a serial port object and reads the values sent from the Arduino. You can then display this data in an EditField in your app. Here are some relevant resources:
I hope this answers your question. The best approach depends on your specific workflow and needs. If you provide more details about your use case, I can offer more targeted advice.

Categories

Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!