Pages: [1]   Go Down
Author Topic: 1 wire temp sensor  (Read 460 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 111
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a project that will ultimately have 5 ( or more) DS18b20  sensors on each of 2 pins.

The issue is that these 5 sensors may change from time to time. eg I will have 3 sensor arrays (A,B and C) and any one of these may be on pin0 while one other may be on pin1 while the third will not be in use.

What I would like to do is have the sketch read the address of the sensors in each sensor array then use "RequestTemperaturebyAddress" as opposed to "RequestTemperatureByIndex"

I have read the "One Wire Address Finder Sketch" but I cant figure out how to read an address, store the address then read from it later.

Can anyone help?



Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 51
Posts: 3438
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

discoverOneWireDevices populates the addr variable with each address in turn. Use memcpy in the while loop to copy those addresses to a global array of addresses.

This is problematic though because if you have multiple devices on a bus, you can find the addresses of each of them, but you will have no idea which is which. If they're all doing the same job, perhaps that doesn't matter, but if you're hoping to monitor kitchen temp, basement temp, attic temp, you have a problem.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 102
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can test them before plug them in final version so you have all addresses and can set: X addr is kitchen, Y is bathroom.... Save that values in eeprom and check them any time arduino reset or power off-on

I guess, address are always the same, aren't them?
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12487
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I guess, address are always the same, aren't them?
yes!

There are two strategies, (1) is hard-coding them by there internal address or (2) use one digitalpin per sensor (OK you can use a multiplexer tricks too)

If you have pins to spare (2) is the easiest option imho
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Full Member
***
Karma: 0
Posts: 111
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I found this page that shows a sketch that does what I wanted.

Thanks for you help guys.

I will of course need to put the sensors in order from lowest address to highest ( or do that via code) but that is not an issue.

http://www.vwlowen.co.uk/arduino/ds18b20/ds18b20.htm
Logged

Pages: [1]   Go Up
Jump to: