DHT11 || DHT22 || DS18B20 with STM32 using TIMER Delay

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 287

  • @ControllersTech
    @ControllersTech  4 года назад +18

    Those who are having problems with the temperature value, here are few things you should do to diagnose
    1. In the set_gpio_input() function, try using GPIO_PULLUP instead of NOPULL.
    2. Check the microsecond delay. This is the most vital part and 90% chances are that you have problem here. You can blink some LED every 1 second using us delay.
    Try the below code
    HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_1);
    for (int i=0; i

    • @kacemberriah5637
      @kacemberriah5637 4 года назад

      what external source shoold we use could you tell us please ?

    • @brendanrichart4804
      @brendanrichart4804 3 года назад +2

      What an excellent response, I'm wish I saw this earlier, you do a great job!!

    • @westonturner3987
      @westonturner3987 3 года назад

      instablaster...

    • @emceeyoungking9220
      @emceeyoungking9220 3 месяца назад

      HOW DO I CONFIGURE LM016L LCD SCREEN IF IM USING PROTEUS TO RUN THE SIMULATION

  • @АльбинаКалабанова
    @АльбинаКалабанова 3 года назад +1

    I have repeated your code with DHT11. At the first time it did not work at all, only DHT11_Start () function did properly and i could clearly see the response from sensor with help of osciloscope. Actually i had to extend HAL_Delay(1000) after all readings up to 1200 ms and it started working continuosly . Thank you so much for helping.

  • @Ngigi
    @Ngigi 2 года назад +1

    I followed with DHT11 and STM32F103C8T6.
    After a few trials and reading the comments, it works perfectly!

  • @mateaguero
    @mateaguero 4 года назад +10

    Hola, espero lo entiendan en español.
    El problema de que no arranque el DHT11 es por el comienzo de la señal enviada por el MCU.
    El sensor espera una señal en alto y luego los 18 mS en bajo. Se ve claramente en los diagramas del datasheet.
    Lo solucioné agregando unas líneas en el código de DHT11_Start de la siguiente manera:
    void DHT11_Start (void)
    {
    Set_Pin_Output(DHT11_PORT, DHT11_PIN);
    HAL_GPIO_WritePin(DHT11_PORT, DHT11_PIN, 1);
    /* Nivel de comienzo de comunicación */
    delay(1000);
    HAL_GPIO_WritePin(DHT11_PORT, DHT11_PIN, 0);
    delay (18000);
    HAL_GPIO_WritePin(DHT11_PORT, DHT11_PIN, 1);
    delay(20);
    Set_Pin_Input(DHT11_PORT, DHT11_PIN);
    }
    Espero les sirva. Muy bueno el posteo y gracias, me fue de muchísima ayuda.

    • @truongpham7279
      @truongpham7279 4 года назад +1

      Yes! Actually the problem is there for me. Thanks for sharing both of you Controllers Tech and
      mateaguero

    • @Ngigi
      @Ngigi 2 года назад

      @@truongpham7279 Thank you so much!!!

  • @radoslav7814
    @radoslav7814 2 года назад +3

    Sensor response doesn't work at all for me, doesnt matter if you connect data pin or not, program never enters if statement in DTH11_Response, and at the end of function the code is stuck on this while loop if you dont connect the data pin I dont know what I'm doinf wrong.

  • @ServiciosydesarrolloCO
    @ServiciosydesarrolloCO 6 месяцев назад +2

    Hi sir! Could you consider making a video using these sensors without stopping the machine? I mean, it has a lot of delay that will affect the operation of the most sensitive systems. It would be interesting if you combined it with Rtos. Greetings, I've been following you for years!

    • @ControllersTech
      @ControllersTech  6 месяцев назад +1

      You need to give delay even if you use freeRTOS. The sensor won't work if ypu try to read faster.
      Try considering some other sensor if you need faster readings.

  • @dighuyntran1351
    @dighuyntran1351 3 года назад +3

    i tried a pull up resistor (around 4.7K) and giving power from an external source, it works perfectly

  • @huythaiquang9682
    @huythaiquang9682 5 месяцев назад +1

    1st The program goes to the response waiting function if (!(HAL_GPIO_ReadPin (DHT_PORT, DHT_PIN))) then it skips because at this time GPIOA_PIN_1 is SET and it runs to the while function while((HAL_GPIO_ReadPin (DHT_PORT, DHT_PIN))); // wait for the pin to go low
    and it's stuck in this loop because GPIO_PIN_1 is still SET without RESET. Even though in theory it should be low. I don't understand why it works like that but when I try to unplug the power to put the GPIO pin down low level and plug the power back in, the program works normally. It only crashes the first time the code is loaded. Do you know why?🙂🙂🙂

  • @kpcgkhn
    @kpcgkhn 4 года назад +1

    it ran on me, but need to start timer6 with "HAL_TIM_Base_Start(&htim6);" and need pull up resistor. two sides of setup have open drain or not. i used 3.3k resistor for 3.3volt setup and ds18b20 worked 3.3v.

  • @artsrunmargaryan2920
    @artsrunmargaryan2920 3 года назад +1

    Thanks for video, but I think I need to add timeouts everywhere to not stuck somewhere in loop.

  • @cosmin751
    @cosmin751 3 года назад

    Thank you! Everything works great on a Nucleo32-L432KC w/o any pullup resistor and with the DHT22 powered directly from Nucleo's 3.3V VCC pin. Great explanations! Subbed! :D

    • @gisselrosariveranavarro84
      @gisselrosariveranavarro84 Год назад

      Hello, I am using the same nucleo, but my values remain at 0, could you guide me how you achieved it please?

    • @hi3u164
      @hi3u164 3 месяца назад

      @@gisselrosariveranavarro84 did u find a solution?

  • @atakan8200
    @atakan8200 11 месяцев назад

    If u are gonna make the clock frequency 100 MHz, the DS18B20 is working correctly. The 100MHz is required for creating nanoseconds delay and please dont forget to add 4.7 K (pull up) resister to data pin.

  • @ruialmeida2605
    @ruialmeida2605 Год назад

    does the delays have to be super precise? to test it out, i tried a 10 microsecond delay with a toggle pin and i get a pwm with 51.5 kHz frequency. Sometimes for highest delay like, 200 us, i get 2.488 khz.

  • @amintayebi
    @amintayebi 3 года назад

    Thanks for the helpful video. I had the problem of receiving the correct temperature in the L476RG-stm32 board. But I solved it by setting "80-1" instead of "50-1" in the prescaler in the TIMER stetting of the board scheme.

    • @katiaihaddadene7457
      @katiaihaddadene7457 2 года назад

      It worked ? You got the temperature values please .? I have stm32l476RG to but it doesn t work

    • @amintayebi
      @amintayebi 2 года назад

      @@katiaihaddadene7457 Hi good evening, yes I put it in my channel too : ruclips.net/channel/UCZpfJjgR5zA-XrB26IhOzkA

    • @amintayebi
      @amintayebi 2 года назад +1

      @@katiaihaddadene7457 Hi thanks for your watching and comment, yes it worked, afte you programmed the board, reset the board by pushing reset bottom or disconnect power once.

    • @katiaihaddadene7457
      @katiaihaddadene7457 2 года назад

      @@amintayebi thanks for replying , i did it but i have 0 temperature

    • @amintayebi
      @amintayebi 2 года назад

      @@katiaihaddadene7457 you have to play with the parameters, PULL DOWN,.. or prescaler, reset several times then it will work.

  • @vandal1176
    @vandal1176 2 года назад +2

    I had a problem, but I fixed it. I was using 8 MHz HCLK, but once I increased it to 48 MHz (plus increased prescaler on timer) everything started working fine

    • @anirudhpattar5374
      @anirudhpattar5374 Год назад

      @vandal sir,
      Which sensor are you using?

    • @vandal1176
      @vandal1176 Год назад

      @@anirudhpattar5374 I think I was using DS18B20 with STM32F0DISCOVERY board

  • @superduper8993
    @superduper8993 4 года назад +1

    thanks for the tutorial, however I cant get the DS18B20 working, I get the presence pulse, I check the data line with my scope, timing looks right, I tried all your alternative solution, the only is issue I can see is the transition from output to input is about 17us so when writing a "1" im a bit over the 15us limit, could you confirm that on your end ? thanks

    • @ControllersTech
      @ControllersTech  4 года назад +1

      Increase the sysclock. Make it highest possible

    • @superduper8993
      @superduper8993 4 года назад +1

      @@ControllersTech yap that worked, thanks

  • @bimower8019
    @bimower8019 4 года назад +1

    Hay, this is a very interesting video. thank's for the detailed explanation.
    Can u show me how to access ds18b20 in parasitic mode.
    Thank You

  • @nafiurrahman1504
    @nafiurrahman1504 3 года назад +2

    I'm getting stuck in the infinite loop.. I've checked the timer delay, the pull up resistor. But still the same response. Do you have a solution for that?

    • @nafiurrahman1504
      @nafiurrahman1504 3 года назад +3

      *UPDATE*
      I've connected an external power source after reading the comments. Now I'm out of the infinity loop. But the value of my response variable is -1 or 255. Still suffering with the sensor. Would appreciate if anyone helps.

    • @hi3u164
      @hi3u164 3 месяца назад

      @@nafiurrahman1504 did u find a solution?

  • @xenonyoutub
    @xenonyoutub 3 года назад +2

    Code doesn't work with DS18B20; using STM32F103C8T6 (Bluepill)

  • @onurkulekci4291
    @onurkulekci4291 3 года назад +1

    Why the program does not work when i use extra delay or delay included functions? example lcd_init(). because lcd_init include extra HAL_delay(). how can i solve it?

    • @ControllersTech
      @ControllersTech  3 года назад +1

      Where are u putting the LCD init ?
      Regarding the hal delay, you should test the led blinking if you have doubt about that

  • @paulinaacosta4989
    @paulinaacosta4989 3 года назад

    What would be the prescaler and counter period for STM32F3030k8 tim 6 configuration? With the ioc configuration you suggested its counting 10 seconds in 60 seconds.

    • @ControllersTech
      @ControllersTech  3 года назад

      It's not some fixed value.
      It changes based on the clock setup, timer connection, input frequency etc.
      Watch that delay video to understand it.

  • @untraditional6235
    @untraditional6235 Год назад +2

    Do i necessary must have an lcd to view the results?

  • @groupeB-ul3pe
    @groupeB-ul3pe Год назад

    i'm trying to configure my sensor but not with the library HAL but i have some problem to configure my pin to LOW, HIGHT and READ mode, how can i do?

  • @aovanhieu3319
    @aovanhieu3319 2 года назад

    I want to display temperature by 7 segment. what should i do on this code?
    Temp_byte1 = DS18B20_Read();
    Temp_byte2 = DS18B20_Read();
    TEMP = (Temp_byte2

  • @shivaranjiniramendran154
    @shivaranjiniramendran154 9 месяцев назад

    Hi I am trying to interface dht22 with stm32l476rg. I followed all your steps. But I cant get the readings to display in my lcd. It shows some funny characters all the time. In my debugger its showing error as well. Cant seem to find the exact problem. Please help….

  • @grogu17
    @grogu17 Год назад

    What should be the clock configurations for stm32f072rb discovery (48MHZ) ?? Because code doesnt work, there is no error, but when i open the live expression it only gives 0. So i taught the problem could be the clock congifuration.
    BTW this is my project for embedded system design so please answer

    • @ControllersTech
      @ControllersTech  Год назад

      Read comments under the video and try those solutions

  • @hashimahmed9117
    @hashimahmed9117 3 года назад

    THankyou for this video!DS18B20 works perfect.
    Can you tell how to change the resolution of sensor and will the code work for negative temperature values?

    • @assemkarmi9370
      @assemkarmi9370 3 года назад

      how it works ?it doesnt work for me any idea please

    • @hashimahmed9117
      @hashimahmed9117 3 года назад

      Double check the code with the video. I noticed that the code was a bit different from the one in the link

  • @nudratjawaria3753
    @nudratjawaria3753 Год назад

    How have you connected the LCD with MCU? Can you explain the breadboard connections of LCD and DS18B20 ?

    • @ControllersTech
      @ControllersTech  Год назад +1

      The ds18b20 connection is shown on the webpage. Link is in the description.
      Lcd is connected via i2c. Scl with scl and sda with sda.

  • @maanavanumala2979
    @maanavanumala2979 Год назад

    Hello I am trying to do this project on a STM32L476 board and it doesnt have the SET_Pin_output and SET_PIN_INPUt functions. what would i do instead?

    • @ControllersTech
      @ControllersTech  Год назад

      These function are not present by default. I wrote them in the code.

    • @maanavanumala2979
      @maanavanumala2979 Год назад

      @@ControllersTech I managed to figure it out. Do you know what I can use to output on putty instead of a display

  • @nghiatranduy8962
    @nghiatranduy8962 6 месяцев назад +1

    i have problem when i try to read ds18b20 temperature with stm32 L0 series. The result always is 4095, do you have any advise

    • @ControllersTech
      @ControllersTech  5 месяцев назад +1

      There could be many reasons for this. Try this video it explains how it actually works. If you have a logi analyzer or an oscilloscope, it will be easier to debug this.
      ruclips.net/video/9RmLBkyb_Gw/видео.html

    • @hi3u164
      @hi3u164 3 месяца назад

      did u find a solution?

  • @thehubisliwa
    @thehubisliwa 4 года назад +1

    It worked for me but I have to add something more. My timer was not incrementing, in function MX_TIM2_Init i added "HAL_TIM_Base_Start(&htim2);" :)

  • @brocooli7744
    @brocooli7744 3 года назад

    But why there is that division by 16 with DS18B20 (25:36 - line 401)? How did you know you have to divide by exactly 16? It is from documentation or what (i can't find it there and i don't understand) :(

    • @ControllersTech
      @ControllersTech  3 года назад

      Check the temperature examples provided in the datasheet

    • @brocooli7744
      @brocooli7744 3 года назад

      @@ControllersTech okay, thank you :)

  • @Kid-cs9ms
    @Kid-cs9ms Год назад

    Kind of a newbie with STM32 boards LCDs so how do I connect the LCD to the board without using an i2c module? I use an STM32F411RE

    • @ControllersTech
      @ControllersTech  Год назад

      Search for lcd in this channel. There is a video on parallel mode.

    • @Kid-cs9ms
      @Kid-cs9ms Год назад

      does the code need to be changed at all or is it just the connections?

    • @ControllersTech
      @ControllersTech  Год назад

      The lcd library file is going to be different. The main code will remain the same.

    • @Kid-cs9ms
      @Kid-cs9ms Год назад

      what exactly would the changes be?

  • @boruuav4300
    @boruuav4300 3 года назад +1

    hello chef,
    thank you so much for this video
    ı want to one question. I must use five sensör same time can ı do it

    • @ControllersTech
      @ControllersTech  3 года назад +1

      What 5 sensors ?

    • @boruuav4300
      @boruuav4300 3 года назад

      ​@@ControllersTech I must use 5 piece DS18B20 temperature sensör on same MCU this is possible?

  • @tomeklewandowski3478
    @tomeklewandowski3478 Год назад

    hi dude!
    Tell me boss, how to use dht11 with usart on timer input capture mode with dma without using delay function? have any magic trick for this?

  • @samalrandula7839
    @samalrandula7839 3 года назад

    I'm using the STM32WB55 nucleo board and DS18B20 as the temperature sensor. Is there any change needed to be done in the code?

    • @ControllersTech
      @ControllersTech  3 года назад

      No changes need in the code but See the setup part carefully

    • @samalrandula7839
      @samalrandula7839 3 года назад

      @@ControllersTech Thank you

    • @samalrandula7839
      @samalrandula7839 3 года назад

      In the response cycle, when we read the pin it should be 0. But im getting 1. What could be the reason ?

  • @toan3931
    @toan3931 3 года назад +1

    How can I convert result of DHT11 from 2 byte temperature to float like DS18B20. I try do it like you code with DS18B20, but it's wrong value.

    • @toan3931
      @toan3931 3 года назад

      Temp_byte1 = DS18B20_Read();
      Temp_byte2 = DS18B20_Read();
      TEMP = (Temp_byte2

    • @ControllersTech
      @ControllersTech  3 года назад +1

      Dht11 doesn't give float values in decimal

    • @toan3931
      @toan3931 3 года назад

      @@ControllersTech oh, DHT22 can?

    • @ControllersTech
      @ControllersTech  3 года назад

      Yes

    • @tuananhbui3844
      @tuananhbui3844 3 года назад

      @@ControllersTech so what different 8 bit integral and 8 bit decimal :( and what the effect of 8 bit decimal because i dont see u use it to display in LCD

  • @leandromontenegropinto6704
    @leandromontenegropinto6704 4 года назад +1

    Thank you!! It works!!!

  • @sinancetin2376
    @sinancetin2376 3 года назад

    thanks for sharing. If you don't mind, Can you make a video about max31855 for temperature measurement?

  • @oanduong7244
    @oanduong7244 4 года назад

    Thanks for tutorials !!!!

  • @hamzairfan5550
    @hamzairfan5550 4 года назад

    Hi. I am using STM32L476RG Nucleo board. I am getting the values of Temperature and Humidity variables but they seem to be coming in 255-1024 range. E.g my temp is showing 331 and Humidity is showing 665. These values changes when parameters changes . when I put a lighter in front of dht22 the temperature values starts going up.
    Kindly help.

    • @ControllersTech
      @ControllersTech  4 года назад +1

      I think you need to divide by 10. So 33.1 and 66.5

    • @hamzairfan5550
      @hamzairfan5550 4 года назад +2

      @@ControllersTech wow you're absolutely right!!!!! Dividing by 10 shows the values correctly now.
      P.S this is me running the compiled code in which both DHT11 and 22 are included. Analogue pin 1 and DHT22 sensor with 3 pins. Also I didn't have to power the DHT22 separately or use a pull up resistor.
      Thanks a lot for this video. Amazing stuff :)

  • @rokio1452
    @rokio1452 4 года назад

    Hi,
    I am using STM32-f031k6 and DHT22 sensor. Max clk frequency of the STM is 48MHz. Do I need any modifications to the code that it will work?

    • @ControllersTech
      @ControllersTech  4 года назад +1

      Dht22 related functions will remain same for everyone. You just need to modify the timer according to your setup. Watch the video properly.

    • @rokio1452
      @rokio1452 4 года назад

      @@ControllersTech ok, I think that I solved my problem with timers but I got another problem. In function DHT22_Check_Response you need to wait for the pin to go low, but my pin does not go to low state. What could be the problem?

    • @ControllersTech
      @ControllersTech  4 года назад +1

      It's related to timing only.
      Check the connection also..

  • @amfa29
    @amfa29 4 года назад +1

    Why did u put PA1(the sensor data) as output and not as input ? the sensor is supposed to send data to the MC not the opposite right ? i'm new so don't laugh at my questions xD

    • @ControllersTech
      @ControllersTech  4 года назад +1

      You are right.
      Actually in this one wire communication, we need to send the command to sensor and receive data from sensor using the same pin.
      Setting input and output based on the Requirements is taken care inside the code itself.
      So here it really doesn't matter if u choose input or output.

    • @amfa29
      @amfa29 4 года назад

      @@ControllersTech oh i see thanks ! however i have a little issue that i need ur help with ! i managed to adapt the code to my f407VG however ,the sensor seems to give the first mesure and then stops ! i'm not getting a refresh unless i restart it manually ! here's my code ! i really wish u could take a look and tell me what could be wrong !
      www.mediafire.com/file/2gcatlkl1v4dh8g/dht11.txt/file

    • @ControllersTech
      @ControllersTech  4 года назад +1

      Give at least 3 seconds delay before measuring again..

    • @amfa29
      @amfa29 4 года назад +1

      @@ControllersTech Damn ... u're a a genius ... Thanks man ! you videos are sooo interesting and nicely done ! Keep it up man

  • @hoangvuviet5923
    @hoangvuviet5923 Год назад

    i used lib and viewed the temp&hum of DHT11 in debug successfully but when I also add i2c-lcd lib, LCD cannot show the temp and hum value. Then i try to send simple string to LCD like Hello and it also doesn't work.
    why? Maybe error when I add 2 different lib file in project ( DHT.c and i2c-lcd.c)

    • @hhh123uh
      @hhh123uh 3 месяца назад

      lỗi ở thư viện thôi

  • @paulinaacosta4989
    @paulinaacosta4989 3 года назад

    What would be the clock frequency for STM32F3030k8? I cant choose 50Mhz

    • @ControllersTech
      @ControllersTech  3 года назад

      It can work at any frequency, higher than 1 MHz

  • @jeffalvarez999
    @jeffalvarez999 2 года назад

    Muchas gracias por su ayuda, lo probé con el DS18B20 en el programa STM32cubeIDE, al principio no me funcionó, y por alguna razón no corre el programa general cuando uso el HAL_delay, así que solo usé el delay() de la función creada, en este caso al ser solo para datos de 16bits, para los los retardos mas grandes usé la estructura for.

  • @liranbugas8062
    @liranbugas8062 9 месяцев назад +2

    hi,
    I am using stm32f401re for dht11
    and in the function Check_Response it stuck in the
    while ((HAL_GPIO_ReadPin (DHT11_PORT, DHT11_PIN)));// gpio port A, pin 0 , timer 2
    and the responce variable is 0
    can you tell me how to try to fix it?

    • @louislienart1093
      @louislienart1093 7 месяцев назад +1

      change the pin mode in the .ioc window, set to input instead of output

    • @Akram-vl7xq
      @Akram-vl7xq 4 месяца назад +1

      ​@@louislienart1093thanks this worked for me.

  • @thainguyenquoc1411
    @thainguyenquoc1411 2 года назад +1

    if i follow you is it possible to simulate it on proteus?(I use stm32f103c6 in proteus)

  • @marcustroy4880
    @marcustroy4880 2 года назад

    why i have error:
    conflicting types for ‘DS18B20_Start’

  • @truongtrongnhan8808
    @truongtrongnhan8808 Год назад +1

    Hello, I have a problem with displaying data to LCD, when I debug, it works well, but when I try to put it to LCD, it doesn't display the value. I use LCD with I2C. Can you check it, please? Many thanks

    • @ControllersTech
      @ControllersTech  Год назад +1

      Lcd display only ascii values so make sure you convert the data to the ascii format first. Use sprintf to do so.
      If it's still not displaying, check if the lcd works separately or not.

    • @truongtrongnhan8808
      @truongtrongnhan8808 Год назад

      @@ControllersTech Many thanks, sir. I will try it

    • @truongtrongnhan8808
      @truongtrongnhan8808 Год назад

      @@ControllersTech It seems like the problem occurs when I use LCD_Init(), when i use that it seems the DHT stops working. Can you tell where is the problem? Thanks

    • @ucnguyenminh8184
      @ucnguyenminh8184 11 месяцев назад

      @@truongtrongnhan8808 I had the exact same problem as you. Have you fixed it yet?

    • @fatihcagrkolsuz5764
      @fatihcagrkolsuz5764 3 месяца назад +1

      define:
      char line1[32]=" ";
      char line2[32]=" ";
      then add begin2 to:
      lcd_init();
      and put this codes in while loop:
      sprintf(line2,"%.2f ",Humidity);
      lcd_put_cur(0,1);
      lcd_send_string(line2);
      HAL_Delay(500);
      sprintf(line1,"%.2f ",Temperature);
      lcd_put_cur(1,1);
      lcd_send_string(line1);
      HAL_Delay(500);

  • @thangnguyend713
    @thangnguyend713 3 года назад

    what should i do if the LCD display -255, Please

  • @kiausiniukova2842
    @kiausiniukova2842 3 года назад

    Hello, I get an error that _HAL_TIM_SET_COUNTER is undifined and implicit declaration of function "_HAL_TIM_SET_COUNTER" is invalid. Can you help me ?

  • @farisilyasa1887
    @farisilyasa1887 3 года назад +1

    I already try the coding LCD just display 0 degree and 0%. Is there anything need to change from coding

    • @MisioNeos
      @MisioNeos 3 года назад

      same...

    • @ControllersTech
      @ControllersTech  3 года назад +1

      Read the comments which i have given the heart (❤️) to

    • @MisioNeos
      @MisioNeos 3 года назад

      @@ControllersTech mateaguero's solution works :))))

  • @ssky7542
    @ssky7542 4 года назад

    Hi,
    I use your code and setting in STM32CubeIDE. (I use DS18B20 with stm32f767zi)
    and I want it to return temp in Teraterm.
    but it return nothing. Tempurature is always 0 *c.
    What should I do?

    • @carmendiezalmoguera3952
      @carmendiezalmoguera3952 3 года назад

      Hi! Did you fix that? Because i have the same problem... Please, let me know if you fixed it

    • @mert8010
      @mert8010 3 года назад

      did you fix it?

    • @ssky7542
      @ssky7542 3 года назад

      Oh, Hi ☺
      I finally fixed it, but it's long time ago and i forgot it already ...
      I just repeat this video and follow each step carefully and then it works ...

  • @jorgeluislampreabarragan3528
    @jorgeluislampreabarragan3528 3 года назад

    Hi
    This video was very interesting, however my sensor DHT11 only read the first value, then this stop the activity. What can do to solve this? I´m working in a STM32f303K8.
    Thanks.

    • @ControllersTech
      @ControllersTech  3 года назад +1

      Make sure you give enough delay between 2 reads.
      Also check the comments with ❤️. They might help you

    • @jorgeluislampreabarragan3528
      @jorgeluislampreabarragan3528 3 года назад

      @@ControllersTech Hi
      I was checking the code with debug, I see that the function "DHT11_Check_Response" stop when it's arrived at " while ((HAL_GPIO_ReadPin (DHT11_PORT, DHT11_PIN)));", because, the pin never get "low", I'm not sure that can be, can you help me?
      can we speak in Discord?
      Thanks.

    • @nhinguyenvan-6279
      @nhinguyenvan-6279 3 года назад

      @@jorgeluislampreabarragan3528 did you find the problem, i got the same error as you, please help me

    • @arunsingh-sw8sb
      @arunsingh-sw8sb 3 года назад

      @@jorgeluislampreabarragan3528 try to give 3 second delay between 2 readings

  • @DanielSanchez-lc2ub
    @DanielSanchez-lc2ub 3 года назад

    I have a question. I did everything from the DHT11 sensor tutorial with LCD and it doesn't work for me. Just introduce me
    TEMP: 0.00 C
    RH: 0.00%
    My DHT11 sensor works but I don't see anything change on the LCD. Please help.
    i'm using STM32F401

    • @ControllersTech
      @ControllersTech  3 года назад

      Declare the variables globally (before main function) and directly update the value into them.

    • @DanielSanchez-lc2ub
      @DanielSanchez-lc2ub 3 года назад

      @@ControllersTech What variables?

    • @ControllersTech
      @ControllersTech  3 года назад

      Those variables where you want to store the temp and humidity values.
      I passed them as the parameters to function right.. don't do that. just declare new variables and save the temp and hum values into them

    • @DanielSanchez-lc2ub
      @DanielSanchez-lc2ub 3 года назад

      @@ControllersTech I don't know if I'm doing it correctly, but it doesn't work for me. :(

    • @ControllersTech
      @ControllersTech  3 года назад

      Take a look at the pinned comment and comment with ❤️

  • @Program2live
    @Program2live 4 года назад

    Hi,
    I have tried your code on the stm32F4 disc board, and the STM32L0 for the DHT11 chip. It gets stuck in the while loop: while ((HAL_GPIO_ReadPin (DHT11_PORT, DHT11_PIN))) in the response function. Any ideas why?

    • @ControllersTech
      @ControllersTech  4 года назад

      Based on all the requests I get on all these sensors, I think you are doing something wrong in the following sections
      1. you made some mistake with the microsecond delay.
      2. Sensor itself is not connected properly.

    • @Program2live
      @Program2live 4 года назад

      @@ControllersTech that's a shame, I checked the timer on the oscilloscope and its perfect, as for the wiring it's almost impossible to mess up. I wonder if there's different types of DHT11 sensors. I will work it out and let you know!

    • @ControllersTech
      @ControllersTech  4 года назад

      You can try using the pull up resistor on the data pin. That might help

    • @Program2live
      @Program2live 4 года назад

      @@ControllersTech I have found the issue is STMCubeIDE, turns out if you put a break-point on DHT11_Start() and jump to the next line the IDE hangs. A glitch to report to ST at some point. Thanks for your help !

    • @ControllersTech
      @ControllersTech  4 года назад

      You should not stop the execution after starting the DHT11... This sensor works on precise timing. When you stop the execution, the mcu stops but the sensor will keep working. So when you read the data in next instruction, you will get some unexpected behaviour

  • @sparta5871
    @sparta5871 Год назад

    Hello, I have a problem that my temperature gets read initialy and it never updates again no matter of what i put on the sensor value, like the while loop breaks or something, do you know what could be the cause? Thanks

    • @ControllersTech
      @ControllersTech  Год назад +1

      Try giving atleast 3second delay between successive reads.
      Also DEBUG... i don't know how you guys write codes without debugging.
      When it stop updating, pause the debugger and see where the control is.

    • @magloirentaba8142
      @magloirentaba8142 3 месяца назад

      I am facing the same problem. I'm using stm32f401re + dht22 and I'm running a simulation on proteus.
      When I run the simulation the values of temperature and humidity are read correctly. However when I vary either value while the simulation is still running the new values are not being updated on my lcd.
      The only way I can display those new values is by stopping and running the simulation again.
      BTW I used the unified DHT library provided in the description link.
      I've tried many solutions and I'm lost and i don't know what to do

  • @farisilyasa1887
    @farisilyasa1887 3 года назад

    is there anything need change on line where have uint8_t and uint16_t

  • @oanduong7244
    @oanduong7244 4 года назад +1

    How to get dark theme on STM32CubeIDE ????

    • @ControllersTech
      @ControllersTech  4 года назад +1

      Goto help-> eclipse marketplace and download darkest dark theme

    • @rcinfla9017
      @rcinfla9017 4 года назад +1

      @@ControllersTech Under CubeIDE 'Help' tab, about two thirds of the way down the help list.

  • @m.nauman7801
    @m.nauman7801 4 года назад

    Kindly make videos on how to add CMSIS DSP Library (FFT or filters) support to stm32.Thanks

  • @ivansh6007
    @ivansh6007 4 года назад

    hi, what software would you recommend to run this project in simulation mode?

    • @ControllersTech
      @ControllersTech  4 года назад

      Why simulation mode?

    • @ivansh6007
      @ivansh6007 4 года назад

      @@ControllersTech i dont really need the hardware, simulation is enough for me

    • @ControllersTech
      @ControllersTech  4 года назад

      I don't know if there is any simulation software for stm32..

    • @ivansh6007
      @ivansh6007 4 года назад

      @@ControllersTech ok, thanks for your amazingly detailed video anyway

  • @Linda-xs5yv
    @Linda-xs5yv Год назад

    hello I have a f401re board which timer do i connect it to ?

    • @ControllersTech
      @ControllersTech  Год назад

      Timer is not used for connection. It just provides the timing for microsecond delay

  • @riannata8309
    @riannata8309 3 года назад

    Hi friend, may you make tutorial for sensor INA219 current, please

  • @filip8467
    @filip8467 3 года назад

    What about not positive??

  • @eveesagiri8397
    @eveesagiri8397 3 года назад

    Sorry how to declare the pin of the DHT11 im using STM32F446RE

    • @ControllersTech
      @ControllersTech  3 года назад

      Use cubemx to set the pin output.. see the video

  • @karthikeyan7705
    @karthikeyan7705 9 месяцев назад +1

    1 st time only my code is executing 2 nd time not executed every time I am going to reset the controller in dht11 sensor

    • @ControllersTech
      @ControllersTech  9 месяцев назад +1

      Give delay of 2-3 seconds before reading again.

  • @eduardodelarosaferrer2205
    @eduardodelarosaferrer2205 4 года назад +1

    Superb !

  • @andresceballos2709
    @andresceballos2709 3 года назад

    hi i am trying to run the code but i get an error in this line of code
    __HAL_TIM_SET_COUNTER (& htim6,0);
    I am using a stm32l051c8t6
    I still can't find the problem.

    • @ControllersTech
      @ControllersTech  3 года назад

      Why is there space after '&'

    • @andresceballos2709
      @andresceballos2709 3 года назад

      it's like I made the comment but normally it's
      __HAL_TIM_SET_COUNTER (&htim6,0);
      even so the code generates an error in that line code

    • @ControllersTech
      @ControllersTech  3 года назад

      Have you set timer 6 in the cubemx ?
      Also it would be easier if you tell what's the error

    • @andresceballos2709
      @andresceballos2709 3 года назад

      @@ControllersTech if I have configured timer 6 as is the tutorial
      my problem is that in the debugger I see values ​​of 4095.9375 for the temperature
      NOTE: I have a pull UP resistor of 4k7
      OHM
      Does it influence when reading the DS18B20?
      according to the tutorial, said resistance should not be

    • @filip8467
      @filip8467 3 года назад

      @@ControllersTech What about not positive measurments?? it will work with ur code? idts

  • @mohammadrahimpoor513
    @mohammadrahimpoor513 3 года назад

    hi i dont know why but when a i use dht22 , i get wrong values, humidity seems to be right but i get 102.4 as temperature which is obviously wrong any ideas?

    • @mohammadrahimpoor513
      @mohammadrahimpoor513 3 года назад

      and i need to say that im using internal clock not crystal

    • @ControllersTech
      @ControllersTech  3 года назад +1

      Are u getting consistent 102.4 ? Are the values fluctuating a little ?
      You can try putting your sensor in the refrigerator for a while and then test. Check the values for both humidity and temperature..

    • @HellesMammuthBS
      @HellesMammuthBS 3 года назад

      @@mohammadrahimpoor513 Do you interpret the values right in terms of temperature measuring units?

  • @Troublemaker-ms9nf
    @Troublemaker-ms9nf 2 года назад

    I have problem with Temp_byte2 reading, it is constantly 0, and consequently i have incorrect temperature value. How can I fix this problem?

    • @ControllersTech
      @ControllersTech  2 года назад

      That will be 0 for dht11 as it doesn't give result in decimal values

  • @RahulKumar-lk1cy
    @RahulKumar-lk1cy Год назад

    code for AHT25 temp sensor using stm32f411re ????

  • @cihankocakir6809
    @cihankocakir6809 Год назад

    why didnt use temp_byte2 and rh_byte2 ?

    • @ControllersTech
      @ControllersTech  Год назад

      They are used in DHT22, as it gives temp and pressure in decimals.
      DHT11's accuracy is upto integral values only.

  • @bsp8751
    @bsp8751 2 года назад

    Hi, how have i connect the pull up resistor to the data pin ?

    • @ControllersTech
      @ControllersTech  2 года назад +1

      Connect a 4 or 5K Resistor between the data line and VCC

    • @bsp8751
      @bsp8751 2 года назад

      @@ControllersTech Thanks for the answer

    • @bsp8751
      @bsp8751 2 года назад

      @@ControllersTech When you said "between" , do you mean a series connection ? (Sorry for the question)

    • @ControllersTech
      @ControllersTech  2 года назад +1

      images.app.goo.gl/WzuRRgL6FhTaXRMF9

    • @bsp8751
      @bsp8751 2 года назад

      @@ControllersTech Thanks

  • @naffaer9759
    @naffaer9759 3 года назад

    hello, i have problem with viewing the temperature and humidity after starting program lcd views initializing and then i dont se anything, i changed your timer from 6 to 1. Can u help what can i do?

    • @ControllersTech
      @ControllersTech  3 года назад

      The steps to debug issue are listed in the pinned comment.
      If they don't work out, then i don't know

    • @quach5081
      @quach5081 3 года назад

      @@ControllersTech So are they ok when I use USART to replace fo LCD???

    • @ControllersTech
      @ControllersTech  3 года назад +1

      Yeah. It have nothing to do with LCD.

  • @dioadadosite4516
    @dioadadosite4516 Год назад

    Hi and good job! How can I make the temperature sensor show me the data every 30 minutes or every estimated period of time... IS IT POSSIBLE? that so that I do not consume a lot of energy

    • @ControllersTech
      @ControllersTech  Год назад +1

      You can use low power mode and set an alarm to wake the mcu after 30 min. Then perform the data read and go back to sleep/standby.

    • @dioadadosite4516
      @dioadadosite4516 Год назад

      @@ControllersTech THANK YOU VERY MUCH, I WILL SEE IF I GET TO IMPLEMENT IT, SINCE THE TIMER IS NOT VERY WELL CONFIGURED IN A PERIOD OF A CERTAIN TIME

    • @ControllersTech
      @ControllersTech  Год назад +1

      It's not the timer. You have to use RTC. Once the mcu goes into standby, timers don't work anymore. We can wake the mcu only using certain things and RTC alarm is one of them.

    • @dioadadosite4516
      @dioadadosite4516 Год назад

      @@ControllersTech
      AGAIN I SAY THANK YOU AND KNOW THAT WE LEARN A LOT WITH YOU

  • @hi3u164
    @hi3u164 3 месяца назад

    my temperature value is 0 what can i do

  • @CaliBeta
    @CaliBeta 3 года назад

    Excellent 👍🔥

  • @camilocienfuegos1531
    @camilocienfuegos1531 4 года назад

    Hey firstly thank u for your every tutorial videos. These are really useful. But i confused about this part of code
    i&= ~(1

  • @haziqazrai4425
    @haziqazrai4425 Год назад

    can this be used on stm32f401re?

  • @Tieulam98k
    @Tieulam98k 4 года назад

    Thanks sir!

  • @marcustroy4880
    @marcustroy4880 2 года назад +1

    /Core/Src/main.c:313:9: error: conflicting types for 'DS18B20_Start'
    313 | uint8_t DS18B20_Start(void)

  • @bietkhong4255
    @bietkhong4255 Месяц назад

    My problem is solved( I use STM32F103C8, Timer 4). My solutions:
    1. In DHT11_Start(), I change the code by:
    {
    HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, 1); //Initialize with Data pin HIGH
    HAL_Delay(1000);
    Set_Pin_Output (DHT11_PORT, DHT11_PIN); // set the pin as output
    HAL_GPIO_WritePin (DHT11_PORT, DHT11_PIN, 0); // pull the pin low
    HAL_Delay(18); //wait for 18ms
    HAL_GPIO_WritePin (DHT11_PORT, DHT11_PIN, 1); // pull the pin high
    delay(20); //20us
    Set_Pin_Input(DHT11_PORT, DHT11_PIN); // set as input
    }
    2. In main(), I add function HAL_TIM_Base_Start(&htim4);
    {
    .....
    MX_GPIO_Init();
    MX_I2C1_Init();
    MX_TIM4_Init();
    HAL_TIM_Base_Start(&htim4);
    ....
    }

  • @cohai6913
    @cohai6913 4 года назад +1

    thanks for sharing

    • @sunny99230
      @sunny99230 4 года назад

      hello bạn. Bạn có thư viện i2c như trên k gửi mình vs.
      gmail: laikhanhluong99@gmail.com

  • @NaveenEC-by9xy
    @NaveenEC-by9xy 3 месяца назад

    can you give the link for i2c.lcd .c & .h file link for stm32f103c8t6 interface with ds18b20

  • @huyphamvu4917
    @huyphamvu4917 3 года назад

    My timer is not working. Can't you help?

  • @bahadrguven6268
    @bahadrguven6268 3 года назад

    debug temperature 25 Humidity 61 '=' ASCI TABLE
    = how can I prevent this or why is it coming

    • @ControllersTech
      @ControllersTech  3 года назад

      What you want to prevent exactly ?

    • @bahadrguven6268
      @bahadrguven6268 3 года назад

      @@ControllersTech Why does the humidity ASCII equivalent write ?

    • @ControllersTech
      @ControllersTech  3 года назад

      It doesn't write anything. That's how the debugger shows the result. It shows ascii equivalent of the value

    • @bahadrguven6268
      @bahadrguven6268 3 года назад

      @@ControllersTech sorry my bad

  • @aovanhieu3319
    @aovanhieu3319 2 года назад

    Can you give me library of i2c-lcd?Thanks

  • @yordaniferreiras6995
    @yordaniferreiras6995 4 года назад +2

    All of those who has been having trouble because of the infinite loop: With this modification it works on my case.
    void MODO_SALIDA(){
    RCC->AHB2ENR|=(RCC_AHB2ENR_GPIOAEN);
    GPIOA->MODER |= (0

  • @ayoubkouch56
    @ayoubkouch56 3 года назад

    your code about ds18b20 is not working, i'm not asking you something, just tell you it's not working

    • @ControllersTech
      @ControllersTech  3 года назад

      controllerstech.com/wp-content/uploads/2021/06/dsbProof.jpeg

  • @emreseyyar5078
    @emreseyyar5078 4 года назад

    what about stm32f103c8t6 ?

    • @ControllersTech
      @ControllersTech  4 года назад

      What about it ?

    • @emreseyyar5078
      @emreseyyar5078 4 года назад

      Controllers Tech i have stm32f103c8t6 mcu i see some differences for coding operetion

    • @ControllersTech
      @ControllersTech  4 года назад

      No there is no difference. It works for every controller.

    • @emreseyyar5078
      @emreseyyar5078 4 года назад +1

      bro for my mcu (stm32f103c8t6) i can not see TIM6 i see only tım1,tım2,tım3,tım4 what can i do instead of that ? could you help me please ?

    • @ControllersTech
      @ControllersTech  4 года назад

      You can use any timer you want. Just make sure that you use the prescalar and ARR values according to your setup

  • @malekzitouni1779
    @malekzitouni1779 5 месяцев назад

    can u give me the main.c
    ?

    • @ControllersTech
      @ControllersTech  5 месяцев назад

      Link to download the project is in the description.

  • @LatenteMor
    @LatenteMor 2 года назад

    i had a problem that i wasn't able to solve, but then i just changed gpio_output, to gpio_input and everything works!!! In this case is the same because is one wire communication

  • @quochuytran5079
    @quochuytran5079 4 года назад +1

    thanks
    can you give me library i2c_lcd

    • @ControllersTech
      @ControllersTech  4 года назад

      go to the link the description, and download from there

    • @quochuytran5079
      @quochuytran5079 4 года назад

      @@ControllersTech i'm trying add file.c in src but can't. Can you tell me about it... thanks

    • @ControllersTech
      @ControllersTech  4 года назад

      What ide are u using ?

    • @quochuytran5079
      @quochuytran5079 4 года назад

      @@ControllersTech thanks, i got it
      But i not use #include "i2c-lcd.h" in function main. I use sm32f411VET

    • @sunny99230
      @sunny99230 4 года назад

      bạn ơi bạn có thư viện i2c cho mình ms.
      gmail : laikhanhluong99@gmail.com
      cám ơn bạn rất nhiều.

  • @tuankienkim6881
    @tuankienkim6881 Год назад

    I tried change mode of Pin A0 from GPIO_MODE_OUTPUT_PP to GPIO_MODE_OUTPUT_OD and in DHT11_Start() function you guys can remove Set_Pin_Output and Set_Pin_Input funcion (must set PA0 to high first).
    void DHT11_Start (void)
    {
    HAL_GPIO_WritePin (DHT11_PORT, DHT11_PIN, 0); // pull the pin low
    delay (20000); // wait for >18ms
    HAL_GPIO_WritePin (DHT11_PORT, DHT11_PIN, 1); // pull the pin high
    delay (45); // wait for about 40us, đợi DHT11 respone
    }
    In DHT11_Check_Response() function remove 'delay (40)' after 'uint8_t Response = 0'. Let's try it, it works fine

    • @minhnguyeninhhoang7982
      @minhnguyeninhhoang7982 Год назад

      Hi, have you ever try to control PT100 sensor by using stm32f103c8t6?

    • @hhh123uh
      @hhh123uh 3 месяца назад

      bạn làm theo video có chạy không

  • @jackycheung7084
    @jackycheung7084 2 года назад +1

    I 100% followed the video and the code but still doesn't work
    then after >10 Hours of debugging, I found out it magically works well if I turned the data pin back to Reset_State
    Still can't figure out why, but it works so whatever lolll

  • @dennisyildirim2708
    @dennisyildirim2708 4 года назад

    can you just fuckn share the sketch so that we can download the damn thing and see if the shit is working or not?

    • @ControllersTech
      @ControllersTech  4 года назад +1

      Goto the link in the description.

    • @MyPodie
      @MyPodie 4 года назад +5

      Dennis Yildirim dude chill out and be grateful and polite

  • @GodsOnlyMonster
    @GodsOnlyMonster Год назад

    I watched the video and followed all the steps properly and DHT11 sensor worked for me in 1st attempt (I am using stm32f407 discovery board), later for one project I needed to use the temp sensor with HC-SR04 sensor and 16x2 lcd without i2c driver but it was not working I checked and found out the program was getting struck, I scrolled thru the comments and saw one guy giving some suggestion @electrolabs337 (Electro Labs) was his name, His solution no 1 worked flawlessly (big thanks to him) but can anyone explain why is his solution working, I would really really like to know

  • @kacemberriah5637
    @kacemberriah5637 4 года назад +1

    the check response dos'ent work the dht22 dosnt give a low voltage so the loop continus forever any help ?

    • @MyPodie
      @MyPodie 4 года назад

      I think I have the same problem. Using DHT22 as well, but it gets stuck at the response check

    • @ControllersTech
      @ControllersTech  4 года назад

      Plz check the pinned comment

    • @camilocienfuegos1531
      @camilocienfuegos1531 4 года назад

      same problem for dht11. The code is stuch at last while which is in response function. Actually it's working only once. Can someone help ?

    • @ControllersTech
      @ControllersTech  4 года назад

      Is the us delay working properly ?
      What's the hlck u have ?

    • @MyPodie
      @MyPodie 4 года назад

      Controllers Tech ya I tried to light up the led every single second using the us delay and it seemed to work just fine. However, it looped inside the while loop infinitely waiting for the pin to go low in check response function. I’m using an stm32f407 board and have the same setting for the hclk in the tutorial video (50MHz). I’ve checked data sheet of the DHT22 and everything in the code looks just fine accordingly. I’ve been working on this for an entire week now and have purchased several new DHT22 sensors in case the sensor is busted, but still have no clue what’s going on.. I’d greatly appreciate it if you can offer any help!