This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Interfacing nRF52832 with ds18b20

Hello guys,

                 I'm trying to interface nrf52832 with ds18b20 temperature sensor and I'm using this code https://github.com/sigurdnev/Nordic-DS18B20 and I'm getting the output value but sometimes I'm getting temperature value as -0.063 and sometimes some random values I'm completely new to nRF so I don't know what I'm doing wrong

Parents
  • Hi,

    Are you running any BLE roles at the same time? (advertising,scanner,central/peripheral connection)?

  • Hi,

    No I'm just using GPIO only

  • How does your main.c file look like? is it 100% the same as the example main.c ?

    The example is very basic, and in a normal application, you likely want to trigger the reading in a app_timer callback so that the GPIO reading happens at a higher priority level, so that it's not preempted by other interrupts.

  • Hi,

    After your suggestion I added app_timer in the main.c  but I'm getting an error, I have added the images of the main code and the error I got, Can you tell why I'm  doing wrong

  • From the screenshots, it looks like you used the example from github(without modification) when you experienced this issue. In that case, there should not be any interrupts happening, that could cause the GPIO reading/writing timing to fail. You could try to start the HFCLK from the crystal oscillator, and see if that makes any difference. Also check the wiring to the sensor, and make sure they are all properly connected.

    Fullscreen
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Ok this is what I have tried, and this is my main.c

    Fullscreen
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Reply
  • Ok this is what I have tried, and this is my main.c

    Fullscreen
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Children
  • And this is my ds18b20.c

    Fullscreen
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Fullscreen
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    And this is my sdk.h 

  • If I run it Its not printing anything 

  • Arun0498 said:
    Its not printing

     Over UART or Segger RTT debug terminal?

    Were you able to get it working with the original code ?

    If you are getting garbage values with the original code, then I suspect there is some HW issue with your setup. As previously mentioned, please check the wiring to the sensor, and make sure all wires are properly connected. If you have a spare sensor, then try to replace the one you are using now.

  • Hi 

    Its not printing in both Termite and debug terminal 

    I have also checked the wiring also as you suggested it same as this one https://github.com/sigurdnev/Nordic-DS18B20/blob/master/nordic-ds18b20.jpg and also tried with different temperature probe same output only coming and even the old temperature probe is working fine when I tried with Arduino