3
0
Эх сурвалжийг харах

ESP Anpassungen fuer den 8266

Chris Hoelzel 4 жил өмнө
parent
commit
dbb0d6a85e
6 өөрчлөгдсөн 86 нэмэгдсэн , 5 устгасан
  1. 1 0
      .gitignore
  2. 0 0
      SIM.py
  3. 30 0
      main.py
  4. 22 0
      test/TO.py
  5. 28 5
      test/esp_uart.py
  6. 5 0
      test/mainTest.py

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+__pycache__

+ 0 - 0
AlarmSMS.py → SIM.py


+ 30 - 0
main.py

@@ -0,0 +1,30 @@
+# Alarmgeber MainCode
+
+# 2022-03-06 - devnull - initial
+
+from machine import Pin
+from machine import Timer
+
+# Wir brauchen unsere Variablen
+import config
+import SIM
+
+
+znr = "017643609376"
+atxt = "Alarm in Garage 1 ausgeloest"
+wz = 600
+
+# INPUT Callback Funktion
+#   GPIO4
+def INcheckCallback(t):
+    p4 = Pin(4, Pin.IN, Pin.PULL_UP)    # create input pin on GPIO4 aber Bitte PullUP, weil das hier ja ein Taster ist
+    print("Taster = " + str(p4.value()))       # get value, 0 or 1
+
+
+
+# das ist der Timer zur Tasterabfrage
+tim = Timer(1)
+
+# periodic with 100ms period
+tim.init(period=500, callback=INcheckCallback)
+

+ 22 - 0
test/TO.py

@@ -0,0 +1,22 @@
+class TO:
+    name=None
+    age=0
+
+    def __init__(self,name=None,age=0):
+        print ("setze Namen auf " + str(name))
+        self.setName(name)
+        print("setze Alter auf " + str(age))
+        self.setAge(age)
+
+
+    def setName(self,name):
+        self.name=name
+
+    def getName(self):
+        return self.name
+
+    def setAge(self,age):
+        self.age=age
+
+    def getAge(self):
+        return self.age

+ 28 - 5
test/esp_uart.py

@@ -1,9 +1,32 @@
 # demo script zum Testversand einer SMS
 
+import time
 from machine import UART
-uart = UART(1, baudrate=115200)
-uart.write('ATI\r\n')
-uart.write('AT+CPIN?\r\n')
-uart.write('AT+CPIN=2389\r\n') # PIN Check
-#uart.read(5) # read up to 5 bytes
+import os
 
+
+
+print("warte 5s auf Abbruch ...")
+time.sleep(5)
+
+uartOUT = UART(1, baudrate=115200)
+uartIN = UART(0,baudrate=115200)
+
+while True:
+
+    print("Repl abhängen")
+    os.dupterm(None,1)
+
+    print("AT Kommando senden")
+    uart.write('ATI\r\n')
+
+    print("Repl anhängen")
+    os.dupterm(UART(0, 115200))
+
+    #uart.write('AT+CPIN?\r\n')
+    #uart.write('AT+CPIN=2389\r\n') # PIN Check
+    #uart.read(5) # read up to 5 bytes
+
+    print("warte 5s ...")
+    time.sleep(5)
+    print("-------[ naechster Lauf ]-------")

+ 5 - 0
test/mainTest.py

@@ -0,0 +1,5 @@
+from TO import *
+
+testobject = TO("Testnutzer", 15)
+
+print ("Gegentest: " + str(testobject.name) + " ist " + str(testobject.age) + " Jahre alt")