9 years ago.

Communication problems between Nucleo L152RE and DS18B20

Hey,

I'm really stuck in my work on communicating with the DS18B20 with the Nucleo L152RE. I have tried several programs on the mbed site, and i always get 0 devices found. I am positive that my circuit is properly set up with a 4.7K pullup resistor as in the datasheet. One of the programs gave me the following output;

Family code: 0xFF Serial Number: FF:FF:FF:FF:FF:FF CRC: 0xFF Sensor Buf : -0.06

It seems to me that the line isnt pulled back down or something since its returning all 1's. I would really appreciate some help with this.

From the DS1820 HelloWorld program which is located under component/DS18B20 I get the following from the oscilloscope probe on the signal pin of the DS18B20:

/media/uploads/hebryn/img_20150218_144712.jpg

Håkon

Question relating to:

ds18b20 work for ST Nucleo DS18B20, temperature sensor

.

posted by Håkon Bryn 20 Feb 2015

2 Answers

9 years ago.

From our earlier conversation it followed that the DS18B20 does seem to respond on a reset, but apparantly not much more than that. Do you have it connected via a very long cable? Or possibly breadboard which is crappy? Or do you happen to have another sensor to test?

okay, I have now changed the breadboard, and tested the sensor with an arduino, which is working. The wires are short. I still get 0 devices discovered, but if u look at my notebook page I have included an oscilloscope image of the pulse sequence.

posted by Håkon Bryn 18 Feb 2015

So on an Arduino it does work, thats interesting. The oscilloscope picture shows something is happening, but not much more than that.

What is visible, and weird, is that the maximum voltage changes. You used the program that your DS18B20 is related to? Or my version? Officially you should write '1's by letting it float up, but my version (inspired on Arduino version) also forces it high when possible, improving signal integrity. But this would result in possibly what you see on the scope picture. The program you linked for the question does not do that.

What are you powering your DS18B20 with? Best to try would be 3.3V power on its VDD, so no parasite power, and then pull-up also to 3.3V.

posted by Erik - 18 Feb 2015

I have used your program in the tests, and a 5v supply from the nucleo board. I have updated the notebook page with a new oscilloscope picture where I have powered it to 3.3V. I also tried with a Nordic nRF51822 mKit and it gave med the exact same pulsetrain. But still there are 0 devices found.

I put a printf in line 133 and that shows that there are an error reading the data. I suppose it could be maybe the bit_out or bit_in functions that are messing it up since all I get is 1's after the presence pulse.

posted by Håkon Bryn 18 Feb 2015

Paul Staron tested it on his Nucleo board, and it also did not work for him. One possible reason is that the Nucleo code to switch between input and output of pins is best summarized as 'horrible'. It needs to toggle a single bit and takes ages to do it, and in the process overwrites a bunch of states. I will have a look later if I still have a DS1820 myself someonewhere, and see if I can make a workaround for Nucleo devices. (Or if you want a starting point yourself, going to require some editting, but if you can replace the current DigitalInOut with a FastInOut from here: http://developer.mbed.org/users/Sissors/code/FastIO/), it might work. Only problem is that it uses a quite different syntax.

posted by Erik - 19 Feb 2015

Did you get a chance to look at it? I wan't to ask you as I have an application that is dependent on the DS18B20 to work, It is a low powered application where the MCU will be sleeping most of the time and taking measurements from different sensors every 30 mins or so. I don't need more than 8K RAM and probably not more than 32K flash memory. Is there a platform that you would recommend, that you know works with the DS18B20?

posted by Håkon Bryn 20 Feb 2015

First of all: There is from a hardware POV no reason why this should not work. It is in the DigitalInOut mbed code most likely. I haven't had time to search for my own DS1820 that might be somewhere around yet (or I might have thrown it out for bending pins beyond recognition). Otherwise I should have a new one someday, but as long as it is hobby and no-one pays me it all comes down to when I feel like it.

As alternatives every NXP/Freescale M0 with roughly those amounts of RAM/flash should run deepsleep at <3uA and run the DS1820 fine.

posted by Erik - 20 Feb 2015

I checked and I don't seem to have a DS1820 anymore. In the coming week one should arrive, but then I still don't have your nucleo target, although I have different ones with same code base.

posted by Erik - 20 Feb 2015

Hey I fully understand that you want to do this when you feel like, and I have to get the DS18B20 working asap so I think I will just choose another platform for now. Thank you for helping and clearing things up!

posted by Håkon Bryn 20 Feb 2015
7 years, 4 months ago.

Hello, did you get it to work? I have the same problem but with a nucleo stm32 l073rz I'll apreciate any help Thank you