Software Install -One Wire File System [owfs]
These instructions should get the 1wire web interface functioning so that you can see any sensor connected to the 1wire bus from your windows machine using firefox or IE.
It does not cover how to setup the ethernet port as a fixed IP address etc however the initial sdcard image is already setup up dhcp so your home router will issue an ip address and get your raspberryPi connected to the web automatically. You should probably look at a fixed IP address and port forwarding however suggest you get owfs installed and running first as this is the most complex hardware/software section in getting the RPi monitoring data. Everything after this is just how you use the owfs data.
Software References
http://www.raspberrypi.org/downloads
http://wiki.temperatur.nu/index.php/OWFS_with_i2c_support_on_Raspberry_Pi_(English_version)
http://www.abelectronics.co.uk/owfs-and-compi/info.aspx
http://owfs.org/
General Notes
Windows : Instead of having a screen and keyboard connected to the RaspberryPi you can log into the RPi with a ssh client from a windows machine. This entire writeup only uses the command prompt and not the RPi desktop. You NEED putty on a windows machine that way you can simply cut and paste commands = not too much typing.
Putty.
To copy from windows (ie a command from this writeup) to putty
Windows support packages
You will need :
The hardware setup is quite easy.
Its very easy to create an SDcard for the raspberrypi. Simply use a program called Win32DiskImager.exe and write an image to an sdcard. The program and image is available from the Raspberrypi downloads page.
I used the following image: 2013-02-09-wheezy-raspbian.img
First Boot (time 5 minutes)
This is the only time I connect a screen and keyboard to the Raspberrypi.
Initial power-up will show a menu, I set the following:
When you have completed this you will end up at a command prompt. Maybe a good idea to find the Rpi IP address so you can then use a putty client to log in and complete the rest of the setup using a windows machine.
root@raspberrypi:~# ifconfig
Will show you the assigned IP address.
NETWORK (@Clownfishy)
Although this guide does not go into network setup (better done elsewhere) a few tips may assist if using the nano style USB wifi adpaters
Enable Re-connect
By default the WiFi will not try and reconnect to your router if it drops the connections. Create a new script containing the commands below and run it in the background which will continually check for dropouts and reconnect if a drop is detected -
Turn Off Power Saving
Add the following line to your interfaces file as the USB Wfif adapter can auto powerdown
wireless-power off
Setup I2C (time 2 minutes)
pi@raspberrypi:~# sudo -i
root@raspberrypi:~# nano /etc/modprobe.d/raspi-blacklist.conf
You need to add “#” before this line: blacklist i2c-bcm2708
root@raspberrypi:~# nano /etc/modules
add new line containing only the following 7 characters i2c-dev
Raspberrypi I2C Port Numbers
There is a difference between models sold before OCt 2012 when it comes to the I2C ports. Although the physical GPIO connections are the same I think they have added another port for maybe a camera or something, really do not know.
Raspberrypi GPIO Sold before October 2012 uses I2C port: 0
Raspberrypi Style A or B GPIO uses I2C port: 1
Install The 1wire support packages including I2C-tools (time 15 minutes)
root@raspberrypi:~# apt-get install automake autoconf autotools-dev gcc-4.7 libtool libusb-dev libfuse-dev swig python2.6-dev tcl8.4-dev php5-dev i2c-tools
Reboot and test I2C interface is working
Having the 1wire board connected onto the RPi we can see if the 1wire I2C 1wire bus master is recognized. Each I2C device has an address so simply scanning the I2C addresses should show the DS2482-100 which is used in these 1wire expansion modules. The response below shows the DS2482-100 is at address 18.
root@raspberrypi:/etc/init.d# shutdown -r now
pi@raspberrypi:~# sudo -i
root@raspberrypi:/etc/init.d# i2cdetect -y 1 (use "i2cdetect -y 0" for older boards)
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Do not go past this step until the 1wire board is recognised and you know I2C bus is running. The 1wire board connected to the RPi is at I2C address 18. You do not need to remember this the owfs software automatically finds the I2C bus master.
TEMPERATURE SENSORS
Install OneWireFileSystem OWFS (Time 40 minutes)
The link below uses the owfs version 2.8p17. I like this version as its been rock solid over the last 6 months. I did try the "latest version" however it did not work so went back to 2.8p17.
pi@raspberrypi:~# sudo -i
root@raspberrypi:~# cd /usr/src
root@raspberrypi:~# wget http://downloads.sourceforge.net/project/owfs/owfs/2.8p17/owfs-2.8p17.tar.gz
root@raspberrypi:~# tar zxvf owfs-2.8p17.tar.gz
root@raspberrypi:~# cd owfs-2.8p17
root@raspberrypi:~# ./configure (takes about 3 minutes)
root@raspberrypi:~# make (takes about 30 minutes)
root@raspberrypi:~# make install (takes about 2 minutes
Install startup script so owfs starts automatically
OWFS has a number of programs associated / available with it. I suggest you only start owserver and the web interface owhttpd. You can also try the fuse file system however get the above two services running first before messing around with fuses virtual file system stuff. The web interface provided by owhttpd is way better for testing.
owserver: you specify the port it will transmit on "-p 3001" coupled with the interface to connect to. OWFS can use serial, usb or I2C. In our instance we use the I2C interface and we start the server up at port 3001.
owhttpd : You specify the server to connect to via a port number -s 3001 and the port the web interface will respond to -p 3002
Create the startup script
root@raspberrypi:~# cd /etc/init.d
root@raspberrypi:/etc/init.d# nano startAquaPi.sh
Paste the follow text into the file startAquaPi.sh:
The reference to the stty command is to setup the serial port for later connect to the Atlas Scientific pH and orp devices. Easier to add this now than go back at a later stage and edit this file. There is a couple more edits required to get the serial port running for Atlas serial devices so will add this section later.
IMPORTANT
Older boards you need to change the owserver line above to use I2C port 0
/opt/owfs/bin/owserver -p 3001 --i2c=/dev/i2c-0:ALL
root@raspberrypi:/etc/init.d# chmod +x startAquaPi.sh
root@raspberrypi:/etc/init.d# update-rc.d startAquaPi.sh defaults
Manual starting of the owfs server (Should not be required just use the startup method above)
I hope I do not confuse people here however there is nothing stopping you manually starting owserver and owhttpd by simply issuing /opt/owfs/bin/owserver -p 3001 --i2c=/dev/i2c-1:ALL and /opt/owfs/bin/owhttpd -s 3001 -p 3002 on the command line. In fact any startup script simply types their commands for you when raspberrypi boots. However you can only have 1 instance of owserver and owhttpd running so do not install the startup script and then try and issue these start up commands manually without first stopping the programs if they are running. To see what programs are currently running
pi@raspberrypi ~ $ sudo -i
root@raspberrypi:~# ps -el
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
1 S 0 2023 1 0 80 0 - 11047 poll_s ? 00:00:02 owserver
1 S 0 2026 1 0 80 0 - 4905 poll_s ? 00:00:00 owhttpd
to stop a program use the kill command followed by the program number (PID) you want to kill.
root@raspberrypi:~# kill xxxx In the case above xxxx = 2023 and 2026 to kill both owfs services
Test owfs is functioning
We use the built in web interface owfs provides. There is NO need for apache at this stage.
reboot raspberrypi and make sure your still plugged into your home network
root@raspberrypi:/etc/init.d# shutdown -r now
From your windows machine go into firefox or internet explore and type into the address bar
192.168.x.x:3002 (replace x.x with your RPi address and you should see the owfs interface.
If you got this far owfs is installed successfully. :) From this interface any sensor you attach to the 1wire interface will be automatically shown in the list together with all its parameters. No further owfs install or programming is required. Thus the simplicity of 1wire. The next section plugging in your first sensor.
Connecting the Temperature Sensors
I am going to connect three temperature sensors which use the dallas 18B20 device. I purchased the units from littlebird as they are very well sealed however you can make your own.
1wire interface board
[Broken External Image]:http://www.abelectronics.co.uk/docs/stock/raspberrypi/1wirepi/1wire-1.jpg[Broken External Image]:http://www.abelectronics.co.uk/docs/stock/raspberrypi/1wirepi/1wire-4.jpg
Wiring (water proof temperature sensor)
The 1wire board includes an ESD suppression device on both the data line (OW) and the negative line (RT) Thus the sensor negative is better connected to the RT terminal. All 1wire devices are just connected in parallel so you will have to connect all sensor cables together
Sensor 1Wire Board
Red -> 5VDC (Supply +ve)
Black -> RT (Return -ve)
White -> OW (1wire Data)
Display the Sensor Data
Just type again 192.168.x.x:3002 in firefox or IE as per the testing phase above. Calling up the web interface shows the following main display, choose a sensor (the DS18B20 temperature sensor ID always start with 28.xx).
OK if you have reached here you have successfully installed owfs and can call up any 1wire connected sensor. (There are lots of different 1wire sensors available) You can run it like this until we get an interface installed which I will need another couple of weeks before I have time to write it up.
You need to label your sensors with their respective addresses 28.xxxxxxx as you will need to know the ID when it comes time to read the data via a script instead of looking at the web interface. The script will read the temperatures via owserver and push the data into a user defined web page.
Hardware and software are now installed and verified for 1wire devices. This data will be used in a bash script in the section "Logging Data".
HUMIDITY SENSORS
Using a DHT22 sensor it is easy to get the temperature and humidity values. Adafruit have written a small program where you specify the pin and sensor type and it returns the values of temperature and humidity. Wiring is as per the link below, remember to use 3.3V and NOT 5VDC
Accuracy: I do not know how accurate it is, I would trust a 1wire DS18B20 temperature sensor more than this device however its a cheap way of getting humidity. Real world results, 3xDS18B20 connected to the RPi and the DHT22 -1wire sensors data 21.5,21.6,21.8 DHT22 was showing 22.1
Usage: I will probably use this to sense the house humidity & temps, then look at relationships to the qty of ATO I am using.
Connecting the DHT22 Sensor
The sensor is easily connected to a GPIO pin on the RPi. adafruit DHT11/22 wiring
Pin 1 3.3V
Pin 2 Data -> GPIO pin 4 (or other pin, you can choose)
Pin 4 Gnd
Pullup Resistor. You need to place a 4.7k resister between the data line and the 3.3V. I just soldered this at the sensor wires and used heat shrink to neaten it up.
Software install (Time 5 minutes)
Reference : adafruit.DHT11/22 software-install
Install Tips:
Make sure your in the directory where you want to save the adafruit programs before git clone.
pi@raspberrypi ~ $ sudo -i
root@raspberrypi:# cd (to a place where you want to save the program)
root@raspberrypi:# apt-get install git-core
root@raspberrypi:# git clone git://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
root@raspberrypi:# cd Adafruit-Raspberry-Pi-Python-Code
root@raspberrypi:# cd Adafruit_DHT_Driver
Now issue the command to interrogate the device which is type 22 on pin 4
root@raspberrypi:# ./Adafruit_DHT 22 4
Using pin #4
Data (40): 0x1 0xfd 0x0 0xdb 0xd9
Temp = 21.9 *C, Hum = 50.9 %
root@raspberrypi:#
Now try the following
root@raspberrypi:# ./Adafruit_DHT 22 4 | grep "Temp" | cut -f4,8 -d " "
21.9 50.9
root@raspberrypi:#
The above command pipes the results to grep, finds a line starting with Temp which in turn pipes the results to cut, which separates the line into fields by using a space " " and returns the 4th and 8th field.
Hardware and software are now installed and verified for HDT22 Humidity device. This data will be used in a bash script in the section "Logging Data"
The atlas scientific devices use a serial connection for communications. I have the pH, orp and the flow board and use a 3rd party flow sensor for $10.00. (BTW The flow sensor is monitoring my ATO). Each Atlas device needs its own serial connection as they are not addressable. As the RPi only has 1 serial port you need to be able to switch this serial port between multiple devices. Atlas has recognised this and created a serial port connector board which allows up to 4 devices to share a single serial port. (i.e. 4 port multiplexor) This board connects to the RPi serial tx/rx and also uses two digital outputs to allow you to select which of its 4 devices you wish to communicate to.
The Atlas devices use TTL level 3.3 - 5VDC for its serial port which is the level of the RPi GPIO pins. Do NOT connect these devices direct to your PC's serial port or a max232 chip (+/- ~15v)
Thus for multiple Atlas devices you need to setup the software for a couple of things:
Reference: abelectronics.co.uk
Install GPIO Library
Reference: WiringPi
Simple GPIO Test
You Will need to test that you can actually control the GPIO pins. Suggest you get a single LED with say a 370ohm resistor and connect it between the GPIO PIN and GND to the pin you want to test. Make sure you can turn on / off the GPIO pins. These "output" pins will be connected onto the Atlas serial port board to enable selecting which device the RPi will communicate to.
To test the GPIO pins I would use the command line options below. This is also the commands used within the script we shall use to eventually read the Atlas devices with.
pi@raspberrypi ~ $ sudo -i
root@raspberrypi:~# gpio -g mode 17 out
root@raspberrypi:~# gpio -g write 17 1 (turn ON)
root@raspberrypi:~# gpio -g write 17 0 (turn OFF)
Do NOT continue until you can prove you can switch on/off at least two outputs (GPIO 17 & 18) and you know the corresponding physical GPIO pins.
Connection of the Hardware
Reference: Atlas document for connection diagram, Atlas Serial board
Note. As the GPIO pins run at 3.3VDC it is important to run the Atlas serial board and sensors at 3.3V. There are Atlas boards, (I think conductivity) that need 5VDC so you would need some additional electronics or level shifter to convert the 5V to 3.3V. The only GPIO pin that would cause issues is the serial receive pin of the RPi..
TBA
Logging Data
These instructions should get the 1wire web interface functioning so that you can see any sensor connected to the 1wire bus from your windows machine using firefox or IE.
It does not cover how to setup the ethernet port as a fixed IP address etc however the initial sdcard image is already setup up dhcp so your home router will issue an ip address and get your raspberryPi connected to the web automatically. You should probably look at a fixed IP address and port forwarding however suggest you get owfs installed and running first as this is the most complex hardware/software section in getting the RPi monitoring data. Everything after this is just how you use the owfs data.
Software References
http://www.raspberrypi.org/downloads
http://wiki.temperatur.nu/index.php/OWFS_with_i2c_support_on_Raspberry_Pi_(English_version)
http://www.abelectronics.co.uk/owfs-and-compi/info.aspx
http://owfs.org/
General Notes
Windows : Instead of having a screen and keyboard connected to the RaspberryPi you can log into the RPi with a ssh client from a windows machine. This entire writeup only uses the command prompt and not the RPi desktop. You NEED putty on a windows machine that way you can simply cut and paste commands = not too much typing.
Putty.
To copy from windows (ie a command from this writeup) to putty
- copy the text to the windows clipboard, standard windows stuff
- in the putty window right click the mouse button pastes onto the command line.
- swipe the text to highlight it in putty (no need to click anything here just highlight it
- in windows then simple use "paste" into your document
Windows support packages
You will need :
- Win32DiskImager to write the initial image to the SDcard
- putty open source secure shell client to log into Raspberrypi.
The hardware setup is quite easy.
- The standard 5VDC power supply connected to the RPi
- Keyboard and monitor only needed for the first boot-up
- Ethernet cable connected to your router
- 1wire board simply plugged into the GPIO header (let RPi power it)
- at least one DS18B20 temperature sensor
Its very easy to create an SDcard for the raspberrypi. Simply use a program called Win32DiskImager.exe and write an image to an sdcard. The program and image is available from the Raspberrypi downloads page.
I used the following image: 2013-02-09-wheezy-raspbian.img
First Boot (time 5 minutes)
This is the only time I connect a screen and keyboard to the Raspberrypi.
Initial power-up will show a menu, I set the following:
- Change password
- Change timezone
- Enable ssh
- Expand root partition
- Update
When you have completed this you will end up at a command prompt. Maybe a good idea to find the Rpi IP address so you can then use a putty client to log in and complete the rest of the setup using a windows machine.
root@raspberrypi:~# ifconfig
Will show you the assigned IP address.
NETWORK (@Clownfishy)
Although this guide does not go into network setup (better done elsewhere) a few tips may assist if using the nano style USB wifi adpaters
Enable Re-connect
By default the WiFi will not try and reconnect to your router if it drops the connections. Create a new script containing the commands below and run it in the background which will continually check for dropouts and reconnect if a drop is detected -
Code:
#!/bin/bash
while true ; do
if ifconfig wlan0 | grep -q "inet addr:"
then
sleep 60
else
echo "Network connection down! Attempting reconnection."
ifup --force wlan0
sleep 10
fi
done
Turn Off Power Saving
Add the following line to your interfaces file as the USB Wfif adapter can auto powerdown
wireless-power off
Setup I2C (time 2 minutes)
pi@raspberrypi:~# sudo -i
root@raspberrypi:~# nano /etc/modprobe.d/raspi-blacklist.conf
You need to add “#” before this line: blacklist i2c-bcm2708
root@raspberrypi:~# nano /etc/modules
add new line containing only the following 7 characters i2c-dev
Raspberrypi I2C Port Numbers
There is a difference between models sold before OCt 2012 when it comes to the I2C ports. Although the physical GPIO connections are the same I think they have added another port for maybe a camera or something, really do not know.
Raspberrypi GPIO Sold before October 2012 uses I2C port: 0
Raspberrypi Style A or B GPIO uses I2C port: 1
Install The 1wire support packages including I2C-tools (time 15 minutes)
root@raspberrypi:~# apt-get install automake autoconf autotools-dev gcc-4.7 libtool libusb-dev libfuse-dev swig python2.6-dev tcl8.4-dev php5-dev i2c-tools
Reboot and test I2C interface is working
Having the 1wire board connected onto the RPi we can see if the 1wire I2C 1wire bus master is recognized. Each I2C device has an address so simply scanning the I2C addresses should show the DS2482-100 which is used in these 1wire expansion modules. The response below shows the DS2482-100 is at address 18.
root@raspberrypi:/etc/init.d# shutdown -r now
pi@raspberrypi:~# sudo -i
root@raspberrypi:/etc/init.d# i2cdetect -y 1 (use "i2cdetect -y 0" for older boards)
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Do not go past this step until the 1wire board is recognised and you know I2C bus is running. The 1wire board connected to the RPi is at I2C address 18. You do not need to remember this the owfs software automatically finds the I2C bus master.
TEMPERATURE SENSORS
Install OneWireFileSystem OWFS (Time 40 minutes)
The link below uses the owfs version 2.8p17. I like this version as its been rock solid over the last 6 months. I did try the "latest version" however it did not work so went back to 2.8p17.
pi@raspberrypi:~# sudo -i
root@raspberrypi:~# cd /usr/src
root@raspberrypi:~# wget http://downloads.sourceforge.net/project/owfs/owfs/2.8p17/owfs-2.8p17.tar.gz
root@raspberrypi:~# tar zxvf owfs-2.8p17.tar.gz
root@raspberrypi:~# cd owfs-2.8p17
root@raspberrypi:~# ./configure (takes about 3 minutes)
root@raspberrypi:~# make (takes about 30 minutes)
root@raspberrypi:~# make install (takes about 2 minutes
Install startup script so owfs starts automatically
OWFS has a number of programs associated / available with it. I suggest you only start owserver and the web interface owhttpd. You can also try the fuse file system however get the above two services running first before messing around with fuses virtual file system stuff. The web interface provided by owhttpd is way better for testing.
owserver: you specify the port it will transmit on "-p 3001" coupled with the interface to connect to. OWFS can use serial, usb or I2C. In our instance we use the I2C interface and we start the server up at port 3001.
owhttpd : You specify the server to connect to via a port number -s 3001 and the port the web interface will respond to -p 3002
Create the startup script
root@raspberrypi:~# cd /etc/init.d
root@raspberrypi:/etc/init.d# nano startAquaPi.sh
Paste the follow text into the file startAquaPi.sh:
Code:
#!/bin/bash
### BEGIN INIT INFO
# Provides: startAquaPi
# Required-Start: $local_fs $syslog
# Required-Stop: $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start OWFS at boot time
# Description: Start OWFS at boot time
### END INIT INFO
# Starts OWFS
/opt/owfs/bin/owserver -p 3001 --i2c=/dev/i2c-1:ALL
/opt/owfs/bin/owhttpd -s 3001 -p 3002
# Setup Serial Port
stty -F /dev/ttyAMA0 raw 38400 cs8 -ignpar -cstopb eol 255 eof 255
IMPORTANT
Older boards you need to change the owserver line above to use I2C port 0
/opt/owfs/bin/owserver -p 3001 --i2c=/dev/i2c-0:ALL
root@raspberrypi:/etc/init.d# chmod +x startAquaPi.sh
root@raspberrypi:/etc/init.d# update-rc.d startAquaPi.sh defaults
Manual starting of the owfs server (Should not be required just use the startup method above)
I hope I do not confuse people here however there is nothing stopping you manually starting owserver and owhttpd by simply issuing /opt/owfs/bin/owserver -p 3001 --i2c=/dev/i2c-1:ALL and /opt/owfs/bin/owhttpd -s 3001 -p 3002 on the command line. In fact any startup script simply types their commands for you when raspberrypi boots. However you can only have 1 instance of owserver and owhttpd running so do not install the startup script and then try and issue these start up commands manually without first stopping the programs if they are running. To see what programs are currently running
pi@raspberrypi ~ $ sudo -i
root@raspberrypi:~# ps -el
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
1 S 0 2023 1 0 80 0 - 11047 poll_s ? 00:00:02 owserver
1 S 0 2026 1 0 80 0 - 4905 poll_s ? 00:00:00 owhttpd
to stop a program use the kill command followed by the program number (PID) you want to kill.
root@raspberrypi:~# kill xxxx In the case above xxxx = 2023 and 2026 to kill both owfs services
Test owfs is functioning
We use the built in web interface owfs provides. There is NO need for apache at this stage.
reboot raspberrypi and make sure your still plugged into your home network
root@raspberrypi:/etc/init.d# shutdown -r now
From your windows machine go into firefox or internet explore and type into the address bar
192.168.x.x:3002 (replace x.x with your RPi address and you should see the owfs interface.
If you got this far owfs is installed successfully. :) From this interface any sensor you attach to the 1wire interface will be automatically shown in the list together with all its parameters. No further owfs install or programming is required. Thus the simplicity of 1wire. The next section plugging in your first sensor.
Connecting the Temperature Sensors
I am going to connect three temperature sensors which use the dallas 18B20 device. I purchased the units from littlebird as they are very well sealed however you can make your own.
- Strapped to Heater
- Display Tank Temperature (located ion sump)
- Ambient Temperature
1wire interface board
[Broken External Image]:http://www.abelectronics.co.uk/docs/stock/raspberrypi/1wirepi/1wire-1.jpg[Broken External Image]:http://www.abelectronics.co.uk/docs/stock/raspberrypi/1wirepi/1wire-4.jpg
Wiring (water proof temperature sensor)
The 1wire board includes an ESD suppression device on both the data line (OW) and the negative line (RT) Thus the sensor negative is better connected to the RT terminal. All 1wire devices are just connected in parallel so you will have to connect all sensor cables together
Sensor 1Wire Board
Red -> 5VDC (Supply +ve)
Black -> RT (Return -ve)
White -> OW (1wire Data)
Display the Sensor Data
Just type again 192.168.x.x:3002 in firefox or IE as per the testing phase above. Calling up the web interface shows the following main display, choose a sensor (the DS18B20 temperature sensor ID always start with 28.xx).
OK if you have reached here you have successfully installed owfs and can call up any 1wire connected sensor. (There are lots of different 1wire sensors available) You can run it like this until we get an interface installed which I will need another couple of weeks before I have time to write it up.
You need to label your sensors with their respective addresses 28.xxxxxxx as you will need to know the ID when it comes time to read the data via a script instead of looking at the web interface. The script will read the temperatures via owserver and push the data into a user defined web page.
Hardware and software are now installed and verified for 1wire devices. This data will be used in a bash script in the section "Logging Data".
HUMIDITY SENSORS
Using a DHT22 sensor it is easy to get the temperature and humidity values. Adafruit have written a small program where you specify the pin and sensor type and it returns the values of temperature and humidity. Wiring is as per the link below, remember to use 3.3V and NOT 5VDC
Accuracy: I do not know how accurate it is, I would trust a 1wire DS18B20 temperature sensor more than this device however its a cheap way of getting humidity. Real world results, 3xDS18B20 connected to the RPi and the DHT22 -1wire sensors data 21.5,21.6,21.8 DHT22 was showing 22.1
Usage: I will probably use this to sense the house humidity & temps, then look at relationships to the qty of ATO I am using.
Connecting the DHT22 Sensor
The sensor is easily connected to a GPIO pin on the RPi. adafruit DHT11/22 wiring
Pin 1 3.3V
Pin 2 Data -> GPIO pin 4 (or other pin, you can choose)
Pin 4 Gnd
Pullup Resistor. You need to place a 4.7k resister between the data line and the 3.3V. I just soldered this at the sensor wires and used heat shrink to neaten it up.
Software install (Time 5 minutes)
Reference : adafruit.DHT11/22 software-install
Install Tips:
Make sure your in the directory where you want to save the adafruit programs before git clone.
pi@raspberrypi ~ $ sudo -i
root@raspberrypi:# cd (to a place where you want to save the program)
root@raspberrypi:# apt-get install git-core
root@raspberrypi:# git clone git://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
root@raspberrypi:# cd Adafruit-Raspberry-Pi-Python-Code
root@raspberrypi:# cd Adafruit_DHT_Driver
Now issue the command to interrogate the device which is type 22 on pin 4
root@raspberrypi:# ./Adafruit_DHT 22 4
Using pin #4
Data (40): 0x1 0xfd 0x0 0xdb 0xd9
Temp = 21.9 *C, Hum = 50.9 %
root@raspberrypi:#
Now try the following
root@raspberrypi:# ./Adafruit_DHT 22 4 | grep "Temp" | cut -f4,8 -d " "
21.9 50.9
root@raspberrypi:#
The above command pipes the results to grep, finds a line starting with Temp which in turn pipes the results to cut, which separates the line into fields by using a space " " and returns the 4th and 8th field.
Hardware and software are now installed and verified for HDT22 Humidity device. This data will be used in a bash script in the section "Logging Data"
The following section is NOT completed
Enable Serial Port for connection to Atlas Scientific devicesThe atlas scientific devices use a serial connection for communications. I have the pH, orp and the flow board and use a 3rd party flow sensor for $10.00. (BTW The flow sensor is monitoring my ATO). Each Atlas device needs its own serial connection as they are not addressable. As the RPi only has 1 serial port you need to be able to switch this serial port between multiple devices. Atlas has recognised this and created a serial port connector board which allows up to 4 devices to share a single serial port. (i.e. 4 port multiplexor) This board connects to the RPi serial tx/rx and also uses two digital outputs to allow you to select which of its 4 devices you wish to communicate to.
The Atlas devices use TTL level 3.3 - 5VDC for its serial port which is the level of the RPi GPIO pins. Do NOT connect these devices direct to your PC's serial port or a max232 chip (+/- ~15v)
Thus for multiple Atlas devices you need to setup the software for a couple of things:
- Disable RPi using the serial port as its terminal and stop it sending messages to the port
- Enable the GPIO library so we can turn on/off some IO pins. Two command outputs will be required to the serial port connector board to switch between its devices.
Reference: abelectronics.co.uk
Install GPIO Library
Reference: WiringPi
Simple GPIO Test
You Will need to test that you can actually control the GPIO pins. Suggest you get a single LED with say a 370ohm resistor and connect it between the GPIO PIN and GND to the pin you want to test. Make sure you can turn on / off the GPIO pins. These "output" pins will be connected onto the Atlas serial port board to enable selecting which device the RPi will communicate to.
To test the GPIO pins I would use the command line options below. This is also the commands used within the script we shall use to eventually read the Atlas devices with.
pi@raspberrypi ~ $ sudo -i
root@raspberrypi:~# gpio -g mode 17 out
root@raspberrypi:~# gpio -g write 17 1 (turn ON)
root@raspberrypi:~# gpio -g write 17 0 (turn OFF)
Do NOT continue until you can prove you can switch on/off at least two outputs (GPIO 17 & 18) and you know the corresponding physical GPIO pins.
Connection of the Hardware
Reference: Atlas document for connection diagram, Atlas Serial board
Note. As the GPIO pins run at 3.3VDC it is important to run the Atlas serial board and sensors at 3.3V. There are Atlas boards, (I think conductivity) that need 5VDC so you would need some additional electronics or level shifter to convert the 5V to 3.3V. The only GPIO pin that would cause issues is the serial receive pin of the RPi..
- After testing out two GPIO pins, (I used GPIO 17 and 18) connect these to the inputs S0 & S1
- Connect the Tx Rx pins from the GPIO to the serial board Tx Rx (you have to cross them, tx->rx and rx<-tx)
- Connect the 3.3VDC and GND from the GPIO header pins to the Serial board VCC and GND
- Make sure the serial board E (enable) input is connected to GND
TBA
Logging Data