This commit is contained in:
chabisik 2022-12-15 12:15:38 +01:00
джерело e71d1500b1
коміт b907521f59
2 змінених файлів з 43 додано та 2 видалено

38
executor_esp32.ino Звичайний файл

@ -0,0 +1,38 @@
#include <ESP32Servo.h>
Servo myservo; // create servo object to control a servo
int servoPin = 18;
void closeCircuitAndOpen(int closeTime=400)
{
int pos = 0;
for(pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
delay(closeTime);
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
void setup()
{
// Allow allocation of all timers
ESP32PWM::allocateTimer(0);
ESP32PWM::allocateTimer(1);
ESP32PWM::allocateTimer(2);
ESP32PWM::allocateTimer(3);
myservo.setPeriodHertz(50); // standard 50 hz servo
myservo.attach(servoPin, 1000, 2000); // attaches the servo on pin 18 to the servo object
myservo.write(0);delay(2500); // position to initial suitable position
}
void loop()
{
closeCircuitAndOpen();
delay(5000);
}

@ -28,6 +28,7 @@ class SIM800L:
def setup(self): def setup(self):
self.command('ATE0\n') # command echo off self.command('ATE0\n') # command echo off
self.command('AT+CFUN=1\n') # set
self.command('AT+CLIP=1\n') # caller line identification self.command('AT+CLIP=1\n') # caller line identification
self.command('AT+CMGF=1\n') # plain text SMS self.command('AT+CMGF=1\n') # plain text SMS
self.command('AT+CLTS=1\n') # enable get local timestamp mode self.command('AT+CLTS=1\n') # enable get local timestamp mode
@ -91,8 +92,8 @@ class SIM800L:
if params2[0]=='+CMGR': if params2[0]=='+CMGR':
number = params[1].replace('"',' ').strip() number = params[1].replace('"',' ').strip()
date = params[3].replace('"',' ').strip() date = params[3].replace('"',' ').strip()
time = params[4].replace('"',' ').strip() reception_time = params[4].replace('"',' ').strip()
return [number,date,time,self.savbuf] return [number,date,reception_time,self.savbuf]
return None return None
def delete_sms(self,id): def delete_sms(self,id):
@ -122,3 +123,5 @@ class SIM800L:
return self.read_sms(1) return self.read_sms(1)
finally: finally:
self.command('AT+CMGDA="DEL ALL"\n',1) self.command('AT+CMGDA="DEL ALL"\n',1)
#-------------------Callback functions--------------------------------