- Download the DHT-sensor-library drivers for the sensor from the GitHub.
 - Download the dependent files Adafruit Unified Sensor from the GitHub.
 - Ensure to install the Simulink support package for arduino hardware.
 
Trying to build a DHT11 block and keep getting this error in Simulink
    9 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
Im trying to build this block but I get this error that I will provide below. I have followed exactly the steps from the matlab tutorials, so I have no idea what is the problem. Please if anyone knows I would appreciate the help.
C:/Users/user/DOCUME~1/MATLAB/R2024b/ArduinoStaticLibrary/ArduinoUno/FasterRuns/MW_RebuildSrc_Core.o  -lm -lcomm -lcore DHT11_DDAppGeneratedModel.o: In function `DHT11_DDAppGeneratedModel_step': DHT11_DDAppGeneratedModel.c:(.text.DHT11_DDAppGeneratedModel_step+0xc0): undefined reference to `stepFunctionDHT11' DHT11_DDAppGeneratedModel.o: In function `DHT11_DDAppGeneratedModel_initialize': DHT11_DDAppGeneratedModel.c:(.text.DHT11_DDAppGeneratedModel_initialize+0x5c): undefined reference to `setupFunctionDHT11' collect2.exe: error: ld returned 1 exit status gmake[1]: *** [../DHT11_DDAppGeneratedModel.elf] Error 1 gmake[1]: Leaving directory `C:/Users/user/Desktop/DHT11/DHT11_DDAppGeneratedModel_ert_rtw' gmake: *** [all] Error 2 C:\Users\user\Desktop\DHT11\DHT11_DDAppGeneratedModel_ert_rtw>echo The make command returned an error of 2 The make command returned an error of 2 C:\Users\user\Desktop\DHT11\DHT11_DDAppGeneratedModel_ert_rtw>exit /B 1 ### Build procedure for DHT11_DDAppGeneratedModel aborted due to an error. 
Build Summary
Top model targets: Model                      Build Reason                                         Status                                                 Build Duration ===================================================================================================================================================== DHT11_DDAppGeneratedModel  Information cache folder or artifacts were missing.  Failed to build. For more information, see build log.  0d             0 of 1 models built (0 models already up to date) Build duration: 0h 0m 29.469s
Component:Simulink | Category:Block diagram error
And my code is as follows:
#include "C:\Users\user\Desktop\DHT11\DHT11.h"
#include "Adafruit_Sensor.h"
#include "DHT.h"
#include "DHT_U.h"
#include "Arduino.h"
#define DHTPIN 10
#define DHTTYPE    DHT11
DHT_Unified dht(DHTPIN, DHTTYPE);
uint32_t delayMS;
void setupFunctiondht11Sensor(uint32_T * dataDelay,int size_vector__1){
    Serial.begin(9600);
    dht.begin();
    delayMS = dataDelay;
}
void stepFunctiondht11Sensor(float * Humidity,int size_vector_1,float * Temperature,int size_vector_2){
    delay(delayMS);
    sensors_event_t event;
    dht.temperature().getEvent(&event);
    if (isnan(event.temperature)) {
    }
    else {
        *Temperature=event.temperature;
    }
    dht.humidity().getEvent(&event);
    if (isnan(event.relative_humidity)) {
    }
    else {
        *Humidity=event.relative_humidity;
    }
} 
0 Commenti
Risposte (2)
  Divyanshu
      
 il 17 Dic 2024
        A possible reason for getting error 'undefined reference to stepfunctionDHT11' during the build can be missing pre-requisite drivers, files or packages.
As mentioned in the above example documentation link, the prerequisites for the example are:
Hope this helps!
  Mohamadmahdi
 il 13 Set 2025
        I followed all of the above steps, but the error has not been resolved.
0 Commenti
Vedere anche
Categorie
				Scopri di più su Arduino Hardware in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!