larsks / blog.oddbit.com

3 stars 0 forks source link

post/2018-03-27-multiple-1-wire-buses-on-the-/ #10

Closed utterances-bot closed 3 years ago

utterances-bot commented 3 years ago

Multiple 1-Wire Buses on the Raspberry Pi · The Odd Bit

The DS18B20 is a popular temperature sensor that uses the 1-Wire protocol for communication. Recent versions of the Linux kernel include a kernel driver for this protocol, making it relatively convenient to connect one or more of these devices to a Raspberry Pi or similar device. 1-Wire devices can be daisy chained, so it is possible to connect several devices to your Pi using only a single GPIO pin, and you’ll find many articles out there that describe how to do so.

https://blog.oddbit.com/post/2018-03-27-multiple-1-wire-buses-on-the-/

dibdib99 commented 3 years ago

Hi, The DS18B20 Dallas device has a Programmable Resolution from 9 Bits to 12 Bits. This is selected by writing to byte 4 of the scratchpad memory. How do you write to this device using the w1 bus interface? The power on resolution is 12 bits (0.0625 deg C) which takes 750ms to do a conversion. As the accuracy os only 0.5 deg C I would like to use only 9 bits or resolution (0.5 deg ) when a conversion takes only 93 ms. Thanks Ian davidson

larsks commented 3 years ago

Hi, thanks for the question! I don't have an answer off the top of my head, but it looks like this question has been asked elsewhere: https://raspberrypi.stackexchange.com/questions/71563/how-to-set-precision-of-ds18b20-via-w1-therm

HuthjaminBen commented 3 years ago

Hi, how many GPIO-pins may I use as one-wire-bus-pins? All? (That would be fantastic!) Am I able to only read out the sensors connectet to one specified pin without caring about the ID of the sensor? For example may i read all temperatures from pin 17, without knowing their IDs? Thanks in advance Ben

larsks commented 3 years ago

how many GPIO-pins may I use as one-wire-bus-pins?

I think you can use any available gpio. Your best bet is just to try it.

Am I able to only read out the sensors connectet to one specified pin without caring about the ID of the sensor?

It's been a while since I wrote this, but I don't believe you need to know the id of the sensors; the driver discovers the available devices on each bus.

GerfriedC commented 3 years ago

Is this feature of connecting several 1-wire branches available with the Pico too?

larsks commented 3 years ago

@GerfriedC It is generally possible to support multiple 1-wire buses on a microcontroller...e.g., the standard Arduino onewire library accepts a pin number in the constructor, so can create a bus for any spare GPIO pin.

I can't comment specifically on the Pico because I don't have one, and every place I've looked is out of stock.

In any case, the solution wouldn't have anything to do with this article, which is specific to Linux.

GerfriedC commented 3 years ago

Now I have tested and two questions:

HuthjaminBen commented 3 years ago

I've tried it in 3 GPIO Pins and it worked, but than I noticed, that this wont let my project become easier, so I did not test the max of GPIO Pins. Ive also tried it with a RasPi ZeroW (2 Pins) - it worked fine. As I understood the pullup just makes sure, that the pin definitly goes to "+", so that the 1-wire-master is able to send a kind of "start-comand" to the sensor by bridging the pin to zero - if You use power supply for the sensor (not that "parasite - power - thing") it should work even with less than 1,6V.