diff --git a/executor_esp32.ino b/executor_esp32.ino new file mode 100644 index 0000000..8f68ec5 --- /dev/null +++ b/executor_esp32.ino @@ -0,0 +1,38 @@ +#include + +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); +} + diff --git a/sim800l.py b/sim800l.py index 6bdac9a..187cab6 100644 --- a/sim800l.py +++ b/sim800l.py @@ -28,6 +28,7 @@ class SIM800L: def setup(self): 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+CMGF=1\n') # plain text SMS self.command('AT+CLTS=1\n') # enable get local timestamp mode @@ -91,8 +92,8 @@ class SIM800L: if params2[0]=='+CMGR': number = params[1].replace('"',' ').strip() date = params[3].replace('"',' ').strip() - time = params[4].replace('"',' ').strip() - return [number,date,time,self.savbuf] + reception_time = params[4].replace('"',' ').strip() + return [number,date,reception_time,self.savbuf] return None def delete_sms(self,id): @@ -122,3 +123,5 @@ class SIM800L: return self.read_sms(1) finally: self.command('AT+CMGDA="DEL ALL"\n',1) + + #-------------------Callback functions--------------------------------