Ich möchte einen Brutkasten selbst bauen und programmieren (ich bin ein Anfänger) leider kommt immer der Fehler,
Unhandled exception in thread started by <function aktualisieren2 at 0x7366e370>
Traceback (most recent call last):
Unhandled exception in thread started by File "/home/pi/Desktop/BQPI/BQPI.py", line 235, in aktualisieren2
<function aktualisieren2 at 0x7366e370>
testtext = "Temperatur: {0:0.1f}*C ". format(float(temperature))
Traceback (most recent call last):
TypeError File "/home/pi/Desktop/BQPI/BQPI.py", line 235, in aktualisieren2
: testtext = "Temperatur: {0:0.1f}*C ". format(float(temperature))
float() argument must be a string or a numberTypeError
: Unhandled exception in thread started by float() argument must be a string or a number
Ich habe das schon einige Leute gezeigt aber leider kommen die auch nicht auf den Fehler ich bin schon am verzweifeln


Mein Python ist 2.7.9 meine Programmierung lautet:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# GUI module generated by PAGE version 4.9
# In conjunction with Tcl version 8.6
# Jul 31, 2017 05:22:26 AM
import thread
import time, threading
Time = time.strftime("%d.%m.%Y %H:%M:%S") #Time
from random import randint
from Tkinter import *
import matplotlib.pyplot as plt
import time
from time import *
from time import sleep
import sys
import Adafruit_DHT
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(13, GPIO.OUT)
GPIO.setup(12, GPIO.OUT)
GPIO.setup(40, GPIO.OUT) # Set LedPin's mode is output
GPIO.output(40, GPIO.HIGH) # Set LedPin high(+3.3V) to off led
Temp = []
Luft = []
plt.ion()
cnt=0
try:
from Tkinter import *
except ImportError:
from tkinter import *
try:
import ttk
py3 = 0
except ImportError:
import tkinter.ttk as ttk
py3 = 1
import BQPI_support
def vp_start_gui():
'''Starting point when module is the main routine.'''
global val, w, root
root = Tk()
top = Bee_Queen_PI (root)
BQPI_support.init(root, top)
root.mainloop()
w = None
def create_Bee_Queen_PI(root, *args, **kwargs):
'''Starting point when module is imported by another program.'''
global w, w_win, rt
rt = root
w = Toplevel (root)
top = Bee_Queen_PI (w)
BQPI_support.init(w, top, *args, **kwargs)
return (w, top)
def destroy_Bee_Queen_PI():
global w
w.destroy()
w = None
class Bee_Queen_PI:
def __init__(self, top=None):
'''This class configures and populates the toplevel window.
top is the toplevel containing window.'''
_bgcolor = '#d9d9d9' # X11 color: 'gray85'
_fgcolor = '#000000' # X11 color: 'black'
_compcolor = '#d9d9d9' # X11 color: 'gray85'
_ana1color = '#d9d9d9' # X11 color: 'gray85'
_ana2color = '#d9d9d9' # X11 color: 'gray85'
font9 = "-family Verdana -size 16 -weight bold -slant roman " \
"-underline 0 -overstrike 0"
top.geometry("900x510+132+196")
top.title("Bee Queen PI")
top.configure(background="#d6d9c1")
top.configure(highlightcolor="black")
self.lab37 = Label(top)
self.lab37.place(relx=0.08, rely=0.06, height=68, width=280)
self.lab37.configure(activebackground="#f9f9f9")
self.lab37.configure(background="#d6d9c1")
self.lab37.configure(font=font9)
self.lab37.configure(text='''Temperatur''')
self.Label2 = Label(top)
self.Label2.place(relx=0.64, rely=0.06, height=78, width=280)
self.Label2.configure(activebackground="#f9f9f9")
self.Label2.configure(background="#d6d9c1")
self.Label2.configure(font=font9)
self.Label2.configure(text='''Luftfeuchtigkeit''')
self.Canvas1 = Canvas(top)
self.Canvas1.place(relx=0.03, rely=0.37, relheight=0.59, relwidth=0.77)
self.Canvas1.configure(background="white")
self.Canvas1.configure(borderwidth="2")
self.Canvas1.configure(relief=RIDGE)
self.Canvas1.configure(selectbackground="#c4c4c4")
self.Canvas1.configure(width=694)
self.Canvas1.create_text(10, 200, text="test", anchor="nw")
self.Label3 = Label(top)
self.Label3.place(relx=0.43, rely=0.24, height=28, width=117)
self.Label3.configure(activebackground="#f9f9f9")
self.Label3.configure(background="#d6d9c1")
self.Label3.configure(font=font9)
self.Label3.configure(text='''Heizung''')
self.Button1 = Button(top)
self.Button1.place(relx=0.41, rely=0.29, height=26, width=62)
self.Button1.configure(activebackground="#d9d9d9")
self.Button1.configure(text='''on''')
self.Button1.bind('<Button-1>',lambda e:BQPI_support.on(e))
self.Button2 = Button(top)
self.Button2.place(relx=0.51, rely=0.29, height=26, width=62)
self.Button2.configure(activebackground="#d9d9d9")
self.Button2.configure(text='''off''')
self.Button2.bind('<Button-1>',lambda e:BQPI_support.off(e))
self.Entry1 = Entry(top)
self.Entry1.place(relx=0.82, rely=0.45, relheight=0.04, relwidth=0.16)
self.Entry1.configure(background="white")
self.Entry1.configure(font="TkFixedFont")
self.Entry1.configure(selectbackground="#c4c4c4")
self.Entry2 = Entry(top)
self.Entry2.place(relx=0.82, rely=0.53, relheight=0.04, relwidth=0.16)
self.Entry2.configure(background="white")
self.Entry2.configure(font="TkFixedFont")
self.Entry2.configure(selectbackground="#c4c4c4")
self.Entry3 = Entry(top)
self.Entry3.place(relx=0.82, rely=0.49, relheight=0.04, relwidth=0.16)
self.Entry3.configure(background="white")
self.Entry3.configure(font="TkFixedFont")
self.Entry3.configure(selectbackground="#c4c4c4")
self.Label1 = Label(top)
self.Label1.place(relx=0.86, rely=0.37, height=28, width=77)
self.Label1.configure(activebackground="#f9f9f9")
self.Label1.configure(background="#d6d9c1")
self.Label1.configure(font=font9)
self.Label1.configure(text='''Info''')
self.Entry4 = Entry(top)
self.Entry4.place(relx=0.82, rely=0.57, relheight=0.04, relwidth=0.16)
self.Entry4.configure(background="white")
self.Entry4.configure(font="TkFixedFont")
self.Entry4.configure(selectbackground="#c4c4c4")
self.Entry5 = Entry(top)
self.Entry5.place(relx=0.82, rely=0.61, relheight=0.04, relwidth=0.16)
self.Entry5.configure(background="white")
self.Entry5.configure(font="TkFixedFont")
self.Entry5.configure(selectbackground="#c4c4c4")
self.Entry6 = Entry(top)
self.Entry6.place(relx=0.82, rely=0.65, relheight=0.04, relwidth=0.16)
self.Entry6.configure(background="white")
self.Entry6.configure(font="TkFixedFont")
self.Entry6.configure(selectbackground="#c4c4c4")
self.Entry7 = Entry(top)
self.Entry7.place(relx=0.82, rely=0.69, relheight=0.04, relwidth=0.16)
self.Entry7.configure(background="white")
self.Entry7.configure(font="TkFixedFont")
self.Entry7.configure(selectbackground="#c4c4c4")
self.Label4 = Label(top)
self.Label4.place(relx=0.43, rely=0.04, height=28, width=117)
self.Label4.configure(activebackground="#f9f9f9")
self.Label4.configure(background="#d6d9c1")
self.Label4.configure(font=font9)
self.Label4.configure(text='''Licht''')
self.Button3 = Button(top)
self.Button3.place(relx=0.41, rely=0.12, height=26, width=62)
self.Button3.configure(activebackground="#d9d9d9")
self.Button3.configure(text='''on''')
self.Button3.bind('<Button-1>',lambda e: BQPI_support.Lichton(e))
self.Button4 = Button(top)
self.Button4.place(relx=0.51, rely=0.12, height=26, width=62)
self.Button4.configure(activebackground="#d9d9d9")
self.Button4.configure(text='''off''')
self.Button4.bind('<Button-1>',lambda e: BQPI_support.Lichtoff(e))
thread.start_new_thread(aktualisieren2, (self,))# aktualisieren
thread.start_new_thread(aktualisieren2, (self,))# aktualisieren
thread.start_new_thread(aktualisieren2, (self,))# aktualisieren
thread.start_new_thread(aktualisieren2, (self,))# aktualisieren
thread.start_new_thread(aktualisieren2, (self,))# aktualisieren
thread.start_new_thread(aktualisieren2, (self,))# aktualisieren
thread.start_new_thread(aktualisieren2, (self,))# aktualisieren
thread.start_new_thread(aktualisieren2, (self,))# aktualisieren
thread.start_new_thread(aktualisieren2, (self,))# aktualisieren
thread.start_new_thread(aktualisieren2, (self,))# aktualisieren
thread.start_new_thread(aktualisieren2, (self,))# aktualisieren
thread.start_new_thread(aktualisieren2, (self,))# aktualisieren
thread.start_new_thread(aktualisieren2, (self,))# aktualisieren
thread.start_new_thread(aktualisieren2, (self,))# aktualisieren
thread.start_new_thread(aktualisieren2, (self,))# aktualisieren
thread.start_new_thread(aktualisieren2, (self,))# aktualisieren
# Holt sich die Werte vom Sensor
def aktualisieren2(s):
while True:
sensor = Adafruit_DHT.DHT22
pin = 4
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
testtext = "Temperatur: {0:0.1f}*C ". format(float(temperature))
s.lab37.configure(text=testtext )
testtexte = "Luftfeuchtigkeit: {1:0.1f}%". format(temperature,humidity)
s.Label2.configure(text=testtexte )
#luft = humidity
#temp = temperature
#print(temp)
#Temp.append(temp)
#Temp.pop(0)
#print(luft)
#Luft.append(luft)
#Luft.pop(0)
#plotNow()
plt.pause(5)
#sleep(20)
if temperature < 35.8: #Relais_3 steuerung Temperatur unter Wert on
GPIO.output(13, GPIO.LOW) #Heizungsteuerung on!!
#print(' Automatik Heizung und Luefter on %s ' % Time ) # Time anzeige
if temperature > 35.9: #Relais steuerung Temperatur unter Wert off
GPIO.output(13, GPIO.HIGH) #Heizungsteuerung off!!
if temperature < 35.8: #Relais_3 steuerung Temperatur unter Wert on
GPIO.output(12, GPIO.LOW) #Lüfter on!!
if temperature > 36: #Relais steuerung Temperatur unter Wert off
GPIO.output(12, GPIO.HIGH) #Lüfter off!!
if __name__ == '__main__':
vp_start_gui()
Ich hoffe mir kann wer helfen das alles funktioniert
LG Max