Hi,
I am using nrf51822 to get DS18B20's temperature data, but I am fail to do it.
Would you please give me an sample C source code which can get temperature data from DS18B20?
Thank you,
Chianglin
Hi,
I am using nrf51822 to get DS18B20's temperature data, but I am fail to do it.
Would you please give me an sample C source code which can get temperature data from DS18B20?
Thank you,
Chianglin
Hi Ives.
I added the full project which I have modified so it now writes out the correct values.
DS18B20TEST.7z
I stripped down main.c and added some stuff in the DS18B20.c so it only takes the measurements of the one-wire sensor. (I used RTT for logging)

(note: 190 = 19.0 C and 662 = 66.2 F)
which is correct: 
Hi Ives.
I added the full project which I have modified so it now writes out the correct values.
DS18B20TEST.7z
I stripped down main.c and added some stuff in the DS18B20.c so it only takes the measurements of the one-wire sensor. (I used RTT for logging)

(note: 190 = 19.0 C and 662 = 66.2 F)
which is correct: 
Hi Martin,
After I will test directly with the code you provided.test directly with the code you provided, and it still have one problem.
It will always print "INFO: (R0004)" in RTT debug windows. It means the program always stay in following loop\
while (! iBSPACMonewireReadBit_ni()) {
NRF_LOG_INFO("(R0004) \r\n");
}
Does I miss something?
Thank you
Chianglin
Hi Ives,
Note that I have changed the GPIO pin for the one wire.
#define ONEWIRE_PIN 29
If you have not connected to the pin correctly as well as powering the Temp. sensor you would get out that info message according to my observations.
Please double check and verify the connection.
Best Regards,
Martin L.
Hi Martin,
Sorry, I forgot to tell you:
I had already change DS18B20 data pin to pin 29, so I can find follow message.
But the program can not exit following loop.
while (! iBSPACMonewireReadBit_ni()) {
NRF_LOG_INFO("(R0004) \r\n");
}
Thank you,
Chianglin
Hi Ives,
I ran your exact application you posted.
I did not have any issues:

However, if i disconnect VDD to the sensor or the one wire data line I get stuck:

Could you post how you have connected to the Sensor?

(RED- VDD, Yellow-onewire(p0.29), BLACK-GND)
Hi Hi Martin,
Yes. you are right.
I had check my DS18b20 circuit again, and had connect to incorrect pin.
After I connect DS18B20 data pin with P0.29, I had print out all the ROM data into RTT, please find the following debug message
According to the display result of the One-Wire waveform, the data read should be 0x0118323C7DFF. However, the data I read is 0xFFFFFFFFFFFF..
My source code is:
Would you please tell me how can I modify my code?
Thank you,
Chianglin