I use the Z-Uno with 4 x DS18B20 - it is working, ...
Maybe you are using 18B20 with parasite power?
You are working with sample sketch - - or can you attach your sketch?
Michael
Z-Uno - negative temperature value from DS18B20
Re: Z-Uno - negative temperature value from DS18B20
No, not parasite powered.michap wrote:Maybe you are using 18B20 with parasite power?
Sure - see attached file. It's a modified sample sketch. See the comments for line #25/26 and #34/35...michap wrote:You are working with sample sketch - - or can you attach your sketch?
Thanks
Ralf
- Attachments
-
- DS18B20Scanner.zip
- (1.37 KiB) Downloaded 273 times
Re: Z-Uno - negative temperature value from DS18B20
I just found the reason...
I reduced the space of the array where the addresses of found 1-wire devices is stored. In my test setup I've two DS18B20 attached and assumed it's enough to provide 2x8 bytes for the device address buffer (because of two devices).
DS18B20Sensor::findAllSensors(byte * rom) writes one more device address to the provided device address buffer than devices found. If 4x8 bytes are provided:
- bytes[0..7] report the device address of the first device
- bytes[8..15] report the device address of the second device
- bytes[16..23] report the device address of the second device again
- bytes[24..31] are all zero
Nevertheless, DS18B20Sensor::findAllSensors() returns 2 devices attached to the 1-wire bus.
Not sure if the above is mentioned somewhere, if not it may make sense to extend DS18B20Sensor::findAllSensors() by a second parameter to provide the size of the provided device address buffer, to prevent DS18B20Sensor::findAllSensors() from overwriting other stuff located behind the device address buffer.
Ralf
I reduced the space of the array where the addresses of found 1-wire devices is stored. In my test setup I've two DS18B20 attached and assumed it's enough to provide 2x8 bytes for the device address buffer (because of two devices).
DS18B20Sensor::findAllSensors(byte * rom) writes one more device address to the provided device address buffer than devices found. If 4x8 bytes are provided:
- bytes[0..7] report the device address of the first device
- bytes[8..15] report the device address of the second device
- bytes[16..23] report the device address of the second device again
- bytes[24..31] are all zero
Nevertheless, DS18B20Sensor::findAllSensors() returns 2 devices attached to the 1-wire bus.
Not sure if the above is mentioned somewhere, if not it may make sense to extend DS18B20Sensor::findAllSensors() by a second parameter to provide the size of the provided device address buffer, to prevent DS18B20Sensor::findAllSensors() from overwriting other stuff located behind the device address buffer.
Ralf