Arbeitet er gerade eine Anleitung ab?
Wenn ja zeig. Ir den link.
Ich finde dazu auf die schnelle auch nichts.
Arbeitet er gerade eine Anleitung ab?
Wenn ja zeig. Ir den link.
Ich finde dazu auf die schnelle auch nichts.
Mein automatisches Gewächshaus - Scripttuning 2022? Schau mal ob du hier fündig wirst!
nach 4 std laufzeit
pi@raspberrypi:~ $ cd Desktop
pi@raspberrypi:~/Desktop $ python3 Test.py
^[[6~^[[C^[[F^C
pi@raspberrypi:~/Desktop $
pi@raspberrypi:~/Desktop $ python3 Test.py
^C
pi@raspberrypi:~/Desktop $
pi@raspberrypi:~/Desktop $ python3 Test.py
C
^C^CTraceback (most recent call last):
File "/home/pi/Desktop/Test.py", line 271, in main
greenhouse.start()
File "/home/pi/Desktop/Test.py", line 191, in start
self.control_pump()
File "/home/pi/.local/lib/python3.9/site-packages/loguru/_logger.py", line 1226, in catch_wrapper
return function(*args, **kwargs)
File "/home/pi/Desktop/Test.py", line 122, in control_pump
self.get_value_giesomat()
File "/home/pi/.local/lib/python3.9/site-packages/loguru/_logger.py", line 1226, in catch_wrapper
return function(*args, **kwargs)
File "/home/pi/Desktop/Test.py", line 167, in get_value_giesomat
sleep(3)
KeyboardInterrupt
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/Desktop/Test.py", line 285, in <module>
main()
File "/home/pi/.local/lib/python3.9/site-packages/loguru/_logger.py", line 1226, in catch_wrapper
return function(*args, **kwargs)
File "/home/pi/Desktop/Test.py", line 279, in main
sleep(3)
KeyboardInterrupt
pi@raspberrypi:~/Desktop $
pi@raspberrypi:~/Desktop $ python3 Test.py
^Cpi@raspberrypi:~/Desktop $ python3 Test.py
C
^Cpi@raspberrypi:~/Desktop $ python3 Test.py
^C
pi@raspberrypi:~/Desktop $
pi@raspberrypi:~/Desktop $ python3 Test.py
^C#
pi@raspberrypi:~/Desktop $ #
pi@raspberrypi:~/Desktop $ #
pi@raspberrypi:~/Desktop $ python3 Test.py
2022-05-03 11:21:53.170 | ERROR | __main__:control_fan_for_temperature:60 - An error has been caught in function 'control_fan_for_temperature', process 'MainProcess' (1893), thread 'MainThread' (3070163328):
Traceback (most recent call last):
File "/home/pi/Desktop/Test.py", line 285, in <module>
main()
-> <function main at 0xb617a100>
File "/home/pi/Desktop/Test.py", line 271, in main
greenhouse.start()
| -> <function GreenHouse.start at 0xb6234f10>
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/Desktop/Test.py", line 193, in start
self.control_fan_for_temperature()
| -> <function GreenHouse.control_fan_for_temperature at 0xb62341d8>
-> <__main__.GreenHouse object at 0xb6181eb0>
> File "/home/pi/Desktop/Test.py", line 60, in control_fan_for_temperature
self.get_value_aht()
| -> <function GreenHouse.get_value_aht at 0xb6234a48>
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/Desktop/Test.py", line 147, in get_value_aht
self.air_humidity = round(self.aht_device.relative_humidity, 0)
| | | | -> <property object at 0xb6a59f78>
| | | -> <adafruit_ahtx0.AHTx0 object at 0xb622ef88>
| | -> <__main__.GreenHouse object at 0xb6181eb0>
| -> 46.0
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/.local/lib/python3.9/site-packages/adafruit_ahtx0.py", line 130, in relative_humidity
self._readdata()
| -> <function AHTx0._readdata at 0xb6abaec8>
-> <adafruit_ahtx0.AHTx0 object at 0xb622ef88>
File "/home/pi/.local/lib/python3.9/site-packages/adafruit_ahtx0.py", line 145, in _readdata
i2c.write(self._buf, start=0, end=3)
| | | -> bytearray(b'\xac3\x00\xb5\xda\xd2')
| | -> <adafruit_ahtx0.AHTx0 object at 0xb622ef88>
| -> <function I2CDevice.write at 0xb6abaa48>
-> <adafruit_bus_device.i2c_device.I2CDevice object at 0xb6181f28>
File "/home/pi/.local/lib/python3.9/site-packages/adafruit_bus_device/i2c_device.py", line 99, in write
self.i2c.writeto(self.device_address, buf, start=start, end=end)
| | | | | | | -> 3
| | | | | | -> 0
| | | | | -> bytearray(b'\xac3\x00\xb5\xda\xd2')
| | | | -> 56
| | | -> <adafruit_bus_device.i2c_device.I2CDevice object at 0xb6181f28>
| | -> <function I2C.writeto at 0xb6ab2e80>
| -> <busio.I2C object at 0xb622ef40>
-> <adafruit_bus_device.i2c_device.I2CDevice object at 0xb6181f28>
File "/home/pi/.local/lib/python3.9/site-packages/busio.py", line 168, in writeto
return self._i2c.writeto(address, memoryview(buffer)[start:end], stop=stop)
| | | | | | | -> True
| | | | | | -> 3
| | | | | -> 0
| | | | -> bytearray(b'\xac3\x00\xb5\xda\xd2')
| | | -> 56
| | -> <function I2C.writeto at 0xb61b3a48>
| -> <adafruit_blinka.microcontroller.generic_linux.i2c.I2C object at 0xb622efa0>
-> <busio.I2C object at 0xb622ef40>
File "/home/pi/.local/lib/python3.9/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 52, in writeto
self._i2c_bus.write_bytes(address, buffer[start:end])
| | | | | | -> 3
| | | | | -> 0
| | | | -> <memory at 0xb619db08>
| | | -> 56
| | -> <function SMBus.write_bytes at 0xb61b3898>
| -> <Adafruit_PureIO.smbus.SMBus object at 0xb6181e38>
-> <adafruit_blinka.microcontroller.generic_linux.i2c.I2C object at 0xb622efa0>
File "/home/pi/.local/lib/python3.9/site-packages/Adafruit_PureIO/smbus.py", line 314, in write_bytes
self._device.write(buf)
| | | -> <memory at 0xb619daa8>
| | -> <method 'write' of '_io.FileIO' objects>
| -> <_io.FileIO name='/dev/i2c-1' mode='rb+' closefd=True>
-> <Adafruit_PureIO.smbus.SMBus object at 0xb6181e38>
OSError: [Errno 121] Remote I/O error
2022-05-03 11:21:57.487 | ERROR | __main__:start:191 - An error has been caught in function 'start', process 'MainProcess' (1893), thread 'MainThread' (3070163328):
Traceback (most recent call last):
File "/home/pi/Desktop/Test.py", line 285, in <module>
main()
-> <function main at 0xb617a100>
File "/home/pi/Desktop/Test.py", line 271, in main
greenhouse.start()
| -> <function GreenHouse.start at 0xb6234f10>
-> <__main__.GreenHouse object at 0xb6181eb0>
> File "/home/pi/Desktop/Test.py", line 191, in start
self.control_pump()
| -> <function GreenHouse.control_pump at 0xb6234898>
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/Desktop/Test.py", line 137, in control_pump
self.update_display((3, 8), " ")
| -> <function GreenHouse.update_display at 0xb6234fa0>
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/Desktop/Test.py", line 206, in update_display
self.lcd.cursor_pos = cursor
| | | -> (3, 8)
| | -> <property object at 0xb6231c80>
| -> <RPLCD.i2c.CharLCD object at 0xb622eef8>
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/.local/lib/python3.9/site-packages/RPLCD/lcd.py", line 158, in _set_cursor_pos
self.command(c.LCD_SETDDRAMADDR | row_offsets[value[0]] + value[1])
| | | | | | -> (3, 8)
| | | | | -> (3, 8)
| | | | -> [0, 64, 20, 84]
| | | -> 128
| | -> <module 'RPLCD.common' from '/home/pi/.local/lib/python3.9/site-packages/RPLCD/common.py'>
| -> <function BaseCharLCD.command at 0xb6229bb0>
-> <RPLCD.i2c.CharLCD object at 0xb622eef8>
File "/home/pi/.local/lib/python3.9/site-packages/RPLCD/lcd.py", line 381, in command
self._send_instruction(value)
| | -> 220
| -> <function CharLCD._send_instruction at 0xb6229e80>
-> <RPLCD.i2c.CharLCD object at 0xb622eef8>
File "/home/pi/.local/lib/python3.9/site-packages/RPLCD/i2c.py", line 240, in _send_instruction
self.bus.write_byte(self._address, (c.RS_INSTRUCTION |
| | | | | | -> 0
| | | | | -> <module 'RPLCD.common' from '/home/pi/.local/lib/python3.9/site-packages/RPLCD/common.py'>
| | | | -> 39
| | | -> <RPLCD.i2c.CharLCD object at 0xb622eef8>
| | -> <method 'write_byte' of 'SMBus' objects>
| -> <SMBus object at 0xb622ef68>
-> <RPLCD.i2c.CharLCD object at 0xb622eef8>
OSError: [Errno 121] Remote I/O error
2022-05-03 11:21:58.364 | ERROR | __main__:<module>:285 - An error has been caught in function '<module>', process 'MainProcess' (1893), thread 'MainThread' (3070163328):
Traceback (most recent call last):
> File "/home/pi/Desktop/Test.py", line 285, in <module>
main()
-> <function main at 0xb617a100>
File "/home/pi/Desktop/Test.py", line 271, in main
greenhouse.start()
| -> <function GreenHouse.start at 0xb6234f10>
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/Desktop/Test.py", line 192, in start
self.control_heating_map()
| -> <function GreenHouse.control_heating_map at 0xb62347c0>
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/Desktop/Test.py", line 103, in control_heating_map
self.update_display((2, 8), chr(3))
| -> <function GreenHouse.update_display at 0xb6234fa0>
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/Desktop/Test.py", line 206, in update_display
self.lcd.cursor_pos = cursor
| | | -> (2, 8)
| | -> <property object at 0xb6231c80>
| -> <RPLCD.i2c.CharLCD object at 0xb622eef8>
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/.local/lib/python3.9/site-packages/RPLCD/lcd.py", line 158, in _set_cursor_pos
self.command(c.LCD_SETDDRAMADDR | row_offsets[value[0]] + value[1])
| | | | | | -> (2, 8)
| | | | | -> (2, 8)
| | | | -> [0, 64, 20, 84]
| | | -> 128
| | -> <module 'RPLCD.common' from '/home/pi/.local/lib/python3.9/site-packages/RPLCD/common.py'>
| -> <function BaseCharLCD.command at 0xb6229bb0>
-> <RPLCD.i2c.CharLCD object at 0xb622eef8>
File "/home/pi/.local/lib/python3.9/site-packages/RPLCD/lcd.py", line 381, in command
self._send_instruction(value)
| | -> 156
| -> <function CharLCD._send_instruction at 0xb6229e80>
-> <RPLCD.i2c.CharLCD object at 0xb622eef8>
File "/home/pi/.local/lib/python3.9/site-packages/RPLCD/i2c.py", line 240, in _send_instruction
self.bus.write_byte(self._address, (c.RS_INSTRUCTION |
| | | | | | -> 0
| | | | | -> <module 'RPLCD.common' from '/home/pi/.local/lib/python3.9/site-packages/RPLCD/common.py'>
| | | | -> 39
| | | -> <RPLCD.i2c.CharLCD object at 0xb622eef8>
| | -> <method 'write_byte' of 'SMBus' objects>
| -> <SMBus object at 0xb622ef68>
-> <RPLCD.i2c.CharLCD object at 0xb622eef8>
OSError: [Errno 121] Remote I/O error
Alles anzeigen
Haste die Lib installiert?
Dann probier das Programm aus:
"""Simple test for I2C RGB character LCD shield kit"""
import time
import board
import adafruit_character_lcd.character_lcd_rgb_i2c as character_lcd
# Modify this if you have a different sized Character LCD
lcd_columns = 16
lcd_rows = 2
# Initialise I2C bus.
i2c = board.I2C() # uses board.SCL and board.SDA
# Initialise the LCD class
lcd = character_lcd.Character_LCD_RGB_I2C(i2c, lcd_columns, lcd_rows, address=0x27)
lcd.clear()
# Set LCD color to red
lcd.color = [100, 0, 0]
time.sleep(1)
# Print two line message
lcd.message = "Hello\nCircuitPython"
# Wait 5s
time.sleep(5)
# Set LCD color to blue
lcd.color = [0, 100, 0]
time.sleep(1)
# Set LCD color to green
lcd.color = [0, 0, 100]
time.sleep(1)
# Set LCD color to purple
lcd.color = [50, 0, 50]
time.sleep(1)
lcd.clear()
# Print two line message right to left
lcd.text_direction = lcd.RIGHT_TO_LEFT
lcd.message = "Hello\nCircuitPython"
# Wait 5s
time.sleep(5)
# Return text direction to left to right
lcd.text_direction = lcd.LEFT_TO_RIGHT
# Display cursor
lcd.clear()
lcd.cursor = True
lcd.message = "Cursor! "
# Wait 5s
time.sleep(5)
# Display blinking cursor
lcd.clear()
lcd.blink = True
lcd.message = "Blinky Cursor!"
# Wait 5s
time.sleep(5)
lcd.blink = False
lcd.clear()
# Create message to scroll
scroll_msg = "<-- Scroll"
lcd.message = scroll_msg
# Scroll to the left
for i in range(len(scroll_msg)):
time.sleep(0.5)
lcd.move_left()
lcd.clear()
time.sleep(1)
lcd.message = "Going to sleep\nCya later!"
time.sleep(5)
# Turn off LCD backlights and clear text
lcd.color = [0, 0, 0]
lcd.clear()
Alles anzeigen
Haste die Lib installiert?
Dann probier das Programm aus:
Python Alles anzeigen"""Simple test for I2C RGB character LCD shield kit""" import time import board import adafruit_character_lcd.character_lcd_rgb_i2c as character_lcd # Modify this if you have a different sized Character LCD lcd_columns = 16 lcd_rows = 2 # Initialise I2C bus. i2c = board.I2C() # uses board.SCL and board.SDA # Initialise the LCD class lcd = character_lcd.Character_LCD_RGB_I2C(i2c, lcd_columns, lcd_rows, address=0x27) lcd.clear() # Set LCD color to red lcd.color = [100, 0, 0] time.sleep(1) # Print two line message lcd.message = "Hello\nCircuitPython" # Wait 5s time.sleep(5) # Set LCD color to blue lcd.color = [0, 100, 0] time.sleep(1) # Set LCD color to green lcd.color = [0, 0, 100] time.sleep(1) # Set LCD color to purple lcd.color = [50, 0, 50] time.sleep(1) lcd.clear() # Print two line message right to left lcd.text_direction = lcd.RIGHT_TO_LEFT lcd.message = "Hello\nCircuitPython" # Wait 5s time.sleep(5) # Return text direction to left to right lcd.text_direction = lcd.LEFT_TO_RIGHT # Display cursor lcd.clear() lcd.cursor = True lcd.message = "Cursor! " # Wait 5s time.sleep(5) # Display blinking cursor lcd.clear() lcd.blink = True lcd.message = "Blinky Cursor!" # Wait 5s time.sleep(5) lcd.blink = False lcd.clear() # Create message to scroll scroll_msg = "<-- Scroll" lcd.message = scroll_msg # Scroll to the left for i in range(len(scroll_msg)): time.sleep(0.5) lcd.move_left() lcd.clear() time.sleep(1) lcd.message = "Going to sleep\nCya later!" time.sleep(5) # Turn off LCD backlights and clear text lcd.color = [0, 0, 0] lcd.clear()
Sorry das ich mich die letzten Wochen nicht melden Konnte ich war wieder ma in einem Land das Hilfe braucht da ich für ein Jahr noch diese Hilfe für das Land machen werde muss ich das gemeinsame ( Sorry) Projekt beenden ich werde nur noch sporadisch zuhause sein. Deshalb werde ich alle Raspberrys verkaufen falls du indessen hast ich mache für dich einen Guten Preis da du mir so viel geholfen hast. Es Sind 2 4 er und 3 er müsste aber noch mal nach schauen kann ich jetzt so nicht sagen ich sage Danke und hoffe das ich jetzt Menschen Helfen kann die auch mal meine Hilfe benötigen.
Grüße,
muss ich das gemeinsame ( Sorry) Projekt beenden
Puuuhhh......das ist ärgerlich. Da wir ordentlich Zeit in das Projekt versenkt haben. Vllt findet sich wer anderes der das Gewächshaus nachbauen will und das Script testen kann.
hoffe das ich jetzt Menschen Helfen kann die auch mal meine Hilfe benötigen.
Dann wünsch ich dir viel Erfolg. Halt die Ohren steif.
Ansonsten werde ich, in den nächsten Tagen, bis hier hin nochmal eine kleine Zusammenfassung schreiben.
Ich habe das ganze nun mal hierher ausgelagert, weil der andere Thread ein abgeschlossenes Projekt ist und die mehr als 500 Beiträge damit eigentlich wenig zu tun haben.
Übersicht zum Gewächshausscript - Aktueller stand / Abhängigkeiten usw.. - Mai 2022
Erstmal Danke an hyle und Dennis89 da sie mir dabei geholfen haben das Script neu zuschreiben, Ich hätte das alleine sicher nicht hinbekommen.
Die Originalanleitung findet man unter naturetec-live
Der eigentliche Thread - Mein automatisches Gewächshaus :-)
Da es Probleme mit dem O-Script gab haben wir das ganze aktualisiert.
Es gibt aber noch das ein oder andere zu tun.
Infos dazu weiter unten.
Funktionsweise des Scripts:
Eingabe aller Werte in einer Config-Datei.
Ausgabe aller Werte über ein i2c Standard LCD Display (hd44780) + Datum + Uhrzeit + Symbole.
Messen von:
- Lufttemperatur
- Luftfeuchtigkeit
- Erdtemperatur
- Erdfeuchtigkeit
Steuern von:
- Lüfter
- Bodenheizung
- Bewässerung
- Licht
Licht wird über Zeit gesteuert.
Lüfter können über Zeit oder Luftfeuchtigkeit gesteuert werden.
Festlegen von Grenzwerten zur Steuerung der Lüfter, Bodenheizung, Bewässerung, Licht
Installation Betriebssystem Raspbian OS:
Abhängigkeiten:
RPLCD pip3 install RPLCD
schedule pip3 install schedule
toml pip3 install toml
loguru pip3 install loguru
ahtx0 pip3 install adafruit-circuitpython-ahtx0
Empfehlung zum Autostart:
raspberrypi.com - Systemd Service Unit
thedigitalpictureframe - ultimate_guide_systemd
Lufttemperatur und Luftfeuchte:
Adafruit empfiehlt den DHT nicht mehr, da diese Sensoren nicht mehr Stand der Technik sind.
Dazu gibt es bei Adafruit ein Overview.
Probleme mit dem AHT20:
Wir hatten im laufe der Tests Probleme mit dem AHT20. Das Script läuft an sich, schmiert aber nach Stunden ab.
Folgender Fehler lief dabei auf:
2022-05-03 11:21:53.170 | ERROR | __main__:control_fan_for_temperature:60 - An error has been caught in function 'control_fan_for_temperature', process 'MainProcess' (1893), thread 'MainThread' (3070163328):
Traceback (most recent call last):
File "/home/pi/Desktop/Test.py", line 285, in <module>
main()
-> <function main at 0xb617a100>
File "/home/pi/Desktop/Test.py", line 271, in main
greenhouse.start()
| -> <function GreenHouse.start at 0xb6234f10>
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/Desktop/Test.py", line 193, in start
self.control_fan_for_temperature()
| -> <function GreenHouse.control_fan_for_temperature at 0xb62341d8>
-> <__main__.GreenHouse object at 0xb6181eb0>
> File "/home/pi/Desktop/Test.py", line 60, in control_fan_for_temperature
self.get_value_aht()
| -> <function GreenHouse.get_value_aht at 0xb6234a48>
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/Desktop/Test.py", line 147, in get_value_aht
self.air_humidity = round(self.aht_device.relative_humidity, 0)
| | | | -> <property object at 0xb6a59f78>
| | | -> <adafruit_ahtx0.AHTx0 object at 0xb622ef88>
| | -> <__main__.GreenHouse object at 0xb6181eb0>
| -> 46.0
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/.local/lib/python3.9/site-packages/adafruit_ahtx0.py", line 130, in relative_humidity
self._readdata()
| -> <function AHTx0._readdata at 0xb6abaec8>
-> <adafruit_ahtx0.AHTx0 object at 0xb622ef88>
File "/home/pi/.local/lib/python3.9/site-packages/adafruit_ahtx0.py", line 145, in _readdata
i2c.write(self._buf, start=0, end=3)
| | | -> bytearray(b'\xac3\x00\xb5\xda\xd2')
| | -> <adafruit_ahtx0.AHTx0 object at 0xb622ef88>
| -> <function I2CDevice.write at 0xb6abaa48>
-> <adafruit_bus_device.i2c_device.I2CDevice object at 0xb6181f28>
File "/home/pi/.local/lib/python3.9/site-packages/adafruit_bus_device/i2c_device.py", line 99, in write
self.i2c.writeto(self.device_address, buf, start=start, end=end)
| | | | | | | -> 3
| | | | | | -> 0
| | | | | -> bytearray(b'\xac3\x00\xb5\xda\xd2')
| | | | -> 56
| | | -> <adafruit_bus_device.i2c_device.I2CDevice object at 0xb6181f28>
| | -> <function I2C.writeto at 0xb6ab2e80>
| -> <busio.I2C object at 0xb622ef40>
-> <adafruit_bus_device.i2c_device.I2CDevice object at 0xb6181f28>
File "/home/pi/.local/lib/python3.9/site-packages/busio.py", line 168, in writeto
return self._i2c.writeto(address, memoryview(buffer)[start:end], stop=stop)
| | | | | | | -> True
| | | | | | -> 3
| | | | | -> 0
| | | | -> bytearray(b'\xac3\x00\xb5\xda\xd2')
| | | -> 56
| | -> <function I2C.writeto at 0xb61b3a48>
| -> <adafruit_blinka.microcontroller.generic_linux.i2c.I2C object at 0xb622efa0>
-> <busio.I2C object at 0xb622ef40>
File "/home/pi/.local/lib/python3.9/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 52, in writeto
self._i2c_bus.write_bytes(address, buffer[start:end])
| | | | | | -> 3
| | | | | -> 0
| | | | -> <memory at 0xb619db08>
| | | -> 56
| | -> <function SMBus.write_bytes at 0xb61b3898>
| -> <Adafruit_PureIO.smbus.SMBus object at 0xb6181e38>
-> <adafruit_blinka.microcontroller.generic_linux.i2c.I2C object at 0xb622efa0>
File "/home/pi/.local/lib/python3.9/site-packages/Adafruit_PureIO/smbus.py", line 314, in write_bytes
self._device.write(buf)
| | | -> <memory at 0xb619daa8>
| | -> <method 'write' of '_io.FileIO' objects>
| -> <_io.FileIO name='/dev/i2c-1' mode='rb+' closefd=True>
-> <Adafruit_PureIO.smbus.SMBus object at 0xb6181e38>
OSError: [Errno 121] Remote I/O error
2022-05-03 11:21:57.487 | ERROR | __main__:start:191 - An error has been caught in function 'start', process 'MainProcess' (1893), thread 'MainThread' (3070163328):
Traceback (most recent call last):
File "/home/pi/Desktop/Test.py", line 285, in <module>
main()
-> <function main at 0xb617a100>
File "/home/pi/Desktop/Test.py", line 271, in main
greenhouse.start()
| -> <function GreenHouse.start at 0xb6234f10>
-> <__main__.GreenHouse object at 0xb6181eb0>
> File "/home/pi/Desktop/Test.py", line 191, in start
self.control_pump()
| -> <function GreenHouse.control_pump at 0xb6234898>
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/Desktop/Test.py", line 137, in control_pump
self.update_display((3, 8), " ")
| -> <function GreenHouse.update_display at 0xb6234fa0>
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/Desktop/Test.py", line 206, in update_display
self.lcd.cursor_pos = cursor
| | | -> (3, 8)
| | -> <property object at 0xb6231c80>
| -> <RPLCD.i2c.CharLCD object at 0xb622eef8>
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/.local/lib/python3.9/site-packages/RPLCD/lcd.py", line 158, in _set_cursor_pos
self.command(c.LCD_SETDDRAMADDR | row_offsets[value[0]] + value[1])
| | | | | | -> (3, 8)
| | | | | -> (3, 8)
| | | | -> [0, 64, 20, 84]
| | | -> 128
| | -> <module 'RPLCD.common' from '/home/pi/.local/lib/python3.9/site-packages/RPLCD/common.py'>
| -> <function BaseCharLCD.command at 0xb6229bb0>
-> <RPLCD.i2c.CharLCD object at 0xb622eef8>
File "/home/pi/.local/lib/python3.9/site-packages/RPLCD/lcd.py", line 381, in command
self._send_instruction(value)
| | -> 220
| -> <function CharLCD._send_instruction at 0xb6229e80>
-> <RPLCD.i2c.CharLCD object at 0xb622eef8>
File "/home/pi/.local/lib/python3.9/site-packages/RPLCD/i2c.py", line 240, in _send_instruction
self.bus.write_byte(self._address, (c.RS_INSTRUCTION |
| | | | | | -> 0
| | | | | -> <module 'RPLCD.common' from '/home/pi/.local/lib/python3.9/site-packages/RPLCD/common.py'>
| | | | -> 39
| | | -> <RPLCD.i2c.CharLCD object at 0xb622eef8>
| | -> <method 'write_byte' of 'SMBus' objects>
| -> <SMBus object at 0xb622ef68>
-> <RPLCD.i2c.CharLCD object at 0xb622eef8>
OSError: [Errno 121] Remote I/O error
2022-05-03 11:21:58.364 | ERROR | __main__:<module>:285 - An error has been caught in function '<module>', process 'MainProcess' (1893), thread 'MainThread' (3070163328):
Traceback (most recent call last):
> File "/home/pi/Desktop/Test.py", line 285, in <module>
main()
-> <function main at 0xb617a100>
File "/home/pi/Desktop/Test.py", line 271, in main
greenhouse.start()
| -> <function GreenHouse.start at 0xb6234f10>
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/Desktop/Test.py", line 192, in start
self.control_heating_map()
| -> <function GreenHouse.control_heating_map at 0xb62347c0>
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/Desktop/Test.py", line 103, in control_heating_map
self.update_display((2, 8), chr(3))
| -> <function GreenHouse.update_display at 0xb6234fa0>
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/Desktop/Test.py", line 206, in update_display
self.lcd.cursor_pos = cursor
| | | -> (2, 8)
| | -> <property object at 0xb6231c80>
| -> <RPLCD.i2c.CharLCD object at 0xb622eef8>
-> <__main__.GreenHouse object at 0xb6181eb0>
File "/home/pi/.local/lib/python3.9/site-packages/RPLCD/lcd.py", line 158, in _set_cursor_pos
self.command(c.LCD_SETDDRAMADDR | row_offsets[value[0]] + value[1])
| | | | | | -> (2, 8)
| | | | | -> (2, 8)
| | | | -> [0, 64, 20, 84]
| | | -> 128
| | -> <module 'RPLCD.common' from '/home/pi/.local/lib/python3.9/site-packages/RPLCD/common.py'>
| -> <function BaseCharLCD.command at 0xb6229bb0>
-> <RPLCD.i2c.CharLCD object at 0xb622eef8>
File "/home/pi/.local/lib/python3.9/site-packages/RPLCD/lcd.py", line 381, in command
self._send_instruction(value)
| | -> 156
| -> <function CharLCD._send_instruction at 0xb6229e80>
-> <RPLCD.i2c.CharLCD object at 0xb622eef8>
File "/home/pi/.local/lib/python3.9/site-packages/RPLCD/i2c.py", line 240, in _send_instruction
self.bus.write_byte(self._address, (c.RS_INSTRUCTION |
| | | | | | -> 0
| | | | | -> <module 'RPLCD.common' from '/home/pi/.local/lib/python3.9/site-packages/RPLCD/common.py'>
| | | | -> 39
| | | -> <RPLCD.i2c.CharLCD object at 0xb622eef8>
| | -> <method 'write_byte' of 'SMBus' objects>
| -> <SMBus object at 0xb622ef68>
-> <RPLCD.i2c.CharLCD object at 0xb622eef8>
OSError: [Errno 121] Remote I/O error
Alles anzeigen
Hier weiß ich nicht ob es zu Problemen mit dem board- und dem RPLCD - Modul kommt oder ob die Verkabelung unzureichend war.
Wenn ein anderer Sensor als der AHT verwendet werden soll, muss das Im Script angepasst werden.
Experimentell, da nicht getestet:
Ich würde auf den BME280 ausweichen und ein Modul suchen welches nicht das board - Modul nutzt.
Wobei ich aber nicht weiß ob das ganze dann wirklich funktioniert.
Mögliche Module für den BME280:
github - pimoroni/bme280-python
ODER
man nutzt den AHT und kauft sich ein LCD Button Shield von Adafruit + 4x20 LCD und lötet, statt das mitgelieferte 2x16 LCD, das 4x20 LCD auf die Platine. Welches dann auch das board Modul von Adafruit nutzt.
Das habe ich schon gemacht und das funktioniert auch recht gut. Nur hatte ich kein AHT.
Man braucht dann aber folgendes Modul:
Installation circuitpython - LCD + adafruit-character-lcd-character-lcd-rgb-i2c. RGB gibt es dann aber nicht.
Die Doku ist etwas durcheinander.
WICHTIG:
Das 4x20 Display passt dann nicht mehr auf die Platine. Entweder man bastelt sich irgendwelche Abstandshalter oder man setzt das Display neben das Shield.
Das ganze läuft dann ebenfalls über i2c. Man braucht also nur 4 Pins.
5V, GND, SDA und SCL.
Erdfeuchtemessung:
Das ganze läuft über einen ESP32 da der Pi keine vernünftigen Werte liefert.
Dazu muss der Giesomat an den ESP32 und der ESP32 via USB an den Pi angeschlossen werden.
Folgende Lib muss in die Arduino IDE eingefügt werden:
An Pin 14 kommt der Output vom Giesomaten
#include "FreqCountESP.h"
int inputPin = 14;
int timerMs = 1000;
void setup()
{
Serial.begin(57600);
FreqCountESP.begin(inputPin, timerMs);
}
void loop()
{
if (FreqCountESP.available())
{
uint32_t frequency = FreqCountESP.read();
Serial.println(frequency);
}
}
Alles anzeigen
To-Do:
- Lösung für das OSError: [Errno 121] Remote I/O error finden.
- Zeitschaltung für das Licht bearbeiten.
- Nur neu gemessene Werte auf Display ausgeben anstatt alles neu auszugeben.
- Config-Datei und Script für die Übergabe der i2c - Adressen anpassen.
Config- Datei:
Die muss im selben Verzeichnis wie die Steuerung liegen, sonst werden die Einstellungen nicht im Script übernommen.
############################# - Konfiguration zum automatisches Gewächshaus - ##########################
#################################### Einstellungen für den Betrieb #####################################
########################################################################################################
# Lüftersteuerung
#
# 1. entweder Steuerung nach Zeit dann steuerung_nach = "zeit" angeben
# wenn "zeit" gewählt wurde können nochmal 2 Schaltmodi angegeben werden:
# 1. zeit_steuerung = "taeglich"
# Luefter läuft zwischen 2 Uhrzeiten durch. Hier für wird eine start- und endzeit benötigt.
# Bsp.: Luefter sollen zwischen 07:00 - 10:00 laufen,
# dann start_zeit_t = "07:00"
# end_zeit_t= "10:00"
# Die restlichen Zeiteinstellungen werden dann nicht berücksichtigt.
# oder
# 2. zeit_steuerung = "stuendlich"
# Luefter läuft zwischen 2 Uhrzeiten, jede X Stunde für X Minuten
# Bsp.: Luefter sollen zwischen 06:00 - 19:00 stündlich 10 min laufen,
# dann start_zeit_t = "06:00" <---- Startzeitraum
# end_zeit_t= "19:00" <---- Endzeitraum
#
# jede_xte_std = 1 <---- stündlich oder jede 2., 3. Std. möglich
#
# start_zeit_s = ":30" <---- Luefter an
# end_zeit_s = ":40" <---- Luefter aus
#
# oder
# 2. Steurung nach gemessener Luftfeuchtigkeit dann steuerung_nach = "luftfeuchtigkeit" angeben
#
########################################################################################################
[Luefter]
steuerung_nach = "zeit"
[Zeitsteuerung]
zeit_steuerung = "stuendlich"
start_zeit_t = "07:00"
end_zeit_t= "20:00"
jede_xte_std = 1
start_zeit_s = ":35"
end_zeit_s = ":40"
########################################################################################################
# Lüfter Luftfeuchtesteuerung aktiv wenn steuerung_nach = "luftfeuchtigkeit"
# Grenzwerte
########################################################################################################
[Steuerung_nach_Luftfeuchte]
luftfeuchte_min = 40
luftfeuchte_max = 60
########################################################################################################
# Uhrzeiten für Licht
# "HH:MM"
########################################################################################################
[Lichtsteuerung]
start_zeit_licht = "07:00"
end_zeit_licht = "20:00"
########################################################################################################
# Grenzwerte für Heizmatte,
# Bewaesserung,
# Lufttemperatur,
# Giesomat
#
########################################################################################################
[Heizmatte]
erd_temperatur_min = 25
erd_temperatur_max = 28
[Bewaesserung]
erd_feuchtigkeit_min = 70
erd_feuchtigkeit_max = 80
[Lufttemperatur]
lufttemperatur_min = 25
lufttemperatur_max = 28
# Giesomat Frequenzeinstellungen
[Giesomat]
niedrigste_frequenz = 12300
hoechste_frequenz = 43400
############### Einstellungen der GPIO bzw. Adressen für Sensoren, Display usw. #######################
########################################################################################################
# Sensoren GPIO-Nummer
########################################################################################################
[Sensoren]
ds18b20 = "28-e46d581e64ff" <--- Adresse auslesen
dht_model = 22
#dht_pin = 22 <--- BME oder AHT nutzen (i2c) - muss im Script angepasst werden
giesomat_pin = 21
########################################################################################################
# Gerätebezeichnung und GPIO-Nummer
########################################################################################################
[Devices]
licht = 17
pumpe = 23
luefter = 24
heizmatte = 25
########################################################################################################
# LCD DISPLAY HD44780 4x20 I2
########################################################################################################
# Adress muss im Script angepasst werden
#[hd44780]
#i2c_chip = "PCF8574"
#lcd_adresse = "0x27"
########################################################################################################
# Display-Symbole
########################################################################################################
[Symbole]
thermometer = [4, 10, 10, 10, 10, 17, 31, 14]
tropfen = [2, 6, 6, 14, 15, 31, 31, 14]
grad = [12, 18, 18, 12, 0, 0, 0, 0]
pfeil_hoch = [4, 10, 17, 0, 4, 10, 17, 0]
pfeil_runter = [17, 10, 4, 0, 17, 10, 4, 0]
licht_an = [4, 21, 10, 10, 21, 4, 0, 0]
luefter_1 = [8, 21, 2, 8, 21, 2, 0, 0]
luefter_2 = [14, 21, 21, 23, 17, 14, 0, 0]
Alles anzeigen
Gewächshausscript
#!/usr/bin/python3
import re
import adafruit_ahtx0
import board
import schedule
import serial
import toml
from datetime import datetime
from pathlib import Path
from threading import Thread
from time import sleep
from gpiozero import DigitalOutputDevice
from loguru import logger
from RPLCD.i2c import CharLCD
LOG_FILE = Path("/home/pi/GreenHouse/logfile.log")
class GreenHouse:
def __init__(self, config, lcd, output_devices, aht_device):
self.time_control = None
self.humidity_control = None
self.earth_humidity = None
self.earth_temperature = None
self.air_humidity = None
self.air_temperature = None
self.config = config
self.lcd = lcd
self.output_devices = output_devices
self.aht_device = aht_device
def control_fan_for_humidity(self):
while True:
self.get_value_aht()
if self.air_humidity is None:
sleep(1)
continue
if (
self.air_humidity
>= self.config["Steuerung_nach_Luftfeuchte"]["luftfeuchte_max"]
):
self.output_devices["luefter"].on()
self.update_display((3, 19), chr(4))
elif (
self.air_humidity
<= self.config["Steuerung_nach_Luftfeuchte"]["luftfeuchte_min"]
):
self.output_devices["luefter"].off()
self.update_display((3, 19), " ")
else:
self.update_display((3, 19), "ok")
sleep(5)
def control_fan_for_temperature(self):
self.get_value_dht()
if self.air_temperature is not None:
if (
self.air_temperature
>= self.config["Lufttemperatur"]["lufttemperatur_max"]
):
self.output_devices["luefter"].on()
self.update_display((2, 8), chr(4))
elif (
self.air_temperature
<= self.config["Lufttemperatur"]["lufttemperatur_min"]
):
self.output_devices["luefter"].off()
self.update_display((2, 8), " ")
else:
self.update_display((2, 8), "ok")
def control_fan_for_time(self):
display_values = {(0, 9): chr(6), (0, 10): chr(7)}
for cursor in display_values:
self.update_display(cursor, display_values[cursor])
sleep(0.5)
if self.config["Zeitsteuerung"]["zeit_steuerung"] == "taeglich":
schedule.every().day.at(self.config["Zeitsteuerung"]["start_zeit_t"]).do(
self.output_devices["luefter"].on
)
schedule.every().day.at(self.config["Zeitsteuerung"]["end_zeit_t"]).do(
self.output_devices["luefter"].off
)
elif self.config["Zeitsteuerung"]["zeit_steuerung"] == "stündlich":
schedule.every(self.config["Zeitsteuerung"]["jede_xte_std"]).hours.at(
self.config["Zeitsteuerung"]["start_zeit_s"]
).do(self.output_devices["luefter"].on)
schedule.every(self.config["Zeitsteuerung"]["jede_xte_std"]).hours.at(
self.config["Zeitsteuerung"]["end_zeit_s"]
).do(self.output_devices["luefter"].off)
def control_heating_map(self):
self.get_value_ds18b20()
if self.earth_temperature is not None:
if self.earth_temperature <= self.config["Heizmatte"]["erd_temperatur_min"]:
self.output_devices["heizmatte"].on()
self.update_display((2, 8), chr(3))
elif (
self.earth_temperature >= self.config["Heizmatte"]["erd_temperatur_max"]
):
self.output_devices["heizmatte"].off()
self.update_display((2, 8), " ")
else:
self.update_display((2, 8), "ok")
def control_light(self):
schedule.every().day.at(self.config["Lichtsteuerung"]["start_zeit_licht"]).do(
self.output_devices["licht"].on
)
schedule.every().day.at(self.config["Lichtsteuerung"]["end_zeit_licht"]).do(
self.output_devices["licht"].off
)
@logger.catch
def control_pump(self):
self.get_value_giesomat()
try:
if (
self.earth_humidity
<= self.config["Bewaesserung"]["erd_feuchtigkeit_min"]
):
self.output_devices["pumpe"].on()
self.update_display((3, 8), chr(3))
sleep(10)
self.output_devices["pumpe"].off()
elif (
self.earth_humidity
>= self.config["Bewaesserung"]["erd_feuchtigkeit_max"]
):
self.output_devices["pumpe"].off()
self.update_display((3, 8), " ")
else:
self.update_display((3, 8), "ok")
except TypeError:
self.output_devices["pumpe"].off()
self.update_display((3, 8), " ")
@logger.catch
def get_value_aht(self):
try:
self.air_humidity = round(self.aht_device.humidity, 0)
self.air_temperature = round(self.aht_device.temperature, 0)
except RuntimeError:
self.air_humidity = self.air_temperature = None
@logger.catch
def get_value_ds18b20(self):
try:
sensor_data = Path(
"/sys/bus/w1/devices", self.config["Sensoren"]["ds18b20"], "w1_slave"
).read_text(encoding="UTF-8")
if re.search(r"crc=\d+ YES", sensor_data):
earth_temperature = (
int(re.search(r"t=(\d+)", sensor_data).group(1)) // 1000
)
self.earth_temperature = earth_temperature
else:
self.earth_temperature = None
except FileNotFoundError:
self.earth_temperature = None
@logger.catch
def get_value_giesomat(self):
try:
with serial.Serial("/dev/ttyUSB0", 57600, timeout=1) as connection:
sleep(3)
frequency = connection.readline().decode("utf8")
try:
self.earth_humidity = round(
(int(frequency) - self.config["Giesomat"]["hoechste_frequenz"])
/ (self.config["Giesomat"]["niedrigste_frequenz"]
- self.config["Giesomat"]["hoechste_frequenz"])
* 100)
except ValueError:
self.earth_humidity = None
except serial.SerialException:
self.earth_humidity = None
def start(self):
self.control_light()
if self.time_control:
self.control_fan_for_time()
elif self.humidity_control:
Thread(target=self.control_fan_for_humidity).start()
while True:
schedule.run_pending()
self.control_pump()
self.control_heating_map()
self.control_fan_for_temperature()
self.write_lcd_output()
sleep(1)
def setting_up_controlling(self):
if self.config["Luefter"]["steuerung_nach"] == "zeit":
self.time_control = True
self.humidity_control = False
elif self.config["Luefter"]["steuerung_nach"] == "luftfeuchtigkeit":
self.humidity_control = True
self.time_control = False
def update_display(self, cursor, text):
self.lcd.cursor_pos = cursor
self.lcd.write_string(text)
def write_lcd_output(self):
self.lcd.clear()
sensor_values = [
self.earth_humidity,
self.earth_temperature,
self.air_humidity,
self.air_temperature,
]
sensor_values = [
value if value is not None else "Fehler" for value in sensor_values
]
display_values = {
(0, 0): datetime.now().strftime("%d.%b"),
(0, 15): datetime.now().strftime("%H:%M"),
(1, 0): "--ERDE--- --LUFT---",
(3, 0): f"{chr(1)}{sensor_values[0]} %",
(2, 0): f"{chr(0)}{sensor_values[1]}{chr(2)} C",
(3, 11): f"{chr(1)}{sensor_values[2]} %",
(2, 11): f"{chr(0)}{sensor_values[3]}{chr(2)} C",
}
for cursor in display_values:
self.update_display(cursor, display_values[cursor])
if self.output_devices["licht"].value:
self.update_display((0, 12), chr(5))
else:
self.update_display((0, 12), " ")
def load_config_file():
return toml.loads(
Path.joinpath(Path(__file__).parent.absolute(), "greenhouse.conf").read_text()
)
def setup_lcd(lcd, config):
for number, symbol in enumerate(config["Symbole"]):
lcd.create_char(number, tuple(config["Symbole"][symbol]))
@logger.catch
def main():
logger.add(
LOG_FILE, backtrace=True, diagnose=True, format="{time:HH:mm:ss} {message}"
)
config = load_config_file()
lcd = CharLCD("PCF8574", 0x27)
try:
setup_lcd(lcd, config)
output_devices = {}
for device in config["Devices"]:
output_devices[device] = DigitalOutputDevice(
config["Devices"][device], active_high=False
)
i2c = board.I2C()
aht_device = adafruit_ahtx0.AHTx0(i2c)
greenhouse = GreenHouse(config, lcd, output_devices, aht_device)
greenhouse.setting_up_controlling()
greenhouse.start()
except KeyboardInterrupt:
lcd.clear()
lcd.cursor_pos = (0, 0)
lcd.write_string(datetime.now().strftime("%d.%m.%y %H:%M:%S"))
lcd.cursor_pos = (3, 2)
lcd.write_string("Benutzerabbruch!")
sleep(3)
schedule.clear()
lcd.close(clear=True)
if __name__ == "__main__":
main()
Alles anzeigen
Ich passe das oben geschrieben ggf. nochmal an.
Nachbau passiert auf eigene Gefahr.
Ich habe da noch eine kleine Infosammlung:
Einmal ein längerer Thread hier im Forum (Forumsperlen Erdfeuchte - Bewässerung
Auf Seite 17 findet man noch folgende Links:
https://www.n8chteule.de/zentris-blog/2…-1-einfuehrung/
https://www.n8chteule.de/zentris-blog/2…on-programming/
Und dort beim stöbern:
https://www.n8chteule.de/zentris-blog/2…n-beschichtung/
https://www.n8chteule.de/zentris-blog/2…urethan-part-2/
Auch wenn das etwas veraltet ist, kann es doch an der ein- oder anderen Stelle weiterhelfen.
z.B.: Stichwort Polyurethan, Algorithmen zum Auslesen der Sensoren, ...
MfG
Jürgen
moinsen,
was ich bei allem hier vermisse, ist die angabe, WAS (größe, substrat, flach- oder tiefwurzler, und und und ...) denn bewässert werden soll ...
ich hatte es kürzlich mit einem hochbeet zu tun gehabt, 4000 x 1500 x 400mm erdvolumen ... letztendlich geht es doch m e i s t e n s darum, die komplette erde g l e i c h m ä s s i g feucht zu bekommen/halten ... das messen wäre das eine, das bewässern das andere ...
ich hätte da eine methode, die ich eingesetzt habe, und auch funktioniert ... dazu eine kurze denkaufgabe:
was passiert, wenn du die letzten 2 cm der beine einer jeans in wasser hältst ?
sie wird nach gut 4 stunden (dauer ist auch unwichtig) komplett feucht sein ...
=> 2 sehr große behälter unters hochbeet gestellt, eine jeansbahn 7000 x 1000mm im erdbett 'verlegt', die beiden enden der bahn jeweils in einen behälter, fertisch.
erde ist UND bleibt feucht. das nachfüllen der behälter gut alle 2 monate mittels gartenschlauch und seitenanschluss. da muss nichts gemessen werden, den rest macht die natur ... und eine entsprechende entwässerung ist natürlich auch vorhanden, wird aber bisher nicht benötigt ...
viel erfolg !
was ich bei allem hier vermisse, ist die angabe, WAS (größe, substrat, flach- oder tiefwurzler, und und und ...)
Hast du dir die Threads durchgelesen?
Du hast noch kein Benutzerkonto auf unserer Seite? Registriere dich kostenlos und nimm an unserer Community teil!