the first time i did like the video, i have successed, but now i have some problem with led, if i connect the led with the resistor, it don't turn on, but when i connect with 3.3v, the led turn on but not right as the code and thank you so much with your video i already can add a lcd which display the temperature and humidity
It is all same except you need to change the timer Prescalor according to clock speed. Prescalor should be one less than timer clock speed. I don't have STM32F401 with me to demonstrate. Thanks
Hi Joseph, The pin need to be output first and then input. Micro-controller needs to send some messages to the sensor asking for temperature, then the sensor will respond with the answer (that is temperature and humidity). Pin type change from output to input and then input to output will be handled by the code. If you inspect the code GPIO_InitStructPrivate.Mode = GPIO_MODE_OUTPUT_PP; HAL_GPIO_Init(DHT11_PORT, &GPIO_InitStructPrivate); // set the pin as output GPIO_InitStructPrivate.Mode = GPIO_MODE_INPUT; HAL_GPIO_Init(DHT11_PORT, &GPIO_InitStructPrivate); // set the pin as input
@@NizarMohideen Sir also I'd like to request for some help integrating the dht sensor with 1602 lcd display and the stm32f103c8t6. Thank you once again.
Hi, I've sent the pulse signal to the data pin. After that I've set the data pin as input. And wait for the pin to go low. But its never going low. i.e. it never satisfies: if (!(HAL_GPIO_ReadPin (DHT11_PORT, DHT11_PIN))) condition. So, response is not 1. Now I'm stuck in a forever loop. Can you help me?
Hi Nafiur Rahman, There are no forever loop in the code. Any while loops I used, I put timeout of 2ms using HAL_GetTick(). if (!(HAL_GPIO_ReadPin (DHT11_PORT, DHT11_PIN))) is not a loop. It just checks and goes inside and makes Response = 1 if the condition satisfies. Otherwise Response = 0 remains. Now we come to the starting of DHT11, the pulse timing is important. You need to keep the pin low for at least 18 milliseconds. Then keep the pin high for about 30 micro seconds. Then make the pin as input. It should become low If it doesn’t become low at this point, check wiring connection and power supply. Please note the timings. One of them is milliseconds and others are micro-seconds.
sorry sir, but if i want to see the value of data which be delivered by DHT11 to STM how can i see that? many channel use keil uvision, but i am using ide like u so i don't know how to see them
You can use live expression to see the values as shown in this video Or you can see in oled display as shown in th-cam.com/video/rIqM63S9eUQ/w-d-xo.html
@@NizarMohideen thanks for replying sir, but i meet a error like "Could not verify ST device! Abort connection" , i can apply code into stm32 by using stlink with file.hex but can not debug directly :( i am trying to fix, hope i can debug :(
hi sir im using STM32 f303RE and when I finish apply system software reset in the debugger it asks.. "confirm perspective switch" should I press switch to no
OpenOCD and system software reset is for generic STM32F103C8T6. If you are using nucleo, you can use GDB server as I have shown in my video-no-50 Thanks
I used Click Clock Configuration tab → HCLK (MHz) to 72 Configuration → Parameter Settings → Prescaler set to 71 If your clock frequency is different set prescalor to one less. For example. If your Click Clock Configuration tab → HCLK (MHz) to 180 Configuration → Parameter Settings → Prescaler set to 179
It is normal to go to while (__HAL_TIM_GET_COUNTER(&htim1) < delay); during debug pause. Define correct pin and port #define DHT11_PORT #define DHT11_PIN Check for wiring connections before trying again.
Hello sir I made circuit on proteus about interfacing dht11 temperature and humidity sensor with STM32F103C6 microcontroller, but for creating hex file it's show error on stm32ide So sir can you please create code for proteus circuit
Hi Sahil, To be honest, I am not familiar with proteus. I give you the steps. You can try Set the pin to output Set the pin to low Wait 20000 micro seconds Set the pin to high Wait 30 micro seconds Set the pin to input Wait 40 micro seconds If the pin is now low and after 80 micro seconds if the pin is high, sensor responded Wait for the pin to go low Now in loop (40 iterations) Wait for the pin to go high Wait 40 micro seconds bit(i) = pin value Wait for the pin to go low Do above 4 steps 40 times First 8 bits will have Relative humidity integral (A) Next 8 bits will have Relative humidity decimal (B) Next 8 bits will have Celsius integral (C) Next 8 bits will have Celsius decimal (D) Next 8 bits will have Check sum (E) If A+B+C+D=E, all good Regards,
You need ST-LINK V2 as I have shown in video th-cam.com/video/kXg467nVd_A/w-d-xo.html In that video, I have installed the driver when I installed the STM32CubeIDE Make sure the USB port for the ST-LINK is working. You may try another port
You need a DHT11 Sensor (Of course) You need a STM32F103C8T6 Blue-Pill You need a ST-LINK programmer. I have shown in video th-cam.com/video/kXg467nVd_A/w-d-xo.html how to connect st-link to the board and installing CubeIDE. Let me know if you have more questions
LCD are below. You can combine with dht11 th-cam.com/video/l-JVnlJIPao/w-d-xo.html th-cam.com/video/9F2gTb3n_p0/w-d-xo.html or I have combined with oled is below th-cam.com/video/rIqM63S9eUQ/w-d-xo.html
in the live expressions, after resume(F8) it is showing as target not available
Sir, when i run this lcd print just 0.00 C and 0.00 % . İt cant read dht11 could you please help me
Very good video!
who to display temp sensor output in lcd 16*2 display
the first time i did like the video, i have successed, but now i have some problem with led, if i connect the led with the resistor, it don't turn on, but when i connect with 3.3v, the led turn on but not right as the code
and thank you so much with your video i already can add a lcd which display the temperature and humidity
oh anyway i found the reason, i reverse installation the led, now i can run it properly. Thank you so much i love your video!
How i can run this on Nucleo-64 Board (STM32F401)
It is all same except you need to change the timer Prescalor according to clock speed. Prescalor should be one less than timer clock speed. I don't have STM32F401 with me to demonstrate. Thanks
Sir, the PB9 that is connected to the sensor, is it supposed to be output or input? In the video you configured as output.
Hi Joseph,
The pin need to be output first and then input.
Micro-controller needs to send some messages to the sensor asking for temperature, then the sensor will respond with the answer (that is temperature and humidity).
Pin type change from output to input and then input to output will be handled by the code.
If you inspect the code
GPIO_InitStructPrivate.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_Init(DHT11_PORT, &GPIO_InitStructPrivate); // set the pin as output
GPIO_InitStructPrivate.Mode = GPIO_MODE_INPUT;
HAL_GPIO_Init(DHT11_PORT, &GPIO_InitStructPrivate); // set the pin as input
@@NizarMohideen Thank you so much for your explanation. I have now understood.
@@NizarMohideen Sir also I'd like to request for some help integrating the dht sensor with 1602 lcd display and the stm32f103c8t6.
Thank you once again.
@@wangere7697 Hi I am asking the same thing, do you have the guidance steps? Thanks
@@clairejhwang2313 Hi which steps would you like please?
Hi, I've sent the pulse signal to the data pin. After that I've set the data pin as input. And wait for the pin to go low. But its never going low. i.e. it never satisfies: if (!(HAL_GPIO_ReadPin (DHT11_PORT, DHT11_PIN))) condition. So, response is not 1. Now I'm stuck in a forever loop. Can you help me?
Hi Nafiur Rahman,
There are no forever loop in the code. Any while loops I used, I put timeout of 2ms using HAL_GetTick(). if (!(HAL_GPIO_ReadPin (DHT11_PORT, DHT11_PIN))) is not a loop. It just checks and goes inside and makes Response = 1 if the condition satisfies. Otherwise Response = 0 remains.
Now we come to the starting of DHT11, the pulse timing is important.
You need to keep the pin low for at least 18 milliseconds.
Then keep the pin high for about 30 micro seconds.
Then make the pin as input. It should become low
If it doesn’t become low at this point, check wiring connection and power supply.
Please note the timings. One of them is milliseconds and others are micro-seconds.
Sir , are you using the FTDI to debug the program on stm32f103?
I am using a “ST Link” as shown in video-no11 in my channel. Thanks
Hi sir
Dht11 is always gonna send 1 whatever I do . Our codes are not completely same but similar
sorry sir, but if i want to see the value of data which be delivered by DHT11 to STM how can i see that? many channel use keil uvision, but i am using ide like u so i don't know how to see them
You can use live expression to see the values as shown in this video
Or you can see in oled display as shown in th-cam.com/video/rIqM63S9eUQ/w-d-xo.html
@@NizarMohideen thanks for replying sir, but i meet a error like "Could not verify ST device! Abort connection" , i can apply code into stm32 by using stlink with file.hex but can not debug directly :( i am trying to fix, hope i can debug :(
You can print messages/values to terminal via UART or USB
You can print values to terminal via USB
Details in this video th-cam.com/video/iYvUzxABmTk/w-d-xo.html
@@NizarMohideen thank you very much sir, i ll check this
hi sir im using STM32 f303RE and when I finish apply system software reset in the debugger it asks.. "confirm perspective switch" should I press switch to no
OpenOCD and system software reset is for generic STM32F103C8T6.
If you are using nucleo, you can use GDB server as I have shown in my video-no-50
Thanks
@@NizarMohideen sir i have tried as u said but still no reading from my DHT11
I used
Click Clock Configuration tab → HCLK (MHz) to 72
Configuration → Parameter Settings → Prescaler set to 71
If your clock frequency is different set prescalor to one less.
For example. If your
Click Clock Configuration tab → HCLK (MHz) to 180
Configuration → Parameter Settings → Prescaler set to 179
@@NizarMohideen yes i have also tried this and when I pause it keep coming back to while (__HAL_TIM_GET_COUNTER(&htim1) < delay);
It is normal to go to while (__HAL_TIM_GET_COUNTER(&htim1) < delay); during debug pause.
Define correct pin and port
#define DHT11_PORT
#define DHT11_PIN
Check for wiring connections before trying again.
thank you
hello friend what kind of connection is between mcu and sensor, pwm or is there a communication like uart
It uses simple input and output using one pin only. Micro-controller programmed to change GPIO INPUT and OUTPUT
Hello sir
I made circuit on proteus about interfacing dht11 temperature and humidity sensor with STM32F103C6 microcontroller, but for creating hex file it's show error on stm32ide
So sir can you please create code for proteus circuit
Can you provide your mail id
I'll send my circuit to you
Hi Sahil,
To be honest, I am not familiar with proteus. I give you the steps. You can try
Set the pin to output
Set the pin to low
Wait 20000 micro seconds
Set the pin to high
Wait 30 micro seconds
Set the pin to input
Wait 40 micro seconds
If the pin is now low and after 80 micro seconds if the pin is high, sensor responded
Wait for the pin to go low
Now in loop (40 iterations)
Wait for the pin to go high
Wait 40 micro seconds
bit(i) = pin value
Wait for the pin to go low
Do above 4 steps 40 times
First 8 bits will have Relative humidity integral (A)
Next 8 bits will have Relative humidity decimal (B)
Next 8 bits will have Celsius integral (C)
Next 8 bits will have Celsius decimal (D)
Next 8 bits will have Check sum (E)
If A+B+C+D=E, all good
Regards,
www.mouser.com/datasheet/2/758/DHT11-Technical-Data-Sheet-Translated-Version-1143054.pdf
what is pmillis?
i get an error saying no stlink detected when i try to debug what do i do
You need ST-LINK V2 as I have shown in video th-cam.com/video/kXg467nVd_A/w-d-xo.html
In that video, I have installed the driver when I installed the STM32CubeIDE
Make sure the USB port for the ST-LINK is working. You may try another port
@@NizarMohideen i want to use i2c in my project too how can i add it
I have i2c oled - th-cam.com/video/rIqM63S9eUQ/w-d-xo.html
If you need i2c lcd use - th-cam.com/video/l-JVnlJIPao/w-d-xo.html
not work for me ?
Do we need a programmer for this?
I've ordered STM32F103C8 board worth 600, so do I need an external programmer for it?
You need a DHT11 Sensor (Of course)
You need a STM32F103C8T6 Blue-Pill
You need a ST-LINK programmer.
I have shown in video th-cam.com/video/kXg467nVd_A/w-d-xo.html how to connect st-link to the board and installing CubeIDE. Let me know if you have more questions
@@NizarMohideen how did you upload the code here. I can't see ST link here. Did you upload the code with micro usb cable ?
you can it with LCD !!
LCD are below. You can combine with dht11
th-cam.com/video/l-JVnlJIPao/w-d-xo.html
th-cam.com/video/9F2gTb3n_p0/w-d-xo.html
or I have combined with oled is below
th-cam.com/video/rIqM63S9eUQ/w-d-xo.html