Timelapse Camera w/ Canon EOS 350D

Raspberry, Kamera, DS18B20, Heizungsschalter
1. DS18B20 an GPIO4 -> Initialisierung laut Anleitung
2. Heizungsschalter an GPIO17
3. Script “heizung.sh”
#!/bin/bash
temp=`cat /sys/bus/w1/devices/10-00080309dc2a/w1_slave | grep t= | cut -c30-34`
#echo $temp
temp=`echo "scale=3; $temp / 1000" | bc`
datum=`date +"%F , %T"`
#temp=`expr $temp / 1000`
#echo 'Temp=' $temp
if [ `echo "$temp < 5" | bc` -eq 1 ]; then
echo "Temp<5°C: " $temp
# 0 = einschalten der Heizung
echo "0" > /sys/class/gpio/gpio17/value
# echo $datum "," $temp ", EIN" >> temperature.log
exit 0
else
echo "Temp≥5°C: " $temp
# 1 = ausschalten der Heizung
echo "1" > /sys/class/gpio/gpio17/value
# echo $datum "," $temp ", AUS" >> temperature.log
rrdtool update temperature_db.rrd N:$temp
sudo rrdtool graph /var/www/html/test.png DEF:temp01=temperature_db.rrd:temperaturwert:AVERAGE LINE:temp01#FF00FF:"Temp °C"
exit 0
fi
exit 1

4. Script “init_gpio17.sh”
#!/bin/bash
echo "17" > /sys/class/gpio/export
sudo chmod 222 /sys/class/gpio/export /sys/class/gpio/unexport
echo "out" > /sys/class/gpio/gpio17/direction

5. crontab (pi)
# m h dom mon dow command
@reboot /home/pi/init_gpio17.sh
* * * * * /home/pi/heizung.sh

Temperatursensor mit NRF24l01 und Arduino Nano (Clone)

Arduino mit 6x DS18B20 und NRF24L01

NRF24L01 – Board Schematic & Pin-Out

Library http://tmrh20.github.io/RF24/

nRF24L01_Product_Specification_v2_0

DS18B20

Sensor 01 (Raumtemperatur):
0x10, 0xC4, 0x1E, 0x0A, 0x03, 0x08, 0x00, 0xEF

Sensor 02:
0x28, 0xFF, 0x0C, 0x0C, 0x86, 0x16, 0x04, 0xEF

Sensor 03:
0x28, 0xFF, 0xB2, 0x89, 0x90, 0x16, 0x05, 0x9F

Sensor 04:
0x28, 0xFF, 0x46, 0xC5, 0x86, 0x16, 0x05, 0x4F

Sensor 05:
0x28, 0xFF, 0x81, 0x93, 0x90, 0x16, 0x05, 0x76

Sensor 06:
0x28, 0xFF, 0xC7, 0x2E, 0x91, 0x16, 0x04, 0xFA

Raspberry Pi 3 mit NRF24L01

von hier: https://tutorials-raspberrypi.de/funkkommunikation-zwischen-raspberry-pis-und-arduinos-2-4-ghz/

sudo apt-get update
sudo apt-get upgrade
wget http://tmrh20.github.io/RF24Installer/RPi/install.sh
chmod +x install.sh
./install.sh
cd rf24libs/RF24
sudo apt-get install python-dev libboost-python-dev
sudo apt-get install python-setuptools

sudo apt-get install librrd-dev // !!!!

RRDTOOL

rrdtool create waermepumpe_temps.rrd --step 60 \
DS:t01:GAUGE:150:0:100 \
DS:t02:GAUGE:150:0:100 \
DS:t03:GAUGE:150:0:100 \
DS:t04:GAUGE:150:0:100 \
DS:t05:GAUGE:150:0:100 \
DS:t06:GAUGE:150:0:100 \
RRA:AVERAGE:0.5:1:14400 \
RRA:AVERAGE:0.5:1440:3600 \
RRA:MAX:0.5:1440:3600 \
RRA:MIN:0.5:1440:3600
/*
 Copyright (C) 2017 Christian Bauer <oe3cjb@qth.at>

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 version 2 as published by the Free Software Foundation.

 */

#include <rrd.h>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <unistd.h>
#include <RF24/RF24.h>

using namespace std;

RF24 radio(22,0);

bool radioNumber = 1;

/********************************/

// Radio pipe addresses for the 2 nodes to communicate.
const uint8_t pipes[][6] = {"Waerm","reuaB"};


int main(int argc, char** argv){

  typedef struct {
    long t01;
    long t02;
    long t03;
    long t04;
    long t05;
    long t06;
  } sensoren;

  sensoren wp;

  int rrd_argc = 3;
  char* rrd_argv[]={"update","/home/pi/waermepumpe_temps.rrd",NULL,NULL};

  cout << "Starte Wärmepumpen-Temperatur-Logger!" << endl;

  // Setup and configure rf radio
  radio.begin();
  radio.setDataRate(RF24_250KBPS);

  // optionally, increase the delay between retries & # of retries
  radio.setRetries(15,15);

  radio.openWritingPipe(pipes[1]);
  radio.openReadingPipe(1,pipes[0]);
  radio.startListening();

  // forever loop
  while (1)
  {
    // if there is data ready
    if ( radio.available() )
    {
      // Dump the payloads until we've gotten everything
      stringstream workhorse;
      string rrd_update_string;

      // laenge = radio.getDynamicPayloadSize();
      // Fetch the payload, and see if this was the last one.
      while(radio.available()){
    //    radio.read( &got_time, sizeof(unsigned long) );
    radio.read( &wp, sizeof(wp) );
      }
      // Ausgeben, was empfangen wurde
      //cout << "rrdtool update ~/waermepumpe_temps.rrd N:" << ((float) wp.t01)/100 << ":" << ((float) wp.t02)/100 << ":" << ((float) wp.t03)/100 << ":" << ((float) wp.t04)/100 << ":" << ((float) wp.t05)/100 << ":" << ((float) wp.t06)/100 << endl;
      workhorse << "N:" << ((float) wp.t01)/100 << ":" << ((float) wp.t02)/100 << ":" << ((float) wp.t03)/100 << ":" << ((float) wp.t04)/100 << ":" << ((float) wp.t05)/100 << ":" << ((float) wp.t06)/100;
      //rrd_update_string << "N:" << ((float) wp.t01)/100 << ":" << ((float) wp.t02)/100 << ":" << ((float) wp.t03)/100 << ":" << ((float) wp.t04)/100 << ":" << ((float) wp.t05)/100 << ":" << ((float) wp.t06)/100;
      rrd_update_string = workhorse.str();
      const char* cstr1 = rrd_update_string.c_str();
      cout << rrd_update_string << endl;
      rrd_argv[2] = (char *) cstr1;
      rrd_clear_error();
      rrd_update(rrd_argc,rrd_argv);
   }

      delay(5000); //Delay after payload responded to, minimize RPi CPU time

  } // forever loop
return 0;
}

rrdtool graph bild.png \
#!/bin/sh
rrdtool graph waermepumpe.png --width 640 --height 480 \
DEF:temp01=waermepumpe_temps.rrd:t01:AVERAGE \
DEF:temp02=waermepumpe_temps.rrd:t02:AVERAGE \
DEF:temp03=waermepumpe_temps.rrd:t03:AVERAGE \
DEF:temp04=waermepumpe_temps.rrd:t04:AVERAGE \
DEF:temp05=waermepumpe_temps.rrd:t05:AVERAGE \
DEF:temp06=waermepumpe_temps.rrd:t06:AVERAGE \
LINE2:temp01#00FF00:Zimmer \
LINE2:temp02#FFB400:Heizung-IN \
LINE2:temp03#FF0000:Heizung-OUT \
LINE2:temp05#0000FF:Quelle-IN \
LINE2:temp04#00FFFF:Quelle-OUT \
LINE2:temp06#990099:Wasserspeicher

USERNAME="wetterkamera"
PASSWORD="Kj69Ap"
SERVER="192.168.29.164"

# local directory to pickup *.tar.gz file
FILE="/home/pi"

# remote server directory to upload backup
BACKUPDIR="/"

# login to remote server
ftp -n -i $SERVER <

Raspi als IP-Power-Switch

Kurzbeschreibung

Läuft als PHP-Script unter http://IP-Adresse/index.php

Das Script selbst:

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>IP-Switch Raspi Hinteralm</title>
</head>
<p><h1 align="center">Welcome,<br />... Raspberry als IP-Switch ist bereit! </h1>
<p align="center"> </p>
<br>
<form method="get" action="index.php">
Port 18 - GPIO 24 - SW1 - schalten (<b>10A max</b>):
<br>
Status (0=ein, 1=aus):<b>
<?php
$val = exec ("/usr/local/bin/gpio -g read 24", $status, $error);
print_r ( $val );
?></b><br>
<input type="text" size="4" value="" name="t1">
<input type="submit" value="SW1 an" name="p1an">
<input type="submit" value="SW1 aus" name="p1aus">
<br><br>
Port 22 - GPIO 25 - SW2 - schalten (<b>10A max</b>):
<br>
Status (0=ein, 1=aus):<b>
<?php
$val = exec ("/usr/local/bin/gpio -g read 25", $status, $error);
print_r ( $val );
?></b><br>
<input type="text" size="4" value="" name="t2">
<input type="submit" value="SW2 an" name="p2an">
<input type="submit" value="SW2 aus" name="p2aus">
<br><br>
Port 24 - GPIO 8 - SW3 - schalten (<b>10A max</b>):
<br>
Status (0=ein, 1=aus):<b>
<?php
$val = exec ("/usr/local/bin/gpio -g read 8", $status, $error);
print_r ( $val );
?></b><br>
<input type="text" size="4" value="" name="t3">
<input type="submit" value="SW3 an" name="p3an">
<input type="submit" value="SW3 aus" name="p3aus">
<br><br>
Port 26 - GPIO 7 - SW4 - schalten (<b>10A max</b>):
<br>
Status (0=ein, 1=aus):<b>
<?php
$val = exec ("/usr/local/bin/gpio -g read 7", $status, $error);
print_r ( $val );
?></b><br>
<input type="text" size="4" value="" name="t4">
<input type="submit" value="SW4 an" name="p4an">
<input type="submit" value="SW4 aus" name="p4aus">
<br><br>
Port 32 - GPIO 12 - SW5 - schalten (<b>10A max</b>):
<br>
Status (0=ein, 1=aus):<b>
<?php
$val = exec ("/usr/local/bin/gpio -g read 12", $status, $error);
print_r ( $val );
?></b><br>
<input type="text" size="4" value="" name="t5">
<input type="submit" value="SW5 an" name="p5an">
<input type="submit" value="SW5 aus" name="p5aus">
<br><br>
Port 36 - GPIO 16 - SW6 -  schalten (<b>10A max</b>):
<br>
Status (0=ein, 1=aus):<b>
<?php
$val = exec ("/usr/local/bin/gpio -g read 16", $status, $error);
print_r ( $val );
?></b><br>
<input type="text" size="4" value="" name="t6">
<input type="submit" value="SW6 an" name="p6an">
<input type="submit" value="SW6 aus" name="p6aus">
<br><br>
Port 38 - GPIO 20 - SW7 - schalten (<b>10A max</b>):
<br>
Status (0=ein, 1=aus):<b>
<?php
$val = exec ("/usr/local/bin/gpio -g read 20", $status, $error);
print_r ( $val );
?></b><br>
<input type="text" size="4" value="" name="t7">
<input type="submit" value="SW7 an" name="p7an">
<input type="submit" value="SW7 aus" name="p7aus">
<br><br>
Port 40 - GPIO 21 - SW8 - schalten (<b>10A max</b>):
<br>
Status (0=ein, 1=aus):<b>
<?php
$val = exec ("/usr/local/bin/gpio -g read 21", $status, $error);
print_r ( $val );
?></b><br>
<input type="text" size="4" value="" name="t8">
<input type="submit" value="SW8 an" name="p8an">
<input type="submit" value="SW8 aus" name="p8aus">
</form>
<?php
if(isset($_GET["p1an"])){
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 24 0"));
$t1 = $_GET["t1"];
if ($t1 > 0) {
sleep($t1);
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 24 1"));
}
}
else if(isset($_GET["p1aus"])){
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 24 1"));
}
if(isset($_GET["p2an"])){
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 25 0"));
$t1 = $_GET["t2"];
if ($t2 > 0) {
sleep($t2);
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 25 1"));
}
}
else if(isset($_GET["p2aus"])){
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 25 1"));
}
if(isset($_GET["p3an"])){
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 8 0"));
$t1 = $_GET["t3"];
if ($t3 > 0) {
sleep($t3);
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 8 1"));
}
}
else if(isset($_GET["p3aus"])){
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 8 1"));
}
if(isset($_GET["p4an"])){
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 7 0"));
$t1 = $_GET["t4"];
if ($t4 > 0) {
sleep($t4);
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 7 1"));
}
}
else if(isset($_GET["p4aus"])){
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 7 1"));
}
if(isset($_GET["p5an"])){
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 12 0"));
$t1 = $_GET["t5"];
if ($t5 > 0) {
sleep($t5);
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 12 1"));
}
}
else if(isset($_GET["p5aus"])){
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 12 1"));
}
if(isset($_GET["p6an"])){
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 16 0"));
$t1 = $_GET["t6"];
if ($t6 > 0) {
sleep($t6);
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 16 1"));
}
}
else if(isset($_GET["p6aus"])){
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 16 1"));
}
if(isset($_GET["p7an"])){
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 20 0"));
$t1 = $_GET["t7"];
if ($t7 > 0) {
sleep($t7);
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 20 1"));
}
}
else if(isset($_GET["p7aus"])){
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 20 1"));
}
if(isset($_GET["p8an"])){
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 21 0"));
$t1 = $_GET["t8"];
if ($t8 > 0) {
sleep($t8);
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 21 1"));
}
}
else if(isset($_GET["p8aus"])){
$val = trim(@shell_exec("/usr/local/bin/gpio -g write 21 1"));
}

?>
</body>
</html>

Die Initialisierung dazu “startup_server.sh” (starten beim Hochlauf mit crontab!):

#
# Port 24
#
/usr/local/bin/gpio -g mode 24 out
# 0 = einschalten, 1 = ausschalten bei Startup
/usr/local/bin/gpio -g write 24 0
#
# Port 25
#
/usr/local/bin/gpio -g mode 25 out
# 0 = einschalten, 1 = ausschalten bei Startup
/usr/local/bin/gpio -g write 25 0
#
# Port 8
#
/usr/local/bin/gpio -g mode 8 out
# 0 = einschalten, 1 = ausschalten bei Startup
/usr/local/bin/gpio -g write 8 0
#
# Port 7
#
/usr/local/bin/gpio -g mode 7 out
# 0 = einschalten, 1 = ausschalten bei Startup
/usr/local/bin/gpio -g write 7 0
#
# Port 12
#
/usr/local/bin/gpio -g mode 12 out
# 0 = einschalten, 1 = ausschalten bei Startup
/usr/local/bin/gpio -g write 12 0
#
# Port 16
#
/usr/local/bin/gpio -g mode 16 out
# 0 = einschalten, 1 = ausschalten bei Startup
/usr/local/bin/gpio -g write 16 0
#
# Port 20
#
/usr/local/bin/gpio -g mode 20 out
# 0 = einschalten, 1 = ausschalten bei Startup
/usr/local/bin/gpio -g write 20 0
#
# Port 21
#
/usr/local/bin/gpio -g mode 21 out
# 0 = einschalten, 1 = ausschalten bei Startup
/usr/local/bin/gpio -g write 21 0

# Verzeichnis fuer Webserver anlegen
if [ ! -d "/var/log/nginx" ]; then
  sudo mkdir /var/log/nginx
fi
# Webserver starten
sudo service nginx restart

Raspi Zero W – als Entfernungsmesser und Geigerzaehler

Achtung: prüfen ob Programme GPIO_GENx, GPIOxx oder nur die Pinnummer verwenden ;-)!

Hier die Nummerierung aller Varianten!

Verbindung Raspberry Zero W <-> GC10 Geiger Zähler/Counter

Stromversorgung des GC10 durch Raspberry Zero!

Das Programm zum Testen der HC-SR04 kommt von HIER.

Datenbank für Radiation Werte erstellen:

rrdtool create radiation_db.rrd --step 600 \
DS:rad:GAUGE:6000:0:U \
RRA:AVERAGE:0.5:1:4500 \
RRA:AVERAGE:0.5:36:1500 \
RRA:MAX:0.5:36:1500 \
RRA:MIN:0.5:36:1500

C-Programm “main”

main.c


gcc -o main -lwiringPi main.c

Shell-Skript zum Grafik erstellen und Hochladen

#!/bin/bash
# Daily radiation graph
rrdtool graph /home/pi/radiation_daily.png \
--left-axis-format %3.3lf -X 0 \
DEF:rad_sample=/home/pi/radiation_db.rrd:rad:AVERAGE \
LINE2:rad_sample#0000FF:"Strahlung uSv/h"
# Weekly radiation graph
rrdtool graph /home/pi/radiation_weekly.png --start end-1w \
--left-axis-format %3.3lf -X 0 \
DEF:rad_sample=/home/pi/radiation_db.rrd:rad:AVERAGE \
LINE2:rad_sample#0000FF:"Strahlung uSv/h" \
# Monthly radiation graph
rrdtool graph /home/pi/radiation_monthly.png --start end-1m \
--left-axis-format %3.3lf -X 0 \
DEF:rad_sample=/home/pi/radiation_db.rrd:rad:AVERAGE \
DEF:rad_max=/home/pi/radiation_db.rrd:rad:MAX \
DEF:rad_min=/home/pi/radiation_db.rrd:rad:MIN \
LINE2:rad_sample#0000FF:"Strahlung uSv/h" \
LINE1:rad_max#FF0000:"Strahlung max" \
LINE1:rad_min#00FF00:"Strahlung min"
# Yearly radiation graph
rrdtool graph /home/pi/radiation_yearly.png --start end-1y \
--left-axis-format %3.3lf -X 0 \
DEF:rad_sample=/home/pi/radiation_db.rrd:rad:AVERAGE \
DEF:rad_max=/home/pi/radiation_db.rrd:rad:MAX \
DEF:rad_min=/home/pi/radiation_db.rrd:rad:MIN \
LINE2:rad_sample#0000FF:"Strahlung uSv/h" \
LINE1:rad_max#FF0000:"Strahlung max" \
LINE1:rad_min#00FF00:"Strahlung min"
# Jetzt noch hochladen
HOST='ftp.server.com'
USER='username'
PASSWD='password'
ftp -n -v $HOST << EOT
bin
user $USER $PASSWD
lcd /home/pi
put radiation_daily.png
put radiation_weekly.png
put radiation_monthly.png
put radiation_yearly.png
bye
EOT

Raspi als Wetterserver neu aufsetzen

  1. Raspi auf SD card installieren
  2. USB Stick als Drive verwenden (hält länger)
    https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=44177
  3. rrdtool installieren
  4. nginx installieren
  5. Datenbank “waermepumpe_temps.rrd”, “write_waermepumpe_image.sh” kopieren
  6. als nächstes Kommunikation zum Arduino mit NRF24 aufbauen
  7. RF24 installieren:
    http://et92.de/2014/08/kommunikation-von-arduino-zu-raspberry-pi-via-nrf24l01-und-rf24-library/
  8. “a” compilieren – innerhalb der RF24 examples; => LIB += -lrrd im Makefile hinzufügen!!!
  9. python installieren
  10. mit pip pywws holen
  11. libusb installieren und
    pip install pyusb --pre
  12. gnuplot installieren

TTGO T-Beam als LoRa APRS Tracker

The TTGO T-Beam as LoRa APRS Tracker for Ham Radio usage

1.) Code

https://github.com/oe3cjb/TTGO-T-Beam-LoRa-APRS

2.) Get TTGO T-Beam from here

https://de.aliexpress.com/item/TTGO-T-Strahl-ESP32-433-868-915-mhz-WiFi-drahtlose-Bluetooth-Modul-ESP-32-GPS-NEO/32875743018.html

3.) First Test with onboard GPS

First Test with GPS – received data to Serial (via USB to PC) out – code from here https://github.com/LilyGO/TTGO-T-Beam
Attention: change all “Serial1” to GPSSerial1 or similar – Serial1 is already defined in GPS.ino!!!!

Useful Links

https://www.bjoerns-techblog.de/2018/10/ttgo-t-beam-kompakter-knochen-zum-mappen/

https://blog.hackster.io/the-ttgo-t-beam-an-esp32-lora-board-d44b08f18628

https://github.com/lyusupov/SoftRF/wiki/Prime-Edition-MkII

http://tinymicros.com/wiki/TTGO_T-Beam