Dr. Arne Jachens
[GPIO] [SPI] [I2C] [RS232] [PCB] [1wire] [motor] [zwave]

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:

  1. Solar heating
    One solar collector (6.93 m2, 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.0 Set up the RaspberryPi

  1. Dowload and install the RaspberryPi Imager on your regular computer.
  2. Start the imager application and
    • set hostname
    • enable ssh
    • set user + password
    • set local settings
  3. Write ISO to SSD.
  4. Plug SSD into RaspberryPi, connect Monitor, Mouse, Keyboard and boot;
    initial boot is slow, keep patient
  5. 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
  6. reboot
  7. connect LAN and login to console
    sudo apt-get update
    sudo apt-get upgrade
    sudo shutdown -r now
  8. route ssh to some different port:
    sudo nano /etc/ssh/sshd_config
  9. 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 might have to use Putty.)
 

1.1 Set up the Web Server

How to setup Raspberry Pi Lighttpd
  1. sudo apt-get install lighttpd
  2. To get your IP use
    hostname -I or ifconfig
  3. install php
    sudo apt install php php-cgi php-mysql
    sudo lighty-enable-mod fastcgi
    sudo lighty-enable-mod fastcgi-php
  4. Change the port number:
    sudo nano /etc/lighttpd/lighttpd.conf
    server.port                 = 12380
  5. finally restart
    sudo /etc/init.d/lighttpd restart
  6. Edit default page:
    sudo chown pi:www-data /var/www/html/index.php
    nano /var/www/html/index.php
    <?php 
    echo "<html>";
    echo "<h1>This is lighttp, hello my fried :-)</h1>";
    phpinfo(); 
    echo "</html>";
    ?>
    
  7. And test it:
    dillo http://localhost:12380

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 84.186.91.131 into the URL of the browser or test
ssh -X pi@84.186.91.131

My first Heating Control PCB on a strip 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.

For a more advaned approach, have a look to Electrical Connection of Sensores and Actuators.

Fraktal als Vektorgrafik

Eines Tages fragte ich mich, was wohl passiert, wenn man an einen Kreis kleinere Kreise in alle Himmelsrichtungen anfügt, ob sich die Äste wohl berühren würden?
Der Versuch, dies zu zeichnen brachte mich sehr schnell dazu, mir einen Algorithmus zu überlegen und eine Vektorgrafik zu errechnen.
Seitdem verwende ich dieses Fraktal als Logo.

Detailierung:
Füllung:
Linienfarbe: