ds18b20 on multiple pins?

Hello all.

I have a photon that I have one ds18b20 running on. I used the example in the “Docs” section; “temperature logger” tutorial to get it up and running. It works really good.

I would like to put one ds18b20 on each pin of the digital in…so 8 sensors…pins D0-D7.

I’ve tried several different ideas but can not get it anywhere near correct.
I’m also newer to this as I used to use the picaxe cpu’s. In that I used goto’s to jump around in the program and use of that here is frowned upon. So I would like to do it correctly but not seasoned enough to be able to pull it off.

Any help is greatly appreciated! Thanks!

Also, when I try to read on seperate pins, I keep getting “no more addresses” printing to my terminal. I know this has to do with the one-wire bus searching for devices. So to have one device per pin means I should have to issue a read rom [33].
…so how the he** do I do that? With using the “onewire” library includes.

First of, the DS18B20 uses a OneWire bus which means you can have multiple sensors on the same pin and just use addresses to talk to one specific device.

But if you really want to run one bus per sensor, you should instantiate one sensor object per sensor/pin and use the dedicated objects and not try to switch pins in the object.

And “surprisingly” there already were similar questions

1 Like

I know it sounds weird…but yup…that’s what I want to do. I thought about it after the post and have some things to try. Basically what you have mentioned. Thanks!

OK…so I’m getting nowhere quick.

Here’s what I would like to do:

First, check to see if there is a sensor present.
Then, the very basics needed to read and convert the temp.
Do I need the include files for this? What is the very basic code I need to achieve this?

Sorry I’m a bit of a moroon…but I’m a beginner and trying to learn.

Thank you.

Yes, similar but not exactly what I’m looking for. I don’t want to hard code the serial numbers. I don’t want a single bus. Check the pin for a sensor, if no sensor tell me and move on;
If sensor, read/convert; move on.

Not trying to be ungrateful or pushy, just looking for a specific way to achieve this.

This is one of the links and that seems exactly like what you want

I (or anybody else) could provide you with some ready made code, but I much prefer it when people first understand the problem and its solution, rather than just following or even merely using boilerplate code.

That’s what happens when you get: “no more addresses”

You just need to reset the search on each new attempt for a new pin.