Skip to content

Commit

Permalink
Platine V6, StromPi Installtion im Skript, Tank-Routinen aktualisiert…
Browse files Browse the repository at this point in the history
…, gpiozero in position und Taster eingebaut
  • Loading branch information
spitzlbergerj committed Mar 15, 2024
1 parent 74860dc commit 213110e
Show file tree
Hide file tree
Showing 18 changed files with 288 additions and 114 deletions.
Binary file added circuit-board/V6/CaravanPi_V6_Board.pdf
Binary file not shown.
Binary file not shown.
Binary file added circuit-board/V6/CaravanPi_V6_Schaltplan.pdf
Binary file not shown.
Binary file added circuit-board/V6/CaravanPi_V6_mit_Masse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added circuit-board/V6/CaravanPi_V6_oben.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
23 changes: 23 additions & 0 deletions circuit-board/V6/JLCPCB/CaravanPi_V6_front_bom.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"Qty";"Value";"Device";"Package";"Parts";"Description";"MF";"MPN";"OC_FARNELL";"OC_NEWARK";"POPULARITY";"SPICEPREFIX";
"2";"";"233-403";"233-403";"KüHLSCHR., RADAR";"WAGO Cage Clamp";"";"233-403";"1601354";"28K9076";"0";"";
"4";"";"233-404";"233-404";"ADX345, HX711-EXTERN, KLIMA1, KLIMA2";"WAGO Cage Clamp";"";"233-404";"1601355";"28K9077";"0";"";
"1";"";"233-406";"233-406";"GASFLASCHEN";"WAGO Cage Clamp";"";"233-406";"1601357";"28K9079";"0";"";
"2";"";"233-408";"233-408";"FRISCHWASSERTANK, FÄKALIENTANK";"WAGO Cage Clamp";"";"233-408";"1601358";"28K9080";"0";"";
"7";"";"233-504";"233-504";"LED-HL, LED-HR, LED-VD, LED-VL, LED-VR, LED-ZL, LED-ZR";"WAGO Cage Clamp";"Wago Corporation";"0233-0504";"1777098";"79K2050";"0";"";
"1";"";"233-516";"233-516";"GPIO_EXTENSION";"WAGO Cage Clamp";"Wago Corporation";"0233-0516";"1777103";"79K2056";"0";"";
"1";"";"CON10";"CON10";"I2C-EXTENSION";"CONNECTOR";"";"";"unknown";"unknown";"3";"";
"1";"";"CON16";"CON16";"GEHÄUSEDECKEL";"CONNECTOR";"";"";"unknown";"unknown";"0";"";
"1";"";"HX711A";"HX711";"HX711";"";"";"";"";"";"";"";
"1";"";"PINHD-2X20";"2X20";"RASPBERRY-PI";"PIN HEADER";"";"";"";"";"";"";
"5";"100n";"C-EUC1206";"C1206";"C3, C4, C5, C6, C7";"CAPACITOR, European symbol";"";"";"";"";"54";"C";
"2";"10k";"R-EU_M1206";"M1206";"R34, R35";"RESISTOR, European symbol";"";"";"";"";"17";"R";
"7";"150";"R-EU_M1206";"M1206";"R3, R6, R9, R12, R17, R20, R23";"RESISTOR, European symbol";"";"";"";"";"17";"R";
"4";"330";"R-EU_M1206";"M1206";"R30, R31, R32, R33";"RESISTOR, European symbol";"";"";"";"";"17";"R";
"5";"47k";"R-EU_M1206";"M1206";"R25, R26, R27, R28, R29";"RESISTOR, European symbol";"";"";"";"";"17";"R";
"1";"47u";"CPOL-EUSMCC";"SMC_C";"C1";"POLARIZED CAPACITOR, European symbol";"";"";"";"";"";"";
"3";"4k7";"R-EU_M1206";"M1206";"R13, R14, R24";"RESISTOR, European symbol";"";"";"";"";"17";"R";
"14";"82";"R-EU_M1206";"M1206";"R1, R2, R4, R5, R7, R8, R10, R11, R15, R16, R18, R19, R21, R22";"RESISTOR, European symbol";"";"";"";"";"17";"R";
"1";"CARAVAN_PI_LOGO";"CARAVAN_PI_LOGO";"CARAVAN_PI_LOGO";"U$1";"Caravan_PI_logo";"";"";"";"";"";"";
"2";"MCP23017SO";"MCP23017SO";"SO28W";"MCP23017_1, MCP23017_2";"http://ww1.microchip.com/downloads/en/DeviceDoc/21952a.pdf";"";"";"";"";"";"";
"2";"P82B715PN,112SOIC8";"P82B715PN,112SOIC8";"SOP127P600X175-8N";"I2EXT1, I2EXT2";"I2C-bus extender";"";"";"";"";"";"";
"1";"S1D";"DIODE-DO214AC";"DO214AC";"D1";"DIODE";"";"";"";"";"14";"";
46 changes: 46 additions & 0 deletions circuit-board/V6/JLCPCB/CaravanPi_V6_front_cpl.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
C1, 97.79, 48.26, 180.00, 47u, SMC_C
C3, 64.77, 44.45, 180.00, 100n, C1206
C4, 77.47, 44.45, 180.00, 100n, C1206
C5, 40.64, 48.26, 90.00, 100n, C1206
C6, 91.44, 48.26, 270.00, 100n, C1206
C7, 45.72, 31.75, 270.00, 100n, C1206
D1, 99.06, 26.67, 0.00, S1D, DO214AC
I2EXT1, 64.77, 39.37, 0.00, P82B715PN,112SOIC8, SOP127P600X175-8N
I2EXT2, 77.47, 39.37, 0.00, P82B715PN,112SOIC8, SOP127P600X175-8N
MCP23017_1, 27.30, 52.07, 0.00, MCP23017SO, SO28W
MCP23017_2, 78.11, 52.07, 0.00, MCP23017SO, SO28W
R1, 92.71, 62.23, 90.00, 82, M1206
R10, 62.23, 62.23, 90.00, 82, M1206
R11, 54.61, 62.23, 90.00, 82, M1206
R12, 50.80, 62.23, 90.00, 150, M1206
R13, 99.06, 19.05, 180.00, 4k7, M1206
R14, 99.06, 22.86, 180.00, 4k7, M1206
R15, 46.99, 62.23, 90.00, 82, M1206
R16, 43.18, 62.23, 90.00, 82, M1206
R17, 39.37, 62.23, 90.00, 150, M1206
R18, 35.56, 62.23, 90.00, 82, M1206
R19, 31.75, 62.23, 90.00, 82, M1206
R2, 88.90, 62.23, 90.00, 82, M1206
R20, 27.94, 62.23, 90.00, 150, M1206
R21, 24.13, 62.23, 90.00, 82, M1206
R22, 20.32, 62.23, 90.00, 82, M1206
R23, 16.51, 62.23, 90.00, 150, M1206
R24, 99.06, 30.48, 180.00, 4k7, M1206
R25, 99.06, 38.10, 0.00, 47k, M1206
R26, 99.06, 59.69, 0.00, 47k, M1206
R27, 99.06, 34.29, 0.00, 47k, M1206
R28, 99.06, 55.88, 0.00, 47k, M1206
R29, 99.06, 52.07, 0.00, 47k, M1206
R3, 85.09, 62.23, 90.00, 150, M1206
R30, 77.47, 17.78, 270.00, 330, M1206
R31, 81.28, 17.78, 270.00, 330, M1206
R32, 64.77, 17.78, 270.00, 330, M1206
R33, 68.58, 17.78, 270.00, 330, M1206
R34, 91.44, 54.61, 90.00, 10k, M1206
R35, 40.64, 54.61, 90.00, 10k, M1206
R4, 81.28, 62.23, 90.00, 82, M1206
R5, 77.47, 62.23, 90.00, 82, M1206
R6, 73.66, 62.23, 90.00, 150, M1206
R7, 69.85, 62.23, 90.00, 82, M1206
R8, 66.04, 62.23, 90.00, 82, M1206
R9, 58.42, 62.23, 90.00, 150, M1206
Empty file added circuit-board/V6/README.md
Empty file.
4 changes: 2 additions & 2 deletions defaults/caravanpiConfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
<v12CarCheckAlarmResume>1</v12CarCheckAlarmResume>
</caravanpiDefaults>
<adjustmentPosition>
<adjustX>-0.0392267</adjustX>
<adjustY>1.5298374</adjustY>
<adjustX>-0.2353596</adjustX>
<adjustY>1.3729310000000001</adjustY>
<adjustZ>8.9044382</adjustZ>
<toleranceX>0.2</toleranceX>
<toleranceY>0.2</toleranceY>
Expand Down
4 changes: 2 additions & 2 deletions html-flask/checks_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ def check_crontab_pi():

checks_passed = []

checks = ['flask_main', 'temp2file_regular', 'position2file_regular', 'tactileSwitches_boot', 'systemstat2file_boot', 'RTCSerial_boot', 'scales', 'tanks', 'climates']
checks = ['temp2file_regular', 'position2file_regular', 'tactileSwitches_boot', 'systemstat2file_boot', 'RTCSerial_boot', 'scales', 'tanks', 'climates']
check_functions = {
'temp2file_regular': lambda: is_script_present(crontab_lines, 'temp2file.py'),
'position2file_regular': lambda: is_script_present(crontab_lines, 'position2file.py'),
Expand Down Expand Up @@ -666,7 +666,7 @@ def check_crontab_root():

checks_passed = []

checks = ['backup', 'pir', 'logrotate']
checks = ['backup', 'logrotate']
check_functions = {
'backup': lambda: is_script_present(crontab_lines, 'backup.sh'),
'logrotate': lambda: is_script_present(crontab_lines, 'logrotate'),
Expand Down
78 changes: 78 additions & 0 deletions install_CaravanPi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ fi

BOOT_CONFIG_FILE_OLD="/boot/config.txt"
BOOT_CONFIG_FILE_NEW="/boot/firmware/config.txt"
BOOT_CONFIG_FILE="$BOOT_CONFIG_FILE_NEW"

STD_HOSTNAME="CaravanPi"

Expand Down Expand Up @@ -362,6 +363,32 @@ config_protocolls() {
run_cmd "echo \"# CaravanPi Temperatur Sensoren über 1-Wire auf GPIO Pin 18\" | sudo tee -a \"$BOOT_CONFIG_FILE\" > /dev/null"
run_cmd "echo \"dtoverlay=w1-gpio,gpiopin=18\" | sudo tee -a \"$BOOT_CONFIG_FILE\" > /dev/null"
fi

# Prüfung wegen Bildschirm Treiber, so dass vcgencmd den Bildschirm ein- und ausschalten kann
#!/bin/bash

SEARCH_STRING="dtoverlay=vc4-kms-v3d"
CHECK_STRING="# dtoverlay=vc4-kms-v3d"
REPLACE_STRING="# changed for CaravanPi so that vcgencmd could turn off monitor\n# dtoverlay=vc4-kms-v3d\ndtoverlay=vc4-fkms-v3d"

# Überprüfen, ob die Datei existiert
echo "Prüfung und ggf. Wechsel des Bildschirm Treibers"
if [ -f "$BOOT_CONFIG_FILE" ]; then
# Überprüfen, ob die Zeile vorhanden ist
if grep -q "$CHECK_STRING" "$CONFIG_FILE"; then
echo "Die Änderung wurde bereits vorgenommen. Keine weiteren Aktionen erforderlich."
elifif grep -q "$SEARCH_STRING" "$BOOT_CONFIG_FILE"; then
# Ersetze die Zeile durch den gewünschten Text
# Benutze sed, um eine Sicherungskopie vor dem Ersetzen zu erstellen (.bak)
sed -i.bak "/$SEARCH_STRING/c\\$REPLACE_STRING" "$BOOT_CONFIG_FILE"
echo "Die Konfiguration wurde erfolgreich geändert."
else
echo "Der Bildschirm Treiber $SEARCH_STRING wurde nicht gefunden. Keine Änderungen vorgenommen."
fi
else
echo "Die Datei $BOOT_CONFIG_FILE existiert nicht. Überspringe."
fi

}

# Funktion zum Klonen/Aktualisieren des CaravanPi Repositories
Expand Down Expand Up @@ -813,6 +840,44 @@ install_backup() {

}

# Installation Python Module
install_stromPi3() {
echo "Python Modul für StromPi3 installieren ...."
run_cmd "sudo apt-get install python3-serial"

echo "Boot Config um Serielle Kommunikation erweitern ...."

# Zu appendende Zeilen
LINES_TO_APPEND=(
"dtoverlay=miniuart-bt"
"enable_uart=1"
"core_freq=250"
)

# Überprüfe, ob die Datei existiert
if [ -f "$BOOT_CONFIG_FILE" ]; then
for line in "${LINES_TO_APPEND[@]}"; do
# Überprüfe, ob die Zeile bereits existiert
if ! grep -qF -- "$line" "$BOOT_CONFIG_FILE"; then
# Füge die Zeile hinzu, wenn sie nicht existiert
run_cmd "echo \"$line\" | sudo tee -a \"$BOOT_CONFIG_FILE\" > /dev/null"
fi
done
echo "Konfiguration wurde erfolgreich aktualisiert."
fi

echo "Serielle Konfigurationen in raspi-config"
if [ "$SIMULATE" = false ]; then
sudo sed -i 's/console=serial0,115200 //g' /boot/cmdline.txt
sudo bash -c "echo 'enable_uart=1' >> /boot/config.txt"
sudo bash -c "echo 'dtoverlay=miniuart-bt' >> /boot/config.txt"
sudo apt-get install minicom
sudo minicom -D /dev/serial0 -b 38400
fi

}


next_steps() {

note "Abschluss und nächste Schritte" "cyan"
Expand Down Expand Up @@ -881,6 +946,7 @@ echo
echo "Die einzelnen Kommados geben sehr viele Daten aus. Um die Übersicht zu erhöhen folge ich diesen Farb-Codex:"
echo_colored "cyan" "CYAN für Kapitelüberschriften und Abfragen an Sie"
echo_colored "magenta" "MAGENTA für wichtige Informationen"
echo_colored "red" "ROT für die Kommandos, die dieses Skript ausführt"
echo
echo

Expand Down Expand Up @@ -1240,6 +1306,18 @@ python3 $CARAVANPI_DIR/installation/caravanPiLibInit.py

cd "$HOME"

# --------------------------------------------------------------------------
# StromPi3 installieren
# --------------------------------------------------------------------------
note "StromPi3 installieren" "cyan"

read_colored "cyan" "Möchten Sie die Software für den StromPi3 installieren? (j/N): " answer
if [[ "$answer" =~ ^[Jj]$ ]]; then
install_stromPi3
fi

cd "$HOME"

# --------------------------------------------------------------------------
# nächste Schritte
# --------------------------------------------------------------------------
Expand Down
36 changes: 16 additions & 20 deletions levels/freshLevels2file.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,6 @@ def interruptPumpOn(pin):
print(datetime.datetime.now().strftime("%Y%m%d%H%M%S "), "INTERRUPT: Pumpe läuft - Wartezeit: ", waitAfterPumpSeconds, " Sekunden")
pumpOnTime = datetime.datetime.now()


def write2file(liter):
global tank
try:
dateiName = "/home/pi/CaravanPi/values/tank"+'{:.0f}'.format(tank)
file = open(dateiName, 'a')
str_from_time_now = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
strLiter = '{:.0f}'.format(liter)
file.write("\n"+ "tank"+'{:.0f}'.format(tank)+" " + str_from_time_now + " " + strLiter)
file.close()
return 0
except:
# Schreibfehler
print ("Die Datei konnte nicht geschrieben werden.")
return -1



def main():
# -------------------------
Expand Down Expand Up @@ -168,10 +151,13 @@ def main():
for a in args:
print("further argument: ", a)


cplib = CaravanPiFiles()

# -------------------------
# read defaults
# -------------------------
(literLevel1, literLevel2, literLevel3, literLevel4) = CaravanPiFiles.readFillLevels(tank)
(literLevel1, literLevel2, literLevel3, literLevel4) = cplib.readFillLevels(tank)

# -------------------------
# initialize IO Pins on MCP23017
Expand Down Expand Up @@ -257,8 +243,18 @@ def main():
else:
print("mind. "+str(actLiter)+" Liter im Tank")

if writeFile == 1:
write2file(actLiter)
# Sensorwerte verarbeiten
cplib.handle_sensor_values(
displayScreen == 1, # Anzeige am Bildschirm?
"tankfuellgrad", # sensor_name = Datenbankname
f"fresh-{tank}", # sensor_id = Filename und Spalte in der Datenbank
[
"fuellgrad",
], # Liste Spaltennamen
(
actLiter,
) # Tupel Sensorwerte
)

time.sleep(waitAfterPumpSeconds)
except KeyboardInterrupt:
Expand Down
37 changes: 17 additions & 20 deletions levels/wasteLevels2file.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,6 @@ def usage():
print (" -s display values on this screen\n")
print (" -t <nr> welcher Tank soll abgefragt werden\n")


def write2file(liter):
global tank
try:
dateiName = "/home/pi/CaravanPi/values/tank"+'{:.0f}'.format(tank)
file = open(dateiName, 'a')
str_from_time_now = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
strLiter = '{:.0f}'.format(liter)
file.write("\n"+ "tank"+'{:.0f}'.format(tank)+" " + str_from_time_now + " " + strLiter)
file.close()
return 0
except:
# Schreibfehler
print ("Die Datei konnte nicht geschrieben werden.")
return -1



def main():
# -------------------------
Expand Down Expand Up @@ -152,10 +135,13 @@ def main():
for a in args:
print("further argument: ", a)


cplib = CaravanPiFiles()

# -------------------------
# read defaults
# -------------------------
(literLevel1, literLevel2, literLevel3, literLevel4) = CaravanPiFiles.readFillLevels(tank)
(literLevel1, literLevel2, literLevel3, literLevel4) = cplib.readFillLevels(tank)

# -------------------------
# initialize IO Pins on MCP23017
Expand Down Expand Up @@ -212,8 +198,19 @@ def main():
else:
print("mind. "+str(actLiter)+" Liter im Tank")

if writeFile == 1:
write2file(actLiter)
# Sensorwerte verarbeiten
cplib.handle_sensor_values(
displayScreen == 1, # Anzeige am Bildschirm?
"tankfuellgrad", # sensor_name = Datenbankname
f"waste-{tank}", # sensor_id = Filename und Spalte in der Datenbank
[
"fuellgrad",
], # Liste Spaltennamen
(
actLiter,
) # Tupel Sensorwerte
)


time.sleep(waitAfterReadingSeconds)

Expand Down
11 changes: 11 additions & 0 deletions position/gpiozeroTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from gpiozero import Button
from time import sleep

button = Button(6, pull_up=False)

while True:
if button.is_pressed:
print("Button is pressed")
else:
print("Button is not pressed")
sleep(0.5)
Loading

0 comments on commit 213110e

Please sign in to comment.