I am connecting multiple DS18B20 together I wonder if I need to use level shifter to get the data? and also What is the way to connect several of DS18B20 together. Should I use paradise power connection?
The DS18B20 is a digital sensor, several of them can sit on the same bus.
It will require a bit of ground work to map a sensor ID to a location (heat it up and see which changes).
I would recommend never using parasitic power, and just connect power+gnd+signal to each sensor.
A star network is advised against in the appnotes, but can work depending on your total wire length and sensors.
For max range, I would run the DS18B20’s on 5V, but if you prefer they can run on 3.3V also.
The photon has some 5v tolerant pins, so a pullup to 5V should not hurt it and will give larger signal-to-noise ratio.
If you need more than 30meters/5sensors I would recommend to have several busses, either by using multiple pins, or using hardware to isolate the busses from each other, for example an analog multiplexer.
Although the DS18B20 can work as multiple units on the same wire, figuring out and maintaining the order of the sensors by using their serial number can be complicated. It can be easier to ignore the “multiple units per wire” feature and just attach the sensors individually to different pins on the microcontroller, and then ignore the individual serial numbers of the sensors, each sensor then having the same index ID.
For beginners, first get individual units working on different pins. If you are worried about multiple wires leaving the display unit, you can use CAT-5 cable, with a power, a ground, and six sensors each individually attached to to a different wire in the cable.
Parasitic power works but it is slow, I recommend not using it.
Thank you for you answer. It was useful. I have one more question. Do you load your use the SparkIO IDE to load Libraries.
Actually, I dont yet have my photons… but I have worked alot with DS18B20 in other projects, so not sure how to interface them in photon software yet.
Do you know how to import library on local ide? I am trying to get the ide load OneWire and make sure it can be compile to the chip. I feel it’s so confusing. Arduino doesn’t have this many issues on loading. It looks like every single project we compile need to be going through cloud.
You can add libraries via the IDE in the web IDE by clicking on the bookmark looking icon on the lower left. Once doing that, you need to search for the library you want. These are all libraries that were submitted by Particle employees or users.
You can also manually add libraries by clicking on the little plus in the upper right in the IDE.
Finally, you had expressed frustration using the Web IDE and prefer an Arduino type model. There is also an offline editor called Spark Dev and you can download it here.
I understand your frustration with web IDE and go back and forth myself. The thing I love about it is the ability to edit wherever you are. The thing that I dislike about it is that it is hard to consistently maintain file versioning.
The local one I have downloaded since the first day I get SparkIo. This local IDE doesn’t provide anything such as, import library or any option like this. The cloud based IDE is not doing anything with compiling when I was trying to compile it from Web IDE. When I use the example from the Web IDE, the Verify and Flash button is completely not clickable. There nothing associate with compiling
Spark Dev is a bit different from the Arduino IDE. It does support libraries and the way you use them is put them in the same folder as the .ino file. The thing that I learned the hard way is that the folder structure needs to be completely flat. You cannot have any other files in that directory or anything in sub-directories. Everything needs to be in the route of the project directory.
It works fine if you follow that process.
yes, I just find that out. Thank you.
When the Error message pop out, it doesn’t tells which file has error. How can we possible deal with this kind of error.
Got my photons recently and made an attempt at multiple ds18b20.
I didnt manage to do it with the current libs, just importing onewire library gives complie error.
So instead I spent some time porting the code I used on AVR, which went suprisingly well.
I will clean it up more over the weekend, but if you are desperate send me a message and I will post the work in progress
Published the library today under the name "DS18X20"
Its a bit messy since its old C code, not a proper cpp class, if someone is up for the task of converting it that would be nice
DS18b20 Working Example?
Thanks @MORA your implementation worked for me finally sigh.
I had tried all the other solutions for working with onewire and dallas temperature with my photon but i always run into some compilation error. This just worked. I have only one (DS18B20) so i’ve just tested it with one sensor. Thanks again.
That sounds similar to PoE way.
I’m new to Particle Photon. I’ve successfully build several tests with X-Band motion detector, etc. so I’ve become relative comfortable with the Photon and most of the tools, like the IDE. But I’m now trying to implement your library for the DS18B20. (I’ve tried a couple of other implementations, but yours seemed the most current, used the Photon and I see from this thread that others have used them AND THEY WORKED!)
I’m having a problem with every library I’ve tried. I’m not seeing the DS18B20.
I got two DS18B20’s from Adafruit. I’ve tried both of them. I’ve connected the data lead from the DS18B20 through the 4K7 resistor that came with the sensor to D0 of my Photon. I’ powering my breadboard, Photon and DS18B20 with 4.72v.
My code is your onewire.cpp, unmodified.
Any help would be appreciated.
Your data line should be pulled high, so the resistor should go from data line on DS18B20 to either VIN or VCC on the photon.
And the datapin before the resistor should be connected to a photon digital pin.
GND to GND.
I generally dont use the parasitic power feature of the sensors, I always connect all 3 pins.
I’ve got a small example explained over here. It’s only one sensor, but pictures are always nice to see how to hook one up
That got me running. I didn’t understand the hookup.
I appreciate to good work you’ve done, and the quick response.
Thanks! That got me up and running.