read sensors DS18B20 - without onewire library

Hi,

I have 13 sensors DS18B20 inside my house cabled to central location, because of the wire topology I have connect them to Arduino Mega on 13 pins, each one has it's on PIN and rezistor.
can I read those sensors without using onewire library? or how can I read all of them?

Why would you want to go to the cost and effort of not using a library?

1 Like

And why have you connect them to separate pins?

And did you connect them in 1-wire mode or do you give them separate power?

And indeed, why NOT use the library?

1 Like

Hi,

sensors are installed and cannot modify the cables. if I want to connect them on single pin will have a start topology and will not work.

  • I read that having multiple instance of one wire (in my case 13, is difficult and not sure if will work) so I thought maybe I can read the sensors in a different way - as a digital sensor... or don't know :slight_smile:
  • so I am looking the simples way and reliable way to read those 13 sensors connected to 13 pins using resistor on each ping...

Maybe too late if you have already wired the house - but this might be a lesson to test things on a bench before installing them.

You only need 1 cable (3 core) from the arduino (using only 1 input pin for all sensors). You only need 1 resistor on this cable as well.

All devices then attach to the one cable in parallel. The arduino then 'talks' on the cable to each device - they all have unique ID's built into them.

One option to get out of this mess is to parallel them all up before attaching to the arduio and using the library and keeping only one resistor.

Hope this helps.

1 Like

A 'star' topology is a parallel topology for your system!

Connect all the grounds from the sensors together.

Connect all the +VCC from the sensors together.

Connect all the data lines together.

Add one resistor across data and V+

Connect to one pin on the arduino and there you have it!

ovex:
can I read those sensors without using onewire library?

Yes you can, by using this method

I have done it with two sensors. That was quite stupid enough but doing it for thirteen is beyond moronic and definitely not the sort thing write home and tell your mother about. I didn't know what I was doing, and I was trying to work around a self-inflicted problem. Read replies #1 and 2 again.

so the story is like this...

when I build my house, and install the heating system in the floor I said why not measure the flooring temperature so I have order some sensors and add some wires and cable to one location... no time for testing
now I am in the situation to read those sensors and my first attempt was

  • all in parallel,one wire, one resistor, one pin - I was not able to discover the sensors or read
  • second attempt I group the sensors in groups of 4 did not work
  • 3rd attempt I group them in groups of 2 with a 2K rezistor and this method worked to discover and read one pin (bus) at the time.... but I was not able to find or write the code to read 7 pins (7 onewire)
    so I thought maybe if I connect each sensors to a ping will be easier :slight_smile: so I do not have to use onewire library and address each sensors separately.

I apologies I am not expert.. so I hope you can guide me on the right track to accomplish this....

A star is indeed not ideal for OneWire. Originally OneWire was only designed for short distances (same PCB) so distributing them through a house is a bit of a stretch.

But a quick scan through the OneWire code and I don't see why it cannot work with multiple instances...

What cable did you use to wire the sensors with?

What power supply are you using?

What arduino are you using?

You need to post your code (using code tags) as the problem may be there.

ovex:
... no time for testing

And now you pay the price for that!

You built a house and in all that time you didn't have a few spare hours making a test system? - I hope the rest of the wiring and plumbing is better thought out!

If you can get to the cables nearer the inatalled location(s) you could add a pro mini arduino there with nrf24l01+ and send the data back to the main arduino wirelessly. But that would require more outlay on parts and more complex programming.

:slight_smile: yes I do pay for the hurry I install the sensors...... but I hope will find a solution to read all those 13 sensors....

No answers to the questions I asked, so now I can't help you any more.

@ovex, reply 8?

Hi,

@skywatch I apologies I did not answer until now,

cable - each sensor has 4*0.25 shielded cable
power I use external 9V to Arduino
Arduino type - I do have Arduino uno and Arduino Mega - I can use any of this
Code.. I have no relevant code because I do not know on witch direction to go.... so I hoped I can find some guidance, what is the best approach?
so I understood corect that Dallas and onewire library and mandatory.
having my situation how do you advice to read the sensors?

@septillion
so do you recomand me to start multiple onewire instance for each pin.

I will look to see if I can find any workable example from where I can start to modify.

Is that 4 single shielded cables to each sensor or one 4 core cable with 1 shield?

How did you wire each ds18b20 to the cable? What does the shield connect to? Or is the shield not connected? Are the sensors soldered or screwed to the cable?

The 9V power supply. How many amps can it deliver? Amps or mA on the label?

In your situation I would proceed as follows......

Use the Dallas library. Load the single code from examples into your arduino.

Attach only ONE sensor at a time to the input pin you have selected to use for the arduino. Use only one resistor to +Vcc.

Test each sensor one at a time. Note which ones respond and which don't.

Then take all the working ones and parallel them up as I posted earlier in this thread and load the multiple code from the library. See if you can still see all the sensors then.

You will need to look at the serial window in the Arduino IDE to see if the device(s) respond(s) or not.

You should only need one instance of the one wire library running. But do the tests in logicl order and lets see what we get.

As an aside, if a sensor fails how will you replace it?

If you have a spare ds18b20, get that working on the bench first and then proceed to test the installed ones. At least that way you know you have a working sketch on the arduino.

Where does the power for the DS18B20s come from? The 9V supply is too much for them.

I have to go out now but will be around again later on today.

I see no problem why not. Just

OneWire TemperatureSensors[13] = {2, 3, 4, 5, etc}; //or whatever pins you want

But yeah, would test that on the bench first of course.

Hi,

If i'll use OneWire TemperatureSensors[13] = {2, 3, 4, 5, etc}; will create multiple instance in paralel for each ping or one by one? and do I have to specify the sensor ROM?