Solar Heating Control

Keywords: RaspberryPI, Home Automation, Temperature Sensor, AD converter, Relay, Solar, Heating, Ventilation, Control with Web Interface,Data Logging

Abstract: To create a solar heating control this article describes how to connect temperature sensor via SPI to a RaspberryPI and how to use GPIO-pins to control relays. In the second part there are detailed control algorithms for a combined solar and combustion heating with web interface to visualize the data logging and as control pannel.

Raspberry Pi Logo
1 Set up the RaspberryPi
1.1Set up the Web Server
1.2Access the Server via Internet
2 Electrical Connection of Sensors and Actuators
2.1Input: AD-converter
2.2Output: Relays
2.3RS232
3 Set up the Communication
3.1SPI Bus
3.2GPIO Pins
3.3PHP Interface
4 Heating Control
5Ventilation Control (Paul Lüftung, Thermos 200)
5.1Hacking a serial bus
6 z-wave

no warranty for any of the provided information

Environment

When my heating control broke down I decided to create my own to

  • implement my own control algorithms
  • have an easy to use web interface
  • be able to repair it myself!
  • safe money

As heating setup I have one central hot water storage tank (550 l Water including 180 l tap water), which provides heat for warm water consumption and heating of my house.
There are two possibilities to heat up this tank which have to be controlled:

  1. Solar heating
    One solar collector (6.93 m2, (TK-Solar) with pump and sensors for hot loading temperature and return flow temperature .
  2. Wood pellet burner
    The Calimax "Twist 80/20" oven has its own control for lighting the fire and control the circulation pump.
    To activate it there are contacts which have to be closed without potentitial by my control. To do this a second relay is needed.
So far I have 4 sensors (Ttank, Tcoll, Tload, Tret) and 2 actuators (Asolar, Aoven) to handle... So let"s set up the RaspberryPI, design the electronis, implement the communication and design the control.

1 Set up the RaspberryPi

You have to buy the RaspberryPI, a 5 V power supply and a (16 Gb) SD card - in total 46 EUR in my case.

First you have to format the SD card. My first attempt was to use gparted under openSUSE 12.x and I figured out that there is a problem with this version and than I used SDFormatter and it worked well.

Afterwards download the NOOBS_v1_2_1.zip to the SD card, unzip it being root and remove the zip-file.

To connect the RaspberryPI have a look into the quick-start-guide-v2_1.pdf - just for inital start it is helpful to have a USB keyboard and mouse and a monitor with HDMI connection to hand.

Choose Raspbian as operating system to be installed and have a cup of coffee...

After installation, to have the bash shell by default do
chsh -s /bin/bash

And since I like the GNU emacs for programming:
sudo apt-get update
sudo apt-get install emacs

And to set the time zone:
sudo cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime

And meld is a good tool to compare two file or directory versions
sudo apt-get install meld

Update the system

If the Raspberry Pi is connected to the internet, you should apply an update regularly:
sudo apt-get update
sudo apt-get dist-upgrade

1.1 Set up the Web Server

To set up the web server, a good introduction I found is:
http://www.penguintutor.com/linux/raspberrypi-webserver

Find out the IP address of the device by
ifconfig
and the IP address of the router by
route

If you are working on some computer and would like to detect other available machines, try nmap

To use ssh to log in from some remote machine edit
nano /ets/hosts
(on all your computers) and add computer names for the fixed IP numbers:

192.168.2.103   raspberry
192.168.2.106   miraculix

From now on you can login to your RaspberryPI from any other computer in your network by
ssh -X pi@raspberry
(If you should work on a Windows PC you might have to use Putty.)

If your raspberry will be connected to the internet, better change the ssh port from 22 to anything else by
nano /etc/ssh/sshd_config
and restart the service
/etc/init.d/ssh restart
First check that this channel is not used by any other service, check
more /etc/services
Before you close your actual shell, use some other and try to log in!
ssh pi@raspberry -p 1234

The essential sequence to set up the web server is:
passwd
A more comprehensive renaming of user pi is there.

cd /etc/network
sudo nano interfaces
#replace the line "iface eth0 inet dhcp" with:

iface eth0 inet static
address 192.168.1.3
netmask 255.255.255.0
gateway 192.168.1.1
nano /etc/resolv.conf #check: nameserver 192.168.1.1
sudo reboot
sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install php5-mysql
#for data logging

To test the server start a browser (dillo) on your RaspberryPI and enter http://localhost/.
To modify this start page edit /var/www/index.html or replace this by your index.php.

1.2 Access the Server via Internet

To make your RaspberryPI visible from the internet you have to open ports in your router (Speedport W723V) and direct them to the RaspberryPI. To have the web server available open port 80 and for the ssh connection port 22.
speedport.png
To test this you have first to figure out your (actual) IP - there are different tools in the internet like monIP.org.
From any external IP you may type your IP like http://84.186.91.131/ into the URL of the browser or test
ssh -X pi@84.186.91.131

2 Electrical Connection of Sensors and Actuators

The RaspberryPi has a 26 pin General Purpose Input/Output (GPIO) connector on its top. The usage is indicated in the figure. Note that the connector is not commutation safe, while most connectors have some edge on their housing to prevent commutation the Raspberry has not. So check the sketch, it will be valid also, if you look on top of the pins of your secondary board.

Qty Title Price
1 MCP 3208-CI/P, 12-bit A/D Converter mit SPI, 8-Kanal / DIL-16 2.48 €
2 FIN 36.11, 5V Finder-Subminiaturrelais, 1x UM, 250V 10A, 5V 1.85 €
1 UP 832EP, Lochrasterplatine, Epoxyd, 160x100mm 3.39 €
1 WSL 26G, Wannenstecker, 26-polig, gerade 0.13 €
2 Transistor BC337-40 0.14 €
2 Diode 1N4148 0.06 €
3 Widerstand Metall 1W 1.2 kOhm 0.48 €
4 Widerstand Metall 1W 2.2 kOhm 0.64 €
2 Pfostenverbinder RM 2.54 26 Pol 1.00 €
1 IC-Fassung 16 Pol 0.20 €
1 Leiterplattenklemme 10 Pol 1.65 €
total 12.02 €
RaspberryPiBreakoutBoard

My RaspberryPi break out board. Additionally I added connectors for 5 V and Ground which are connected via two pins each to the RaspberryPi. This way they could be used as alternative voltage supply to the whole system and for control measurements I have these potentials easily accessible. The board is already prepaired to have a second AD converter to handle more signals.

2.1 Input: AD-converter

Connection of the MCP3208 AD converter to the RaspberryPi. Colorcoding corresponds to the wires on my board. Since I want to measure warm temperatures, I use resistors of 1.2 kOhm in case of PT1000 sensors and 2.2 kOhm for KTY sensors.

2.2 Output: Relays

Connection of the relays to the RaspberryPi. Some output pin (GPIO22) is used to stear a relay. To keep the currenct over the RaspberryPi < 3 mA I use a resistor of 1.2 kOhm and a Transistor to switch the control current of the relay. The diode is used to get rid of inductive voltage spike when relay is shut off.

2.3 Serial Interface

Raspberry_Serial.png

2.4 Further Digital I/O

Raspberry_MCP23017.svg Since I start to run out of GPIOs to controll my ventilation, I added an MCP23027 connected via I2C.

3 Set up the Communication

3.1 SPI Bus

The Serial Peripheral Interface (SPI) Bus uses four wires. CS/CE (chip select or chip enable) activates the slave to talk to - the RaspberryPi has two such connections (CE0, CE1). The ship clock (SCLK) gives the pulse for the communication. Each pulse one bit can be sent master out / slave in (MOSI) and at the same time a bit slave out / master in (SOMI) is received. The received bit overrides the sent bit.

In computers it is convenient to group 8 bits as a byte. The necessary sequence to read channel 1 you may get from the documentation MCP3208ADC.pdf:
1. byte
0do not care
0do not care
0do not care
0do not care
0do not care
1start bit
1single mode
0D2
2. byte
0D1
1D0
0do not care
0do not care
0do not care
0do not care
0do not care
0do not care
3. byte
0do not care
0do not care
0do not care
0do not care
0do not care
0do not care
0do not care
0do not care
start bit the change from 0 to 1 starts the communication
Sngl/Diff 1 indicates single mode
D2, D1, D0 is the binary number of the AD channel (0-7)

In my example the resulting bytes look like:
1. byte
0do not care
0do not care
0do not care
0do not care
0do not care
0do not care
0do not care
0do not care
2. byte
1do not care
1do not care
1do not care
0do not care
012. bit
111. bit
010. bit
09. bit
3. byte
18. bit
17. bit
16. bit
15. bit
14. bit
13. bit
02. bit
11. bit
just in case you never had to worry about the bits in your computer before, you have to sort the result as follows:
Shift the 2nd byte 4 bits to the left to drop the first four bits. tmp is stil an unsigned char with 8 bits:

tmp = (byte2<<4)
gives tmp = 0100 0000
Casting the unsigned char to 16 bit integer (the RaspberryPi uses 32 bit, which gives 16 more leading zeros):
result = (int)tmp
gives result = 0000 0000 0100 0000
Shifting the integer again 4 bit to left to have bits at positions 9 - 12:
result = (result<<4)
gives result = 0000 0100 0000 0000
Now add the 3rd byte:
result = result + (int)byte3
gives result = 0000 0100 1111 1101
In decimal world this is 1277, dividing by 212 = 4096 gives 0.31.

My test program I came up with uses Gordons wiringPi library and looks like:

#include <stdio.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <math.h>
#include <wiringPi.h>
#include <wiringPiSPI.h>

double SPI_readMCP3208Channel(chip,channel){
  unsigned char cntrlStack[3];
  unsigned char tmp;
  uint result;
  double realResult;
  /* according figure 6-1 of MCP3208 */
  switch(channel){
  case 0:
    cntrlStack[0]=0b00000110;
    cntrlStack[1]=0b00000000;
    break;
  case 1:
    cntrlStack[0]=0b00000110;
    cntrlStack[1]=0b01000000;
    break;
  case 2:
    cntrlStack[0]=0b00000110;
    cntrlStack[1]=0b10000000;
    break;
  case 3:
    cntrlStack[0]=0b00000110;
    cntrlStack[1]=0b11000000;
    break;
  case 4:
    cntrlStack[0]=0b00000111;
    cntrlStack[1]=0b00000000;
    break;
  case 5:
    cntrlStack[0]=0b00000111;
    cntrlStack[1]=0b01000000;
    break;
  case 6:
    cntrlStack[0]=0b00000111;
    cntrlStack[1]=0b10000000;
    break;
  case 7:
    cntrlStack[0]=0b00000111;
    cntrlStack[1]=0b11000000;
    break;
  }
  cntrlStack[2]=0b00000000;
  /* fprintf(stdout," in1: %X t  in2: %X t  in3 %X n",cntrlStack[0],cntrlStack[1],cntrlStack[1]); */

  wiringPiSPIDataRW (chip,cntrlStack, 3);

  /* fprintf(stdout,"out1: %X t out2: %X t out3 %X n",cntrlStack[0],cntrlStack[1],cntrlStack[1]); */
  tmp=(cntrlStack[1]<<4);
  result=(uint)tmp;
  result=(result<<4);
  result=result+(uint)cntrlStack[2];
  return result;
}

int main (){
  int chip =0;
  int channel=1;
  int result;
  int errno;
  if (wiringPiSPISetup (chip, 2000000) < 0){
    fprintf (stderr, "SPI Setup failed: %s\n", strerror (errno));
  }else{
    printf("SPI okn");
  }
  for (channel=0;channel<8;channel++){
    result = SPI_readMCP3208Channel(chip,channel);
    realResult = (double)result/(double)4096;
    fprintf(stdout,"chn: %i result: %i = %f\n",channel,result,realResult);
  }
  return;
}

First you have to install the "wiringPI" library:
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build

And to use the SPI bus you have to load the module first:
gpio load spi
After update to newest kernel (> 3.18) use sudo raspi-config and in Advanced Options enable the SPI.
After the kernel update all output of the ADC had been zero - until I recompiled the wiringPi.

To compile and execute do:
gcc -I/usr/local/include -c talkSPI.c
gcc -o talkSPI.x talkSPI.o -L/usr/local/lib -lwiringPi
./talkSPI.x

Doing the first tests I got garbage which was due to wrong clock frequency. In the documentation of the MCP3208 there is the note that the chip works with 2 MHz operating at 5 V.
To test I used different combinations of resistors as voltage divider or put the AD channel to 5 V or Ground. This way you can measure the voltage at the input using a multimeter and compare it to the output of the program. (Free inputs which are not connected to some potential will show arbitrary values.)

3.2 GPIO Pins

To test the output relays you may toggle the appropriate pin via shel:
This works only if you have root privilegues
sudo -i
Activate port 22 and configure it as output pin
echo "22" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio22/direction

Now toggle the port
echo "1" > /sys/class/gpio/gpio22/value
echo "0" > /sys/class/gpio/gpio22/value
If you did connect a multimeter to the relay you will hear the beep.

3.3 PHP Interface

Since I prefer PHP over C and since I plan to do a web frontend for my control, I need PHP interfaces for the wiringPi functions. There are may explanations in the net how to create your own PHP extensions like the "Programming PHP" sec. 14.3 ff of OReilly. To follow these instructions, you have to install the PHP development kit first:
sudo apt-get install php5-dev
Than create your definitions file
cd /home/pi/PHPextension
nano /home/pi/PHPextension/wiringPi.def

int wiringPi_SPI_Setup(int chip, int freq)
string wiringPi_SPI_DataRW(int chip, string command)
int wiringPi_SPI_readMCP3208Channel(int chip, int channel)
void wiringPi_Setup(void)
void wiringPi_pinMode(int pin, string mode)
void wiringPi_digitalWrite(int pin, int state)
and do
/usr/share/php5/ext_skel --extname=wiringPi --proto=wiringPi.def

Enter the generated directory and edit
emacs wiringPi.c

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_wiringPi.h"
#include <wiringPi.h>
#include <wiringPiSPI.h>

...

/* {{{ wiringPi_module_entry
 */
zend_module_entry wiringPi_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
	STANDARD_MODULE_HEADER,
#endif
	"wiringPi",
	wiringPi_functions,
	PHP_MINIT(wiringPi),
	PHP_MSHUTDOWN(wiringPi),
	NULL,
	NULL,
	PHP_MINFO(wiringPi),
#if ZEND_MODULE_API_NO >= 20010901
	"0.1", /* Replace with version number for your extension */
#endif
	STANDARD_MODULE_PROPERTIES
};
/* }}} */

...

/* {{{ proto int wiringPi_SPI_Setup(int chip, int freq)
    */
PHP_FUNCTION(wiringPi_SPI_Setup)
{
	int argc = ZEND_NUM_ARGS();
	long chip;
	long freq;
	long success;

	if (zend_parse_parameters(argc TSRMLS_CC, "ll", &chip, &freq) == FAILURE) 
		return;

	success = (long)wiringPiSPISetup ((int)chip, (int)freq); 
	RETURN_LONG(success);
}
/* }}} */

/* {{{ proto string wiringPi_SPI_DataRW(int chip, string command)
    */
PHP_FUNCTION(wiringPi_SPI_DataRW)
{
	char *command = NULL;
	int argc = ZEND_NUM_ARGS();
	int command_len;
	long chip;
	/*
	int i;
	char message;
	array_init(message);
	*/
	if (zend_parse_parameters(argc TSRMLS_CC, "ls", &chip, &command, &command_len) == FAILURE) 
		return;

	wiringPiSPIDataRW (chip, command, command_len);
	/*
	for (i=0;i<command_len;i++){
		add_index_string(message, i, command(i));
	} //i
	*/

	//RETURN_STRING(message);
	RETURN_STRING(command, command_len);
}
/* }}} */

/* {{{ proto int wiringPi_SPI_readMCP3208Channel(int chip, int channel)
    */
PHP_FUNCTION(wiringPi_SPI_readMCP3208Channel)
{
	int argc = ZEND_NUM_ARGS();
	long chip;
	long channel;
	int value;
	unsigned char cntrlStack[3];
	unsigned char tmp;

	if (zend_parse_parameters(argc TSRMLS_CC, "ll", &chip, &channel) == FAILURE) 
		return;
	//according figure 6-1 of MCP3208
	switch(channel){
	case 0:
		cntrlStack[0]=0b00000110;
		cntrlStack[1]=0b00000000;
		break;
	case 1:
		cntrlStack[0]=0b00000110;
		cntrlStack[1]=0b01000000;
		break;
	case 2:
		cntrlStack[0]=0b00000110;
		cntrlStack[1]=0b10000000;
		break;
	case 3:
		cntrlStack[0]=0b00000110;
		cntrlStack[1]=0b11000000;
		break;
	case 4:
		cntrlStack[0]=0b00000111;
		cntrlStack[1]=0b00000000;
		break;
	case 5:
		cntrlStack[0]=0b00000111;
		cntrlStack[1]=0b01000000;
		break;
	case 6:
		cntrlStack[0]=0b00000111;
		cntrlStack[1]=0b10000000;
		break;
	case 7:
		cntrlStack[0]=0b00000111;
		cntrlStack[1]=0b11000000;
		break;
	default:
		RETURN_LONG((long)-1);
	}
	cntrlStack[2]=0b00000000;

	wiringPiSPIDataRW (chip, cntrlStack, 3);

	tmp=cntrlStack[1];
	tmp=(cntrlStack[1]<<4);
	value=(long)tmp;
	value=(value<<4);
	value=value+(long)cntrlStack[2];

	RETURN_LONG(value);
}
/* }}} */

/* {{{ proto void wiringPi_Setup()
    */
PHP_FUNCTION(wiringPi_Setup)
{
	if (zend_parse_parameters_none() == FAILURE) {
		return;
	}
	wiringPiSetupSys();
}
/* }}} */

/* {{{ proto void wiringPi_pinMode(int pin, int mode)
    */
PHP_FUNCTION(wiringPi_pinMode)
{
	int argc = ZEND_NUM_ARGS();
	long pin;
	long mode;

	if (zend_parse_parameters(argc TSRMLS_CC, "ll", &pin, &mode) == FAILURE) 
		return;

	pinMode((int)pin, (int)mode);
}
/* }}} */

/* {{{ proto void wiringPi_digitalWrite(int pin, int state)
    */
PHP_FUNCTION(wiringPi_digitalWrite)
{
	int argc = ZEND_NUM_ARGS();
	long pin;
	long state;

	if (zend_parse_parameters(argc TSRMLS_CC, "ll", &pin, &state) == FAILURE) 
		return;

	digitalWrite((int)pin, (int)state);
}
/* }}} */
Use meld to compare this extract to your generated file.

Now enable the compilation:
emacs config.m4

...
PHP_ARG_ENABLE(wiringPi, whether to enable wiringPi support,
[  --enable-wiringPi           Enable wiringPi support])
...
and run
phpize
and
./configure

If you follow with
make
you will gain garbage since the wiringPi library is not linked - and all experimenting with PHP_ADD_LIBRARY_WITH_PATH and so on gave no success!
Finally I took the stdout of the make command to compile and link manually:

cc -I. -I/home/pi/PHPextension/wiringPi -DPHP_ATOM_INC -I/home/pi/PHPextension/wiringPi/include 
 -I/home/pi/PHPextension/wiringPi/main -I/home/pi/PHPextension/wiringPi -I/usr/include/php5 
 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext
 -I/usr/include/php5/ext/date/lib -I/usr/local/include 
 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -g -O2 
 -c /home/pi/PHPextension/wiringPi/wiringPi.c  -fPIC -DPIC -o .libs/wiringPi.o

/home/pi/PHPextension/wiringPi/libtool --mode=link cc -DPHP_ATOM_INC 
 -I/home/pi/PHPextension/wiringPi/include -I/home/pi/PHPextension/wiringPi/main 
 -I/home/pi/PHPextension/wiringPi -I/usr/include/php5 -I/usr/include/php5/main 
 -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext 
 -I/usr/include/php5/ext/date/lib -L/usr/local/lib -lwiringPi
 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -DHAVE_CONFIG_H  -g -O2   -o wiringPi.la -export-dynamic
  -avoid-version -prefer-pic -module -rpath /home/pi/PHPextension/wiringPi/modules  wiringPi.lo 

/home/pi/PHPextension/wiringPi/libtool --mode=install cp ./wiringPi.la /home/pi/PHPextension/wiringPi/modules

To use your new PHP extension you have to edit
sudo nano /etc/php5/{apache2,cli}/php.ini
and add the line

extension=/home/pi/PHPextension/wiringPi/modules/wiringPi.so

To test my work I wrote a small script

<php

/* test SPI, AD converter */
$chip=0;
$freq=2000000;
$success = wiringPi_SPI_Setup($chip,$freq);
echo $success." >0 SPI activated\n";

for ($i=0;$i<8;$i++){
    $channel=$i;
    $value = wiringPi_SPI_readMCP3208Channel($chip, $channel);
    echo $i." value= ".$value." = ";
    $value=$value/4096;
    echo $value."\n";
} #i

/* test GPIO22 switch relay */
wiringPi_Setup();
/* mode 0 = input, mode 1 = output */
wiringPi_pinMode(22,1); 
/* state = 1  on, state = 0 = off */
wiringPi_digitalWrite(22,1);
sleep(2);
wiringPi_digitalWrite(22,0);

?>

and figured out that I had to modify the access rights of the GPIO pins.

3.4 Access the GPIO Pins

I created a new group
sudo -i
groupadd -f --system gpio

and added me to that group
nano /etc/group

gpio:x:99:pi
Than I created the access to the four pins used by me:
echo "22" > /sys/class/gpio/export
echo "23" > /sys/class/gpio/export
echo "24" > /sys/class/gpio/export
echo "25" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio22/direction
echo "out" > /sys/class/gpio/gpio23/direction
echo "out" > /sys/class/gpio/gpio24/direction
echo "out" > /sys/class/gpio/gpio25/direction

and changed owner and writing permissions:
chown -R root:gpio /sys/class/gpio/gpio22/*
chown -R root:gpio /sys/class/gpio/gpio23/*
chown -R root:gpio /sys/class/gpio/gpio24/*
chown -R root:gpio /sys/class/gpio/gpio25/*
chmod g+w /sys/class/gpio/gpio22/value
chmod g+w /sys/class/gpio/gpio23/value
chmod g+w /sys/class/gpio/gpio24/value
chmod g+w /sys/class/gpio/gpio25/value

This way I can switch the relays with my user privilegues - as long as I do not reboot the PI.

Finally I"ve put these tasks to the startup script /etc/init.d/S999raspberry
!/sbin/sh
#
# Template for custom rc script
PATH=/usr/sbin:/usr/bin:/sbin
export PATH

case $1 in
"start_msg")
        echo "Starting the RaspberryPi ports"
        ;;

"stop_msg")
        echo "Stopping the RaspberryPi ports"
        ;;

"start")
        # All required instruction to start the process. Can be a call to another script.
        sudo echo "22" > /sys/class/gpio/export
        sudo echo "23" > /sys/class/gpio/export
        sudo echo "24" > /sys/class/gpio/export
        sudo echo "25" > /sys/class/gpio/export
        sudo echo "out" > /sys/class/gpio/gpio22/direction
        sudo echo "out" > /sys/class/gpio/gpio23/direction
        sudo echo "out" > /sys/class/gpio/gpio24/direction
        sudo echo "out" > /sys/class/gpio/gpio25/direction
        sudo /bin/chown -R root:gpio /sys/class/gpio/gpio22/*
        sudo /bin/chown -R root:gpio /sys/class/gpio/gpio23/*
        sudo /bin/chown -R root:gpio /sys/class/gpio/gpio24/*
        sudo /bin/chown -R root:gpio /sys/class/gpio/gpio25/*
        sudo /bin/chmod g+w /sys/class/gpio/gpio22/value
        sudo /bin/chmod g+w /sys/class/gpio/gpio23/value
        sudo /bin/chmod g+w /sys/class/gpio/gpio24/value
        sudo /bin/chmod g+w /sys/class/gpio/gpio25/value
        cd /var/www/ && sudo -u www-data php HV_loop.php&
        rval=1
        ;;

"stop")
        # All required instruction to stop the process. Can be a call to another script.
        pid=$(pgrep -f HV_loop)
        echo $pid
        kill $pid
        pid=$(pgrep -f thermos200)
        kill $pid

        rval=1
        ;;

*)
        echo "usage: $0 {start|stop|start_msg|stop_msg}"
        rval=1
        ;;

*)
        echo "usage: $0 {start|stop|start_msg|stop_msg}"
        rval=1
        ;;
esac
exit $rval
and activated this by
update-rc.d S999raspberry start NN 3

Such init.d script may be tested by
sudo /etc/init.d/S999raspberry start

The apache may be restarted by:
sudo /etc/init.d/apache2 restart

4

next page: Heating Control

  • meld /media/arne/root/etc/apache2/ /etc/apache2/
Login
Valid HTML 4.01!