Dr. Arne Jachens Dr. Arne Jachens
Hamburger Hamburger

Solar Heating and Ventilation Control based on Raspberry Pi

Raspberry Pi Logo 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.

Motivation

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:

  • Solar heating One solar collector (6.93 m2, with pump and sensors for hot loading temperature and return flow temperature .
  • 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.0 Set up the RaspberryPi

  • Dowload and install the RaspberryPi Imager on your regular computer.
  • Start rpi-imager and
    • set hostname
    • enable ssh
    • set user + password
    • set local settings
  • Write ISO to SSD.
  • Plug SSD into RaspberryPi, connect Monitor, Mouse, Keyboard and boot; initial boot is slow, keep patient
  • sudo raspi-config
    • System Options > Boot / Auto Login > Console
    • System Options > Hostname
    • System Options > WLAN
    • Interface Options > ssh = yes
    • Localisation Options > Locale = de_DE.UTF-8 en_US.UTF-8
  • reboot
  • connect LAN and login to console sudo apt-get update sudo apt-get upgrade sudo shutdown -r now
  • route ssh to some different port:
    sudo nano /etc/ssh/sshd_config
    • Port 65022
    • LoginGraceTime 1m
    • MaxAuthTries 6
    • PubkeyAuthentication yes
    • AuthorizedKeysFile .ssh/authorized_keys
    Put your ssh-key onto the new machine:
    cat your_id_rsa.pub > ~/.ssh/authorized_keys
    or, from extern computer do:
    ssh-copy-id -p 65022 @
    Set access rights:
    sudo chown -R .ssh/
    chmod 700 .ssh
    chmod 600 .ssh/authorized_keys

    restart service:
    sudo service sshd restart
    Before you logout, try to login in from different shell first!
    ssh -p 65022 -X user@IP
    Be aware of your firewall settings.
  • find IP address by ifconfig and try to login via
    ssh -p 12345 user@192.168.xxx.xxx
    (If you should work on a Windows PC, you may use PowerShell.)
  • Install further usefull applications:
    sudo apt-get install emacs
    sudo apt-get install gnuplot
    sudo apt-get install meld
    sudo apt-get install git-cola

1.1 Set up the Web Server

  • If there should be apache be default, uninstall it:
    sudo systemctl stop apache2
    sudo apt-get purge apache2 apache2-utils apache2-bin apache2.2-common -y
    sudo apt-get autoremove -y
  • install lighttpd
    sudo apt-get install lighttpd -y
    sudo systemctl start lighttpd
    sudo systemctl enable lighttpd
  • To get your IP use hostname -I or ifconfig
  • install php sudo apt install php php-cgi -y
    sudo lighttpd-enable-mod fastcgi
    sudo lighttpd-enable-mod fastcgi-php
    sudo systemctl restart lighttpd
  • Change the port number: sudo nano /etc/lighttpd/lighttpd.conf
    server.port = 12380
  • finally restart sudo /etc/init.d/lighttpd restart
  • Edit default page: sudo chown pi:www-data /var/www/html/index.php
    nano /var/www/html/index.php
       ;-)  php 
    echo "";
    echo "

    This is lighttp, hello my fried :-)

    "; phpinfo(); echo ""; ;-)
  • And test it:
    lynx http://localhost:12380

debug

messages

PAGE CONSTRUCTOR

handleArguments
sec: raspberry
page: raspberry
what2do:

main( DIR: Content/ sec: raspberry page: raspberry w2d: )

toc( DIR: Content/ level: )

handleJSON.read(Content//sections.json)

handleJSON.read(Content//toc.json)

pageEditor.operate( mode: showPage, w2d: , action: ?s=raspberry&sec=arne&subSec=raspberry&what2do=edit )

File Content/raspberry.htm read to display.

head(Content/)

header(Content/)

footer(Content/)