2

I'm using the raspberry pi (model B) with the DS18B20 to read temperature. I connected 9 sensors through the 1wire (port 4), however I'm having a few sensors with a weird problem.

The sensors disappear and come back in a few minutes, also I have removed some sensors but nothing change.

I'm using the normal connection (VCC with 4.7k through the line data and GND/VCC 3.3v (external supply) connected, each sensor has around 3m of cable.

Does any one had the same problem?

I'm thinking to buy the i2c -> 1wire (https://www.abelectronics.co.uk/products/3/Raspberry-Pi/27/29/1-Wire-Pi) does any one recommend it?

Is there any other solution to read temperature using 9 digital sensors?

crasic
  • 3,033
  • 1
  • 11
  • 20
Canela
  • 21
  • 3

2 Answers2

1

this is answered here.

the ideal way to read multiple sensor is use I2C sensors.

this is the only way you can chain multiple sensors together or you can use analog sensors but they will take lot of analog pins but i2c will use only 2 lines. lets say you are using Pi2/3, then i will suggest get a raspberry Pi hat which has I2C port so that you can connect all your i2c devices with Pi within seconds and it will make sure your hardware is correct.

now you have the Pi with an I2C adpter let move on the sensor part. TI,AD,NXP,freescale and lot of other companies make temp sensor with I2C but you want to connect more then one sensor so there are two options.

get 6 different different I2C sensors with different different I2C address, if you have two sensors with same address it wont work. you can get sensors with address line and just change address and you can connect them with Pi without any address conflict. i will suggest use this TMP 100 sensor i prefer this one because it has 2 address line with floating address line support so you can hookup 6 sensor with one i2c line. there are advantage of using same sensors are that you dont have to read 6 datasheet to write your code you will need to study one datasheet and write the code its way easy. if your all sensors are same then you will have better results to compare.

bruce
  • 461
  • 2
  • 4
1

The problem here is that 1-wire uses a parasitic supply from the data line. This means there is a fanout limit, or max number of devices on the bus that is determined by the total current draw of your devices and proportional the pull-up resistor and the supply voltage.

In this case, your system has a maximum fanout of 7 devices (calculated below), and you are powering 9, the best solution is to decrease the value of the pull-up resistor to say, 1k

Additionally, it is prefered with 1-wire to use a daisy chain and not long parallel wires. Using 3m cables to distant sensors adds significant capacitance to the line. To compensate this, a smaller pull-up resistor can be used as well.

How to calculate the fanout of 1-wire bus

Each device, during phantom power phase, will draw a maximum of 15uA. Therefore for our estimates, the total current draw is the number of devices times 15uA.

The the maximum fanout is when the total current reduces the supply voltage to <2.8V through our Pull-Up resistor.

CURRENT_LIMIT=(VDD-2.8)/(R_PU)

FANOUT=CURRENT_LIMIT/15uA

If we take your 3.3V supply with 4.7K, we can calculate

FANOUT=(3.3-2.8)/(4.7)*1/(0.015)= 7

Which means 9 devices is beyond the fan-out limit of the bus in your configuration.

The best option here is to reduce the value of the P-U resistor to 1k in order to achieve a limit of 30 devices on the 1-wire bus. This will increase the consumption of the 1-wire bus from ~1mA to ~5ma, not very significant in powered applications.

More Concerns

When running sensors on long parallel cables, then there is additional capacitance on the line, this will reduce the maximum speed of communication determined by the slew rate . In the worst case If you have 10nF for parasitic supply storage, and say 10nF more with 9 parallel cables at 3m each (using ~100pf/ft), with 4.7K, we calculate T=1/R*C=100uS, which means that the maximum rate of communication on a bus is 5KHZ or less. .

This is the worst case, so you may get away with faster rates, but you will have intermittent connection occasionally.

crasic
  • 3,033
  • 1
  • 11
  • 20