Tuesday, October 20, 2009

Wire length

I got comment from Stephane about wanting to know, how long CAT5E ethernet cable can be used. Well, I just bought a 100 meters (328 feet) of wire. Not CAT5E ethernet cable, but 4 wire flat telephone cable. I connected one temperature sensor DS18S20 at one end and DS9490R USB adapter to another. Under /media/1wire/ folder I got new folder "10.BCD8ED010800" and I got even a reading from it.
$ cat /media/1wire/10.BCD8ED010800/temperature
23.375
$ cat /media/1wire/10.BCD8ED010800/power
0

power file shows that it's powered parasitically.

I don't know how many sensors I can connect to 100 meeter cable before I have to add additional power, but if I got reading from 100 meeter cable, then I am sure I get readings of many sensors with external power. Just found guidelines page. In my case, I probably need total of 50 meters of wiring.

Thursday, October 8, 2009

Reading 2 sensors

So, I have connected 2 sensors and reading these for about 5 days now. One is outside the window (yellow) and another is connected to radiator (red). I made even a script that reads sensors every 10 minutes and sends reading over internet to public net and saves it to MySQL database. And using XML/SWF Charts, I can see live chart on readings. First problem I noticed right away is outside sensor. Currently here in Estonia, outside air temperature is around 10°C, but sometimes sun comes out and heats outside sensor up to about 25°C. That means that I have to find some better place for this sensor, where sun can't shine on it. Also, I think I should rewrite my script so that when reading outside sensor, then on saving it to database, It should save average value of current and last two readings.
Here is another chart, where temp1 is live reading of outside temperature and temp2 is average of last 3 readings. As you can see, temp2 is little bit smoother.

About my radiators, I found out that they are switched off for night. Every day 23:10, they are turned off and temperature starts to fall. And from 6:10 they are turned on and temperature rapidly raises. I am thinking that if I want some more energy efficiency, then I would also turn off radiators from 9:00 on working days and turn them on on 16:00, about hour before I'm home.

Thursday, October 1, 2009

first readings


So, Yesterday I installed owfs and got first read. I made a little script that read sensor every 15 minutes and wrote it to file. Here is my living-room temperature from 22:00 30.09.2009 to 18:30 01.10.2009.
I took out my old laptop, about 5-6 year old with 1,2GHz and 256MB RAM. Useless for everyday use, perfect for server type use. Currently it has some kind of Windows installed, but I found live CD with owfs. ISO file is less then 50MB and I have to say that it worked quite well, but I will probably find something better to install.

Wednesday, September 30, 2009

Installing 1-wire USB adapter DS9490R on Ubuntu 9.04

OK, let's install DS9490R 1-wire USB adapter on Ubuntu 9.04. Connecting adapter to my laptop, shows dmesg this:

$ dmesg
[1553881.079000] Driver for 1-wire Dallas network protocol.
[1553881.121233] usbcore: registered new interface driver DS9490R
[1553882.700959] w1_master_driver w1_bus_master1: Family 81 for 81.0000002d0f1d.39 is not registered.


I choosed a owfs to read sensors. To install it, I use Tomasz Korwel's guide.

1. Let's install packages needed for compiling owfs.

# apt-get install automake autoconf autotools-dev gcc g++ libtool libusb-dev fuse-utils libfuse-dev swig python2.4-dev tcl8.4-dev php5-dev


2. Download, extract and compile owfs

Download owfs from owfs Source Force download page. Extract it. Open terminal and cd into directory where owfs-2.7p26.tar.gz (or whatever version you download) was extracted.


$ cd Desktop/
$ cd owfs-2.7p26/
$ ./configure


If you get after ./configure something like this:


Current configuration:

Deployment location: /opt/owfs

Compile-time options:
Caching is enabled
USB is enabled
I2C is enabled
HA7Net is enabled
W1 is enabled
Multithreading is enabled
Parallel port DS1410E is enabled
TAI8570 barometer is enabled
Thermocouple is enabled
Zeroconf/Bonjour is enabled
Debug-output is enabled
Profiling is DISABLED

Module configuration:
owlib is enabled
owshell is enabled
owfs is enabled
owhttpd is enabled
owftpd is enabled
owserver is enabled
ownet is enabled
ownetlib is enabled
owtap is enabled
owside is enabled
owmon is enabled
owcapi is enabled
swig is enabled
owperl is enabled
owphp is DISABLED
owpython is enabled
owtcl is enabled

...where USB is enabled, then it's all OK.

Now, let's compile and install it.

$ make
$ sudo make install


If everything went well, then software should be installed. Let's try out.

$ sudo mkdir /media/1-wire
$ sudo /opt/owfs/bin/owfs --allow_other -u /media/1-wire
DEFAULT: ow_ds9490.c:DS9490_sub_open(552) Opened USB DS9490 adapter at 002/009.
DEFAULT: ow_ds9490.c:DS9490_detect_found(412) Set DS9490 002/009 unique id to 81 1D 0F 2D 00 00 00 39

-u key means USB and "/media/1-wire" is mountpoint and --allow_other means that non-root users can read 1-wire directory.
So, if you can see something like this in 1-wire folder...

$ ls -lah 1-wire
drwxr-xr-x 1 root root 8 2009-09-30 20:38 .
drwxr-xr-x 7 root root 4096 2009-09-30 20:30 ..
drwxrwxrwx 1 root root 8 2009-09-30 20:39 81.1D0F2D000000
drwxr-xr-x 1 root root 8 2009-09-30 20:38 bus.0
drwxr-xr-x 1 root root 8 2009-09-30 20:38 settings
drwxr-xr-x 1 root root 8 2009-09-30 20:38 statistics
drwxr-xr-x 1 root root 30 2009-09-30 20:38 structure
drwxr-xr-x 1 root root 8 2009-09-30 20:38 system
drwxr-xr-x 1 root root 8 2009-09-30 20:38 uncached

... then software is installed and you can proceed to hardware.

Now, let's try to connect hardware. A temperature sensor DS18S20. I wired it to use a parasite power. That means that I only use 2 wires, ground and data, and power comes also from data wire. Anyway, connect RJ11 to adapter and wait a little bit and look at 1-wire folder again.

$ ls -lah 1-wire
drwxr-xr-x 1 root root 8 2009-09-30 21:12 .
drwxr-xr-x 7 root root 4096 2009-09-30 20:30 ..
drwxrwxrwx 1 root root 8 2009-09-30 21:22 10.0FC3ED010800
drwxrwxrwx 1 root root 8 2009-09-30 21:22 81.1D0F2D000000
drwxr-xr-x 1 root root 8 2009-09-30 21:12 alarm
drwxr-xr-x 1 root root 8 2009-09-30 21:12 bus.0
drwxr-xr-x 1 root root 8 2009-09-30 21:12 settings
drwxrwxrwx 1 root root 8 2009-09-30 21:22 simultaneous
drwxr-xr-x 1 root root 8 2009-09-30 21:12 statistics
drwxr-xr-x 1 root root 30 2009-09-30 21:12 structure
drwxr-xr-x 1 root root 8 2009-09-30 21:12 system
drwxr-xr-x 1 root root 8 2009-09-30 21:12 uncached

As you can see, there is now new folder - 10.0FC3ED010800. This is my DS18S20 sensor. In this folder, there is temperature file. In that file, there is a temperature in celsius.

$ cat 1-wire/10.0FC3ED010800/temperature
20.0625

And putting sensor in front of my laptop fan, I get reading...

$ cat 1-wire/10.0FC3ED010800/temperature
45.5

I noticed that this file is always 12 bytes long, numbers is aligned to rights and it does not have new-line character at the end.

So, next thing is to create a script that will log a temperature reading and I will try to do a nice graph of it.

package arrived!

My first order from Hobby Boards online store arrived! I ordered a 1-Wire USB Adaptor and 6 1-Wire Digital Thermometer DS18S20. Hobby Boards is located in Birmingham, Alabama, USA and I am in Tallinn, Estonia and it took about week to get here.

Thursday, September 24, 2009

for starters…

I had this idea of automating my home for a long time now and finally I ordered first pieces to start playing with them. So it's great time to start blogging about it.

What I have in mind? Well... nothing mind-blowing. A while ago I discovered great way to put lots of sensors around apartment and connect them with wires so there won't be any need to demolish my apartment to hide all wires. It's 1-wire. When reading sensors from computer I don't need device with multiple I/O ports to read all sensors. I need 1-wire USB adapter DS9490R to read all sensors from 1 wire. First step would be to put temperature sensors to every room to measure room temperature and radiator temperate. After that it would be nice to have ability to regulate radiators automatically somehow. Also I have a cat now and I am thinking of some-kind of computer controlled cat feeder. Actually, I have lot's of ideas but let's start with the easiest parts and let's see, how things are working out.