Esempio n. 1
0
def stromstaerke():

    read_arduino.read()
    Measure0 = float(globvar.measure0)
    stromstaerkeSpan = Measure0 * 4.86 / 1023  #umwandeln von 8 bit in spannungswert
    stromstaerke = stromstaerkeSpan / 10  #ohm

    return stromstaerke
 def testCorrectResult(self, mock_Serial):
     """
     Checks the correct parsing of the result
     """
     target = unittest.mock.MagicMock()
     mock_Serial.return_value = target
     target.readline.side_effect = [b'123 456 789 876 543 0 333 1023']
     read_arduino.read()
     self.assertEqual(123, globvar.measure0)
Esempio n. 3
0
def spannung():

	read_arduino.read()
	
	Measure0=globvar.measure0
	
	spannung=Measure0*4.86/1023  #umwandeln von 8 bit in spannungswert

	return spannung
 def testNoEndlessLoop(self, mock_Serial):
     """
     The read must not yield into an endless loop. After several retries a ValueError will be thrown
     """
     target = unittest.mock.MagicMock()
     mock_Serial.return_value = target
     target.readline.return_value = b'123 456'  # a shortened result should give a retry
     with self.assertRaises(
             ValueError
     ):  # a value error should be raised after several tries
         read_arduino.read()
 def testCorruptedResult(self, mock_Serial):
     """
     Checks that a measurement is retried when garbaged data is read
     """
     target = unittest.mock.MagicMock()
     mock_Serial.return_value = target
     target.readline.side_effect = [
         b'123 4\x136 789 876 543 0 333 1023',
         b'321 456 789 876 543 0 333 1023'
     ]
     read_arduino.read()
     self.assertEqual(321, globvar.measure0)
Esempio n. 6
0
def leistung():

    read_arduino.read()  #Empfangen der Daten
    Measure0 = globvar.measure0  #importieren der Daten
    spannung = Measure0 * 4.86 / 1023  #8 bit in spannungswert

    Measure1 = globvar.measure1  #für die Leistung  2 werte messen
    stromstaerkeSpan = Measure1 * 4.86 / 1023  #8 bit in spannung
    stromstaerke = stromstaerkeSpan / 10  #I=U/R

    leistung = spannung * stromstaerke

    return leistung  #Ausgabe der Leistung
Esempio n. 7
0
def widerstand():

    read_arduino.read()
    Measure0 = float(globvar.measure0)
    if Measure0 == 0:
        widerstand = "messfehler"
    else:
        widerstandREF = 1100
        widerstandSPAN = Measure0 * 4.86 / 1023  #umwandeln von 8 bit in spannungswert

        #anwenden von u/(r1+r2)= u2/r2 umgewandelt zu r1=((u*r2)/u2)-r2
        widerstandZS1 = 5 * widerstandREF
        widerstandZS2 = widerstandZS1 / widerstandSPAN
        widerstand = widerstandZS2 - widerstandREF

    return widerstand
Esempio n. 8
0
def temperatur():

    read_arduino.read()
    #Berechnung des Widerstandswert vom NTC
    tempOhmREF = 1100
    Measure0 = float(globvar.measure0)
    tempSPAN = Measure0 * 4.86 / 1023  #umwandeln von 8 bit in spannungswert
    #anwenden von u/(r1+r2)= u2/r2 umgewandelt zu r1=((u*r2)/u2)-r2
    tempZS1 = 5 * tempOhmREF
    tempZS2 = tempZS1 / tempSPAN
    tempNTCohm = tempZS2 - tempOhmREF

    ##tempNTCohm=10000
    #Berechnung der Temperatur anhand von widerstand + ntc Eigenschaften
    ntczs1 = tempNTCohm / 10000
    ntczs2 = math.log10(ntczs1)
    ntczs3 = ntczs2 * 0.0002911208151382824
    ntczs4 = ntczs3 + 0.0033540164346805303
    TempKelvin = 1 / ntczs4

    Temperatur = TempKelvin - 273.15  #umwandeln in Celsius

    return Temperatur