We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you've provided to them or that they've collected from your use of their services.

Extending the range of 1-Wire network (DS2482)

Connecting the 1-wire sensors directly to the RPi does allow to test various concepts... I does not, however, suffices the needs of home automation.  There are two reasons:

  • Connecting the sensors directly to the RPi pins is risky - it can lead to damaging the RPi itself,
  • The pins do not provide sufficient current to power and extensive network with many sensors.

To check if a RPi-based system can at all fit my automation needs, I have built 2 testing modules based on Maxim's DS2382-100 and DS2382-800.

DS2482-100 board DS2482-800 board

All that you see here is an effect of mixing and digesting examples found on the net.  I have repeatedly concluded that I have not clue about what I am doing.  At the end, however, I have managed to design and make a PCB, solder the elements and run the modules.  Nevertheless - beware! ...and if you find errors, please let me know.

The first step was making a PCB project.  On the www.temperatur.nu forum I have found an scheme of  an example RPi extension. One can also buy a ready board at www.m.nu. Looking through the pictures and analyzing the list of the elements I managed to 'decode' what fits into what.  Don't laugh.  This is the first time I ever noticed that there is a difference between a capacitor and a resistor.  Designs found at www.abelectronics.co.uk. helped a lot.  Finally my schemes look as follows:

DS2482-100 schemeDS2482-800 scheme

In case of the board using DS2482-100 I have decided to provide pins (here – SV1), which allow changing the I2C address. Such a possibility should - if needed - use more than one module at the same time.


I have spent a lot of time thinking, how all the wires should be connected.  Should the modules be powered through a microUSB plug, should I use RJ.. plug for I2C.  At the end I chose screw terminals.  They fit well to all the rest of connections around.

Here are the images of my boards:

DS2482-100_board_layoutDS2482-800_board_layout

The photos of boards shown at the beginning differ slightly from the images above.  I have found and corrected some errors.  As an example - the P6E6.8A has been replaced by SMBJ6.0A, which was unavailable to me at the time of first soldering.


The boards in the DIN cases look as follows:

DS2482-100 board in case DS2482-800 board in case

 

All who - similar to me - have had fear for soldering should know that making a PCB is extremely easy and very rewarding.  The boards you see above are the first in my life.  A thin soldering wire, borrowed iron, half an hour spend watching the EEVBlog... and that's it.  The whole thing is not hard at all... and the joy of entering a mysterious terrain of electronics is priceless (even if one does not understand everything...).

The modules you see above are powered from an external 5VDC source.  The 1-wire communication and GND are protected with DS9503P.  The 5VDC wire powering the 1-wire network is protected with a polyfuse (1206L050YR) and a transil diode (SMBJ6.0A).


In order to test the capacity of the modules I still need to build the network - i.e. place the sensors around my house.

Now a bit of theory and programming. DS2482 are bridges between I2C and 1-wire networks.  On the side of the RPi the pins 1 (3.3VDC), 3, 5 (SDA and SCL of I2C) and 6 (GND) are used.  It is also necessary to install software related to I2C itself and changing the scripts.  The Rpi should no longer control the 1-wire communication by itself (through GPIO4) but should use the I2C instead.  The needed commands are:


nano /etc/modprobe.d/raspi-blacklist.conf


and adding „#” before „blacklist i2c-bcm2708”, then:


nano /etc/modules


and adding at the bottom  „i2c-dev”. In the next step install the tools related to I2C:


apt-get install i2c-tools


After you restart your RPI and enter:


i2cdetect -y 1


you should see a table showing the found devices which use I2C.


For OWFS to read sensors connected to DS2482 you need:

 

  • Install OWFS by entering: apt-get install owfs ow-shell,
  • Create a directory by entering mkdir /mnt/1wire,
  • Check if in  /etc/fuse.conf the line "user_allow_other” is free from „#” in front,
  • Run OWFS by:


/opt/owfs/bin/owfs --i2c=ALL:ALL --allow_other /mnt/1wire/

(owfs might install into other directory like: /usr/bin/owfs)

The found DS2482 bridges and sensors can be found in the /mnt/1-wire directory.

You will be better off reading and following a great tutorial presented at http://wiki.temperatur.nu.

 

On the PHP side It was necessary to modify the scripts:

<?php
if ($MainDir = opendir('/mnt/1wire/bus.0')) {
	while (false !==($MainDirItem = readdir($MainDir))){
		if (preg_match('/[0-9]{2}./', $MainDirItem)) {
			$TempFile = fopen("/mnt/1wire/$MainDirItem/temperature", "r");
			if (!$TempFile) {
				echo "...some problems with temp. file opening...";
			}
			else {
				$Temperature = fgets($TempFile);
				echo "Temperature of ".$MainDirItem." = ";
				echo $Temperature."°C";
			}
		}
	}
}

So much for now.  If you are interested in making a PCB, please take a look at Appendix 1 - making a PCB.